def transform_depth_to_color(self, input_depth_image_handle, color_image_handle): calibration = _k4a.k4a_calibration_t() # Get desired image format image_format = self.image_get_format(input_depth_image_handle) image_width = self.image_get_width_pixels(color_image_handle) image_height = self.image_get_height_pixels(color_image_handle) image_stride = 0 # Get the camera calibration self.device_get_calibration(self.config.depth_mode, self.config.color_resolution, calibration) # Create transformation transformation_handle = self.transformation_create(calibration) # Create the image handle transformed_depth_image_handle = _k4a.k4a_image_t() self.image_create(image_format, image_width, image_height, image_stride, transformed_depth_image_handle) # Transform the depth image to the color image format self.transformation_depth_image_to_color_camera( transformation_handle, input_depth_image_handle, transformed_depth_image_handle) # Get transformed image data transformed_image = self.image_convert_to_numpy( transformed_depth_image_handle) # Close transformation self.transformation_destroy(transformation_handle) return transformed_image
def bodyTracker_start(self, bodyTrackerModulePath, modelType = _k4abt.K4ABT_DEFAULT_MODEL): # Get depth sensor calibration depthSensorCalibration = _k4a.k4a_calibration_t() self.getDepthSensorCalibration(depthSensorCalibration) # Initialize the body tracker self.body_tracker = kinectBodyTracker(bodyTrackerModulePath, depthSensorCalibration, modelType)
def transform_depth_image_to_point_cloud(self, depth_image_handle: _k4a.k4a_image_t): """Transforms the depth map to point clouds Parameters: depth_image_handle (k4a_image_t): Handle to the Image Returns: point_cloud (k4a_image_t): Handle to point cloud """ calibration = _k4a.k4a_calibration_t() self.getDepthSensorCalibration(calibration) transformation_handle = self.transformation_create(calibration) point_cloud = _k4atypes.k4a_image_t() self.image_create( _k4atypes.K4A_IMAGE_FORMAT_CUSTOM, self.image_get_width_pixels(depth_image_handle), self.image_get_height_pixels(depth_image_handle), self.image_get_width_pixels(depth_image_handle) * 6, point_cloud ) _k4a.VERIFY(self.k4a.k4a_transformation_depth_image_to_point_cloud( transformation_handle, depth_image_handle, _k4atypes.K4A_CALIBRATION_TYPE_DEPTH, point_cloud ), "Error Occur When Make Point Cloud") return point_cloud
def bodyTracker_start(self, bodyTrackerModulePath): # Get depth sensor calibration depthSensorCalibration = _k4a.k4a_calibration_t() self.getDepthSensorCalibration(depthSensorCalibration) # Initialize the body tracker self.body_tracker = kinectBodyTracker(bodyTrackerModulePath, depthSensorCalibration)
def get_readable_calibration(self, depth_mode, color_resolution): """Return a readable_calibration contains intrinsics matrix Args: depth_mode(k4a_depth_mode_t): Mode in which depth camera is operated. color_resolution(k4a_color_resolution_t): Resolution in which color camera is operated. Returns: readable_calibration: .depth_camera_calibration: .cx .cy .fx .fy .color_camera_calibration: .cx .cy .fx .fy .extrinsics: .depth_camera_calibration_matrix: 3x3 numpy array .color_camera_calibration_matrix: 3x3 numpy array """ cal = _k4a.k4a_calibration_t() self.device_get_calibration(depth_mode, color_resolution, cal) return self.readable_calibration(cal)