ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS Kinect OpenCV for depth information of a particular pixel in real-time. [Solved]

asked 2016-02-17 04:40:04 -0600

PKumars gravatar image

updated 2016-02-26 09:48:12 -0600

I followed this tutorial and now I'm able to do image processing with OpenCV in ROS. but I want some more guidance. I want to extract the exact depth information using OpenCV ,ROS, Kinect. Now I'm able to detect a ball. I have the U,V coordinates of that ball. How can I get exact position of that ball with respect to Kinect in 3-dimensions? I mean x,y,z coordinate of the center of the ball if my Kinect camera is at origin for instance.

I hope you understood my problem.

Thanking you Waiting for your valuable replay.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-02-18 09:02:25 -0600

If you subscribe to both /camera/rgb/image and /camera/depth_registered/image you should have to video streams (or maybe you want the image_rect topics). One is the standard RGB image, the other is the depth image that has been transformed into the same frame as the RGB image. A feature located at u,v in the RGB image should also exist at u,v in the depth image. From that information, you should know the u,v and the real-world Z distance. Then I'd recommend using the image_geometry to calculate X,Y. In Python you could use something like image_geometry.PinholeCameraModel.projectPixelTo3dRay or image_geometry.PinholeCameraModel.getDeltaX (and getDeltaY). If you are in C++ you could use the corresponding functions.

edit flag offensive delete link more

Comments

I'm trying to synchronize two topics but no result. If I can use two call backs then how can I transfer u,v from one callback(rgb_callback) to another callback(depth_callback)? I want to transfer so that I can find depth information. I hope you understood my point.

PKumars gravatar image PKumars  ( 2016-02-18 13:29:08 -0600 )edit

If you need the callbacks synchronized, I'd recommend a Time Synchronizer from the message_filters package.

jarvisschultz gravatar image jarvisschultz  ( 2016-02-18 13:55:08 -0600 )edit

I tried to synchronize but I have some problem and I created a new Issue.

http://answers.ros.org/question/22705...

PKumars gravatar image PKumars  ( 2016-02-18 14:32:10 -0600 )edit

I solved the previous problem. now I want to get exact coordinates of my specific object. I'm subscribing /camera/rgb/image_color and /camera/depth/image_raw. I have u,v pixel coordinate from RGB image. i followed this http://nicolas.burrus.name/index.php/... . but couldn't.

PKumars gravatar image PKumars  ( 2016-02-23 04:20:17 -0600 )edit
0

answered 2016-02-17 20:33:08 -0600

Willson Amalraj gravatar image

If you know the focal length of the camera and the depth (distance to the object from the camera), you can use pin-hole camera model to convert pixel values to real-world coordinates.

Focal length of the camera can be found be exploring the camera_info topic that will be published (The value will be px and you have to convert that to mm).

Assuming that you the pixel coordinates of the region of interest, you can get the depth from the depth image published by kinect.

edit flag offensive delete link more

Comments

Hello I have the u,v coordinate of pixel. I'm subscribing two topics."/camera/rgb/image_raw" and "/camera/depth_registered/points" and using two callback function. but I don't know how to use these u,v for extraction of depth of that pixel. I mean how to transfer u,v from rgb_cb to depth_cb?

PKumars gravatar image PKumars  ( 2016-02-18 04:41:59 -0600 )edit

I solved the previous problem. now I want to get exact coordinates of my specific object. I'm subscribing /camera/rgb/image_color and /camera/depth/image_raw. I have u,v pixel coordinate from RGB image. i followed this http://nicolas.burrus.name/index.php/.. . . but couldn't.

PKumars gravatar image PKumars  ( 2016-02-24 05:59:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-17 04:40:04 -0600

Seen: 1,765 times

Last updated: Feb 26 '16