0
$\begingroup$

Rosanswers logo

I'm using a turtlebot (Create base) with a kinect. I need to save images automatically (RGB and depth images) when the turtlebot is in front of a object that is less than 1 meter away. Therefore, i need to get access to the data values of depth image, and convert the numbers to get the distance. How can i do that ? And what's the appropriate topic to get what i need ?

For sure i'll have a code running, and since i'm new to ros i still have some silly doubts:

  • My goal is to use the images on opencv. Is it necessary to install again or the one who come with ros hydro is enough ?
  • When saving depth images from /camera/depth/image topic manually, i get a .jpg completely black. Anyone knows why ?
  • What's the best way to get start with opencv ? How to save a image thought a C++ code and etc.

Thanks!


Originally posted by Thiagopj on ROS Answers with karma: 23 on 2014-07-10

Post score: 0


Original comments

Comment by Henschel.X on 2016-03-23:
My project is kind of similar with yours, but the time I see it, it is 2016 lol. I met the same problem just as you do.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi there,

You don't need to convert the data on the depth image topic manually. If you execute roslaunch openni_launch openni.launch you should have the topic /camera/depth/points which is a 3D Point Cloud with the depth image converted to what you want.

About OpenCV, unless you need the bleeding edge functionalities of the ultra-super-last version, the one that comes with ROS is fairly recent and should include everything you need.

Regarding the black jpg image, the data on the topic /camera/depth/image contains uint16 depths in mm, which is not a regular image that can be directly saved as jpg, you would need to convert the depth values to the range of a uchar (consequently loosing information, because uchar is only 8bits) to store it as an image.

Also, the best way to get started with opencv is to follow the tutorials and ask in answers.opencv.org all your questions about the computer vision library.

I hope this helps


Originally posted by Martin Peris with karma: 5625 on 2014-07-11

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Thiagopj on 2014-07-11:
Actually i got the distance in meters using this function

void chatterCallback(const sensor_msgs::Image::ConstPtr& msg) { cv_bridge::CvImagePtr Dest=cv_bridge::toCvCopy(msg); ROS_INFO("Value: %f", Dest->image.at(msg->width/2,msg->height/2)); }

and on function main i have: ros::Subscriber sub = n.subscribe("/camera/depth/image", 1000, chatterCallback);

The output is the distance in meters between the sensor and the central pixel. Using the 'points' topic whats the difference ?

I now have to transform the image received from kinect to a OpenCV image and then try to convert and save it. Any tutorial that could help with that?

Thank you for the answer!

Comment by rasoo on 2016-10-23:
why you are only interested for the depth value of center point? if I am not wrong, In your image some points or object could be more closer/far, getting the center point popnt distance does not imply that every point of the image are at same distance

$\endgroup$

Your Answer

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