[ros-users] Convert sensor_msgs/Image to the opencv image

Soonhac Hong soonhac.hong at gmail.com
Fri Nov 19 20:49:39 UTC 2010


Hi all,

I'm trying to convert sensor_msgs/Image to the opencv image. The 
sensor_msgs/Image is defined in the ros service as follows.

<temp_srv.srv>
bool isColor
----
sensor_msgs/Image left_image


The problem has happened at the following code.

IplImage* left_image = bridge_.imgMsgToCv((const 
sensor_msgs::ImageConstPtr&) srv.response.left_image, "passthrough");

Without the casting,(const sensor_msgs::ImageConstPtr&), there was an 
compile error. With the casting, there is a runtime error, segmentation 
fault. Is there anyone to know how to get the 
sensor_msgs::ImageConstPtr& of the sensor_msgs/Image which is defined in 
the ros service?

I confirmed that there are the proper value of each pixel in the 
srv.response.left_image.data[] as well as srv.response.left_image.width 
and srv.response.left_image.hight.

Thank you for any comments.

Best,
Soonhac




More information about the ros-users mailing list