Esempio n. 1
0
    ## read configuration file
    cfg = ConfigParser("config.yml")

    ## initialize resting surface
    env = cfg.getSurfaceType()
    if env == 'table':
        surface = Table('surface_models/table/table.obj')
    elif env == 'shelf':
        surface = Shelf('surface_models/shelf/shelf.obj')
    sPose = cfg.getSurfacePose()
    surface.setPose(sPose)

    ## initialize camera
    camIntrinsic = cfg.getCamIntrinsic()
    camExtrinsic = cfg.getCamExtrinsic()
    numViews = cfg.getNumViews()
    cam = Camera(camIntrinsic, camExtrinsic, numViews)

    ## initialize light
    pLight = Light()

    ## initialize objects
    objModelList = cfg.getObjModelList()
    objectlist = []
    for objFileName in objModelList:
        bpy.ops.import_scene.obj(filepath="obj_models/" + objFileName + "/" + objFileName + ".obj")
        imported = bpy.context.selected_objects[0]
        objectlist.append(imported.name)
    for item in bpy.data.materials:
        print (item)
    argv = sys.argv
    argv = argv[argv.index("--") + 1:]
    num = int(argv[0])

    ## read configuration file
    cfg = ConfigParser("config.yml", "camera_info.yml")
    framesIter = cfg.getNumSimulationSteps()

    ## initial condition
    if num == 0:
        env = cfg.getSurfaceType()
        surface = Bin('3d_models/bin/shelf.obj')
        sPose = cfg.getSurfacePose()
        surface.setPose(sPose)
        camIntrinsic = cfg.getCamIntrinsic()
        maxCamViews, camExtrinsic = cfg.getCamExtrinsic(
        )  # maxCamViews: num of poses
        numViews = cfg.getNumViews()
        cam = Camera(camIntrinsic, camExtrinsic, numViews)
        cam_pose = cam.placeCamera(0)
        pLight = Light()
        light_range_x = cfg.getLightRangeX()
        light_range_y = cfg.getLightRangeY()
        light_range_z = cfg.getLightRangeZ()
        pLight.placePointLight(light_range_x, light_range_y, light_range_z)

    if num > 0:
        scene_path = os.path.join(
            g_repo_path,
            'rendered_images/image_%05i/labels/obj_poses.yml' % num)
        numObjectsInScene, o1_poses = cfg.getObjPoses(scene_path, 1)
        for i in range(0, numObjectsInScene):