How can I get the metric distance from the topic "camera/depth/image_raw"?

I am learning turtlebot_simulator. I run turtlebot_gazebo. Then I subscriber the topic "camera/depth/image_raw" using Python. but How can I know the exact distance of each point from the depth image? I can print the information of the image.Like: frame_id: camera_depth_optical_frame

height 480

weight 640

encoding 32FC1

I have seen some similar problems, but have not solved my problem.

edit retag close merge delete

Sort by ยป oldest newest most voted

You can know the know the distance of each point in the world from the camera centered co-ordinate frame. Just subscribe to the topic /camera/depth/points . It is a sensor_msgs::PointCloud2 topic where you have points with [x, y, z] distance from the camera centered coordinate frame.

The package depth_image_proc implements the method to convert the depth image to point cloud [x, y, z] format. Going through the internals of this package can help you in understanding more on how the image is converted to point cloud.

To completely understand and gain access to each point in the point cloud, you need to understand basics of point cloud library and point cloud format. This can be learnt from

http://wiki.ros.org/pcl/Tutorials

http://wiki.ros.org/pcl

EDIT 1 :

Here is something which can be done. First convert the 32

const std::string& enc = depth_msg->encoding;

if (enc.compare("16UC1") == 0)

depth_img = cv_bridge::toCvShare(depth_msg)->image;

else if (enc.compare("32FC1") == 0)

depthImageFloatTo16bit(cv_bridge::toCvShare(depth_msg)->image, depth_img);

// get raw z value (in mm)

uint16_t z_raw = depth_img.at<uint16_t>(v, u);

// z [meters]

z_mean = z_raw * 0.001;

Look here for better understanding : http://docs.ros.org/groovy/api/ccny_r...

Go through in detail and you can completely find what you are asking for.

more

Thank you for your answer.It really a good way to get the depth data. But others say that depth/image_raw(32FC1) contains depth data. "For using the depth image, it is important to note that is a 32-bit float for each pixel, corresponding to meters." My problem is how to get the value of each pixel?

( 2014-04-15 16:05:50 -0600 )edit

Thanks a lot.

( 2014-04-15 16:50:29 -0600 )edit

Stats

Seen: 1,797 times

Last updated: Apr 15 '14