Ask Your Question
0

How to use depth value from /camera/depth/image?

asked 2014-02-01 00:54:14 -0500

Safeer gravatar image

updated 2014-04-20 14:09:25 -0500

ngrennan gravatar image

I am using this code

topic is: /camera/depth/image
type: /sensor_msgs/Image

According to the code, (msg->data[0]) is providing the value of Top-Left Corner.

I wanted to ask:

  1. How can I get the value of the Top-Right Corner, Centre, etc.
  2. How can I get the normal depth value that can tell me the distance from the object? Do I need to do some mathematical work or is there a method?
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2014-02-06 23:50:08 -0500

Wolf gravatar image

In the code the message is already converted to a cv::Mat ( cv_ptr->image ). Use this Matrix if you want to do some processing of the data.

E.g. you can use

float dist_val = cv_ptr->image.at<float>( 10, 10 );

to get the value at 10, 10. (There are much faster methods if you not just want to access one pixel, though).

See, http://docs.opencv.org for infos on how to handle your data with OpenCV.

edit flag offensive delete link more

Comments

Thanks for your help. I visited the link you gave. Please guide me which topics/tutorials should I follow?

Safeer gravatar imageSafeer ( 2014-02-10 01:37:27 -0500 )edit

That very much depends on what you actually want to do. Probably some of the core and improc tutorials. If you want to do object detection: "Creating Bounding boxes and circles for contours"(particularly cv::findContours() usage). Threshold works also for dist imgs. Likely you need some normalizing.

Wolf gravatar imageWolf ( 2014-02-10 19:37:54 -0500 )edit

Thanks for your reply.

Safeer gravatar imageSafeer ( 2014-02-17 01:16:32 -0500 )edit
0

answered 2017-04-18 09:56:03 -0500

zubair gravatar image

hi but this is giving me always dist_val=0 !! why is that so ??

edit flag offensive delete link more

Comments

Check if your sensor is working fine and is at an acceptable distance from an object.

Safeer gravatar imageSafeer ( 2017-04-18 13:49:44 -0500 )edit

Hello, I have the same problem. Did you find any solution for this issue? Thank you.

User gravatar imageUser ( 2018-07-06 06:42:56 -0500 )edit

Again, check if the sensor is working fine.

Safeer gravatar imageSafeer ( 2018-07-09 00:53:24 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-02-01 00:54:14 -0500

Seen: 5,259 times

Last updated: Apr 18 '17