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:
/* ... 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
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.