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

programming with kinect rgb

asked 2012-07-09 09:56:08 -0500

Rydel gravatar image

updated 2016-10-24 09:02:41 -0500

ngrennan gravatar image

I'm writing a program which requires an rgb image from the kinect, ideally I want something like the horizontal slice like the /scan topic only with RGB points instead of depth points but it's not necessary.

What would be the best topic to subscribe to? camera/rgb/image_color? camera/rgb/image_raw? or something else?

Lastly, has anyone had any experience with organizing the data in the above topics? I was surprised when I saw the data in rostopic being published as a 1-dimensional array instead of a 3-dimensional... as I said before I simply would like to extract the RGB values for a horizontal slice in the middle of the image.

Any help or advice appreciated!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-07-09 15:11:16 -0500

updated 2012-07-09 15:15:37 -0500

Hi Rydel!

Regarding which topic to subscribe, the topic camera/rgb/image_raw provides the raw image from the device with Bayer GRBG format (for kinect) and the topic camera/rgb/image_color provides the image already in RGB format.

So, between both of them, I would recommend you to subscribe to camera/rgb/image_color as it is already in RGB format. But, if you calibrated your camera, it would be even better to subscribe to the topic camera/rgb/image_rect_color (generated by the package openni_launch) as it provides the color rectified image (no lens distortion).

To handle the image the best option is to use OpenCV library, the package cv_bridge makes it really easy to transform from ROS images to OpenCV images. You can find a tutorial here.

By the way, never mind the image data being published as a 1-dimensional array, the data is serialized when published and with cv_bridge everything is being taken care for you.

Once you have your image in OpenCV you can, for example, access the horizontal line in the middle of the image like this:

cv::Mat received_image;

/* ... Subscribe to the topic... */
/* ... Convert image to OpenCV using cv_bridge ...*/  

//the matrix middle line will contain the horizontal line in the middle of the image
cv::Mat middle_line = received_image.row(received_image.rows/2);

I hope you find it helpful.

edit flag offensive delete link more

Comments

1

thanks for the help! I'll have to mull it over for a while, I'm new to OOP and OpenCV.

Rydel gravatar image Rydel  ( 2012-07-10 08:19:35 -0500 )edit

Question Tools

Stats

Asked: 2012-07-09 09:56:08 -0500

Seen: 1,978 times

Last updated: Jul 09 '12