0
$\begingroup$

Rosanswers logo

Hello

I have generated a bag file using an Turtlebot Kinect camera with openni and it contains the topic /camera/depth/image_raw. I subscribed to this topic and got the depth image correctly and I converted it to an openCV image in its callback as follows: depthImage_ptr=cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::TYPE_32FC1); using the 32FC1 encoding.

The problem is that when I print the depth of any cell, for example ROS_INFO("depth = %.2f",depthImage_ptr->image.at(Point2f(200,300)));

I get values that are too large to be considered in meters. Here is an example of output [ INFO] [1431974682.739030530]: depth = 2426.00 [ INFO] [1431974683.904995806]: depth = 2281.00 [ INFO] [1431974685.126654288]: depth = 2101.00 [ INFO] [1431974686.354065935]: depth = 1883.00

My question is what is the unit of this depth? If it is meter, then the values I got are misleading? I browsed a lot of pages in ROS wiki and all mention that the unit of the depth when printed as float is in meter, and when printed as uint16 is millimeter. But as I mentioned, the values are too large. If it is in centimeters, then the values would be more logic.

What can be wrong with my settings? I am really blocked and I would appreciate to have any pointer on this.

Thank you Anis


Originally posted by Anis on ROS Answers with karma: 253 on 2015-05-18

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

According to the openni_camera wiki page, /camera/depth/image_raw "contains uint16 depths in mm."


Originally posted by Dan Lazewatsky with karma: 9115 on 2015-05-18

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by lanyusea on 2015-05-23:
Hi Dan, thanks for your answer. I subscribed topic'/camera/depth/image_raw' and print its value at certain pixel but I got a complex number... Does the distance equal to its modulus or I made something wrong?

Comment by lanyusea on 2015-05-23:
my code:

   def get_distance(img):
       bridge=CvBridge()
       cv_image = bridge.imgmsg_to_cv2(img, "32FC1")
       print cv_image[10,10]

   rospy.Subscriber('/camera/depth/image_raw',Image,get_distance)

result: [ 2.75039315+2.75118136j] ...

Comment by Dan Lazewatsky on 2015-05-23:
What happens if you don't specify an encoding (defaulting to "passthrough")?

Comment by lanyusea on 2015-05-23:
@Dan Lazewatsky "passthrough" works, the result will be an integer. Does it mean python has already decoded the image once? I just tried cpp,and I need to decode with sensor_msgs::image_encodings::TYPE_32FC1.

Comment by Dan Lazewatsky on 2015-05-23:
passthrough uses the encoding specified in the message. If you use another encoding, it will use opencv Mat.convertTo. If that doesn't do what you want, you'll have to do the conversion yourself.

Comment by lanyusea on 2015-05-23:
thanks for your reply.

Comment by lanyusea on 2015-05-23:
one more question: the data I got (both cpp and python) are not integer. It is a floating number like 0.711012. It should be uint16 as mentioned, but what I got is a float number. I didn't use a real kinect, I was running a simulation from turtlebot_gazebo. Is that the reason why I got a float?

$\endgroup$

Your Answer

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