def setup_cameras(self): """Setup camera, and place at a default location""" # get scene scene = bpy.context.scene # add camera, update with calibration data, and make it active for the scene bpy.ops.object.add(type='CAMERA', location=(0.66, -0.66, 0.5)) self.cam_obj = bpy.context.object self.cam = self.cam_obj.data camera_utils.set_camera_info(scene, self.cam, self.config.camera_info) # re-set camera and set rendering size bpy.context.scene.camera = self.cam_obj if (self.config.camera_info.width > 0) and (self.config.camera_info.height > 0): bpy.context.scene.render.resolution_x = self.config.camera_info.width bpy.context.scene.render.resolution_y = self.config.camera_info.height # look at center blnd.look_at(self.cam_obj, Vector((0.0, 0.0, 0.0))) # get effective extrinsics effective_intrinsic = camera_utils.get_intrinsics(scene, self.cam) # store in configuration (and backup original values) if self.config.camera_info.intrinsic is not None: self.config.camera_info.original_intrinsic = self.config.camera_info.intrinsic else: self.config.camera_info.original_intrinsic = '' self.config.camera_info.intrinsic = list(effective_intrinsic)
def setup_render_output(self): # setup render output dimensions. This is not set for a specific camera, # but in renders render environment # first set the resolution if it was specified in the configuration if (self.config.camera_info.width > 0) and (self.config.camera_info.height > 0): bpy.context.scene.render.resolution_x = self.config.camera_info.width bpy.context.scene.render.resolution_y = self.config.camera_info.height # Setting the resolution can have an impact on the intrinsics that were # used for rendering. Hence, we will store the effective intrinsics # alongside. # First, get the effective values effective_intrinsic = camera_utils.get_intrinsics(bpy.context.scene, self.cam) # Second, backup original intrinsics, and store effective intrinsics if self.config.camera_info.intrinsic is not None: self.config.camera_info.original_intrinsic = self.config.camera_info.intrinsic else: self.config.camera_info.original_intrinsic = '' self.config.camera_info.intrinsic = list(effective_intrinsic)
def get_effective_intrinsics(self): """Get the effective intrinsics that were used during rendering. This function will copy original values for intrinsic, sensor_width, and focal_length, and fov, to the configuration an prepend them with 'original_'. This way, they are available in the dataset later on """ cam_str = self.config.scene_setup.cameras[0] cam_name = self.get_camera_name(cam_str) cam = bpy.data.objects[cam_name].data # get the effective intrinsics effective_intrinsic = camera_utils.get_intrinsics(bpy.context.scene, cam) # store in configuration (and backup original values) if self.config.camera_info.intrinsic is not None: self.config.camera_info.original_intrinsic = self.config.camera_info.intrinsic else: self.config.camera_info.original_intrinsic = '' self.config.camera_info.intrinsic = list(effective_intrinsic)