Rosanswers logo

Hi all,

I would like to record a scene and save depth image + rgb image of the kinect sensor. therefore I use cv_bridge and save the images to png format. After that I want to use rgbdslam with my recorded data but it seems that I have a lot of data loss.

The color images are stored as 640×480 8-bit RGB images in PNG format.
The depth maps are stored as 640×480 16-bit monochrome images in PNG format.

But when I convert the images back to sensor_msgs::Image and display them with image_view the depth image looks totally different (much darker) as it looks when I directly display the depth image from the sensor.

Would be great to get your thoughts.

Originally posted by dinamex on ROS Answers with karma: 447 on 2013-01-29

Post score: 0


1 Answer 1


Rosanswers logo

Assuming 8UC3 rgb image, and 16UC1 depth image, this is what I use for saving and loading:

// save images 
cv::imwrite("rgb.png",   rgb_img);
cv::imwrite("depth.png", depth_img);

// load images
rgb_img = cv::imread("rgb.png");
depth_img = cv::imread("depth.png", -1);

I believe the crucial part is the -1 flag. From the imread page:

flags: <0 Return the loaded image as is (with alpha channel).

Originally posted by Ivan Dryanovski with karma: 4954 on 2013-02-12

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.