pose_estimation/blender/functions.py
def render_image(
        cam_ob, cam_pos, cam_quat, ob, ob_pos, ob_quat, image_file, alpha=True,
        world_RGB=None):
    '''
    set the camera and object to a position and orientation, take, and save an
    image
    '''

    cam_ob.location = cam_pos
    cam_ob.rotation_mode = 'QUATERNION'
    cam_ob.rotation_quaternion = cam_quat

    ob.location = ob_pos
    ob.rotation_mode = 'QUATERNION'
    ob.rotation_quaternion = ob_quat
    bpy.data.scenes['Scene'].render.filepath = image_file

    if world_RGB is not None:
        A = np.array([1.0]) # alpha for world RGBA lighting
        RGBA = np.concatenate((world_RGB, A))
        bpy.data.worlds['World'].node_tree.nodes['Background'].inputs[0]. \
            default_value = RGBA

    if not alpha:
        bpy.data.scenes['Scene'].render.image_settings.color_mode = 'RGB'
        bpy.data.scenes['Scene'].cycles.film_transparent = False

    else:
        bpy.data.scenes['Scene'].render.image_settings.color_mode = 'RGBA'
        bpy.data.scenes['Scene'].cycles.film_transparent = True

    bpy.ops.render.render(write_still=True)

    set the camera and object to a position and orientation, take, and save an
    image
    
set the camera and object to a position and orientation, take, and save an
image
set the camera and object to a position and orientation take and save an image
def render_image(
        cam_ob, cam_pos, cam_quat, ob, ob_pos, ob_quat, image_file, alpha=True,
        world_RGB=None):
    cam_ob.location = cam_pos
    cam_ob.rotation_mode = 'QUATERNION'
    cam_ob.rotation_quaternion = cam_quat
    ob.location = ob_pos
    ob.rotation_mode = 'QUATERNION'
    ob.rotation_quaternion = ob_quat
    bpy.data.scenes['Scene'].render.filepath = image_file
    if world_RGB is not None:
        A = np.array([1.0]) 
        RGBA = np.concatenate((world_RGB, A))
        bpy.data.worlds['World'].node_tree.nodes['Background'].inputs[0]. \
            default_value = RGBA
    if not alpha:
        bpy.data.scenes['Scene'].render.image_settings.color_mode = 'RGB'
        bpy.data.scenes['Scene'].cycles.film_transparent = False
    else:
        bpy.data.scenes['Scene'].render.image_settings.color_mode = 'RGBA'
        bpy.data.scenes['Scene'].cycles.film_transparent = True
    bpy.ops.render.render(write_still=True)
def render_image ( cam_ob , cam_pos , cam_quat , ob , ob_pos , ob_quat , image_file , alpha = True , world_RGB = None ) : cam_ob . location = cam_pos cam_ob . rotation_mode = 'QUATERNION' cam_ob . rotation_quaternion = cam_quat ob . location = ob_pos ob . rotation_mode = 'QUATERNION' ob . rotation_quaternion = ob_quat bpy . data . scenes [ 'Scene' ] . render . filepath = image_file if world_RGB is not None : A = np . array ( [ 1.0 ] ) RGBA = np . concatenate ( ( world_RGB , A ) ) bpy . data . worlds [ 'World' ] . node_tree . nodes [ 'Background' ] . inputs [ 0 ] . default_value = RGBA if not alpha : bpy . data . scenes [ 'Scene' ] . render . image_settings . color_mode = 'RGB' bpy . data . scenes [ 'Scene' ] . cycles . film_transparent = False else : bpy . data . scenes [ 'Scene' ] . render . image_settings . color_mode = 'RGBA' bpy . data . scenes [ 'Scene' ] . cycles . film_transparent = True bpy . ops . render . render ( write_still = True )
set the camera and object to a position and orientation, take, and save an
image
set the camera and object to a position and orientation take and save an image
'''
    set the camera and object to a position and orientation, take, and save an
    image
    ''' # alpha for world RGBA lighting
cam_ob
cam_pos
cam_quat
ob
ob_pos
ob_quat
image_file
alpha
world_RGB