Ask Your Question
0

how to save depth image loss-less to disk

asked 2013-01-29 09:04:58 -0500

dinamex gravatar image

updated 2013-01-29 09:08:56 -0500

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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2013-02-12 10:39:48 -0500

updated 2013-02-12 10:40:20 -0500

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).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-29 09:04:58 -0500

Seen: 1,155 times

Last updated: Feb 12 '13