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

publishing image data as sensor_msgs

asked 2011-09-13 22:20:06 -0600

updated 2011-09-13 22:21:18 -0600

I am working on ubuntu platform and I have an ueye usb camera. Using ueye_api I have managed to write a .cpp program which captures a frame and stores it in a memory space allocated according to image size and bit depth. The program returns pointer to this memory space (say ppcImgMem) and it is of char type. ppcImgMem is a single array with ppcImgMem[0] corresponding to the pixel value of the first image pixel in unsigned format.

Now, I want to publish this image as sensor message (sensor_msgs) using image_transport. I have created a package which successfully does the same for frames captured by my webcam using gscam driver. But I do not have a driver for the ueye usb cam. I also tried to publish the array as a standard message and it is working but I think it would be better if I can publish it as sensor_msgs/Image form for further processing. Can somebody tell me how can I proceed from here onwards ?

-Abhinav

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-09-14 03:27:21 -0600

The easiest way to do this is to load your image data into a CvMat, and use cv_bridge to convert that to a sensor_msgs/Image, which can then easily be published using image_transport.

edit flag offensive delete link more

Comments

yes, I agree with you. Yesterday after going through some more tutorials from ros and opencv I reached the same conclusion. But thanks for reply now I am confident that I am on right track.
abhinav gravatar image abhinav  ( 2011-09-14 19:32:57 -0600 )edit
But I still have some doubts regarding header information of sensor_msgs/Image which I think can extract using some functions from ueye_api but they are not part of image vector for which I have the pointer. Is this header information mandatory or can it be skipped ?
abhinav gravatar image abhinav  ( 2011-09-14 19:39:41 -0600 )edit
Regarding loading image data into CvMat, since I have image data in vector form I think I have two options : 1) I can create a 1D CvMat and reshape it after loading data into it, OR 2) I can create a 2D CvMat and load my image data using a for loop. Can you tell me which one looks better to you ?
abhinav gravatar image abhinav  ( 2011-09-14 19:53:23 -0600 )edit

Question Tools

Stats

Asked: 2011-09-13 22:20:06 -0600

Seen: 1,474 times

Last updated: Sep 14 '11