0
$\begingroup$

Rosanswers logo

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!


Originally posted by Rydel on ROS Answers with karma: 600 on 2012-07-09

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Martin Peris with karma: 5625 on 2012-07-09

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Rydel on 2012-07-10:
thanks for the help! I'll have to mull it over for a while, I'm new to OOP and OpenCV.

$\endgroup$

Your Answer

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