none
point cloud from depth image RRS feed

  • Question

  • Hi, I m trying to get the point cloud from depth image but I get the following error at the transformation step:

    [error] [t=11448] /home/vsts/work/1/s/extern/Azure-Kinect-Sensor-SDK/src/transformation/rgbz.c (74): transformation_compare_image_descriptors(). Unexpected image descriptor. Expected width_pixels: 640, height_pixels: 576, stride_bytes: 1280. Actual width_pixels: 640, height_pixels: 576, stride_bytes: 3840

    Here is my code: Depth image format is K4A_IMAGE_FORMAT_DEPTH16

    Depth16 res: 576x 640 stride: 1280
    Point cloud res: 576x 640 stride: 1280
    

    //Set device configuration
    	k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL;
    	config.camera_fps = K4A_FRAMES_PER_SECOND_30;
    	config.color_format = K4A_IMAGE_FORMAT_COLOR_BGRA32;
    	config.color_resolution = K4A_COLOR_RESOLUTION_2160P;
    	config.depth_mode = K4A_DEPTH_MODE_NFOV_UNBINNED;
    	config.synchronized_images_only=true;
    
    	// Start the camera with the given configuration
    
    	if (K4A_RESULT_SUCCEEDED != k4a_device_start_cameras(device, &config))
    	{
    		printf("Failed to start device\n");
    		k4a_device_close(device);
    		return -1;
    	}
    
    	// Camera capture and application specific code would go here
    	k4a_capture_t capture;
    	k4a_image_t color_image, depth_image;
    	while(true)
    	{
    		k4a_device_get_capture(device, &capture, 10000);		
    		
    		// Capture a depth frame
    		depth_image = k4a_capture_get_depth_image(capture);
    		
    		
    		if (depth_image != NULL)
    		{
    			
    			depth_frame=cv::Mat(k4a_image_get_height_pixels(depth_image), k4a_image_get_width_pixels(depth_image), CV_8UC4, k4a_image_get_buffer(depth_image));
    
    			k4a_image_t point_cloud_image;
    			k4a_image_create( K4A_IMAGE_FORMAT_CUSTOM, k4a_image_get_width_pixels(depth_image),k4a_image_get_height_pixels(depth_image),
    							k4a_image_get_stride_bytes(depth_image), &point_cloud_image);
    			k4a_calibration_t sensor_calibration;
    			k4a_device_get_calibration(device, config.depth_mode, config.color_resolution, &sensor_calibration))
    
    
    			k4a_transformation_t transform= k4a_transformation_create(&sensor_calibration);
    			
    			if (K4A_RESULT_SUCCEEDED !=k4a_transformation_depth_image_to_point_cloud(transform , depth_image, K4A_CALIBRATION_TYPE_DEPTH, point_cloud_image))
    			{
    				printf("Get depth camera transform failed!\n");
    				return 0;
    			}
    			




    Monday, July 22, 2019 10:41 PM

All replies

  • I found a fix. I was't initializing the point cloud image with the right stride size.

    k4a_image_t point_cloud_image;
    			if (K4A_RESULT_SUCCEEDED !=k4a_image_create( K4A_IMAGE_FORMAT_CUSTOM, 
    					depth_image_width_pixels,depth_image_height_pixels,
    					depth_image_width_pixels * 3 * (int)sizeof(int16_t),
    					 &point_cloud_image))

    Tuesday, July 23, 2019 3:47 PM