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

Putting a sensor_msgs/Image into a message, getting it back, and converting it for OpenCV?

asked 2011-05-01 11:56:34 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I'm just doing this wrong somehow.

I've got a Sensor_msgs/Image already. I want to put it into my message which has "Sensor_msgs/Image image" in it's definition.

Can I just do this:

msg.image = *imgPtr;

Or do I need to do some form of deep copy? The data types are a bit too complicated for me to figure out what's going on.

Later, in a service, I want to extract that image and convert it to a IplImage* for use with OpenCV. i'm trying this:

cv_img = cv_bridge::toCvCopy(image, enc::BGR8);
IplImage img; 
img = cv_img->image;
And it seems to be working alright now, but it's hard to tell since i think that first bit is not working.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-05-01 16:26:02 -0600

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I suggest you take a look at the cv_bridge tutorials

edit flag offensive delete link more

Comments

Any idea on the first part - do i need to do a deep copy or something to put an image into the message file? I think the Image i'm sending is not working right now.
Murph gravatar image Murph  ( 2011-05-02 04:17:19 -0600 )edit
All messages should do a full copy on assignment.
tfoote gravatar image tfoote  ( 2011-05-06 18:39:47 -0600 )edit

Question Tools

Stats

Asked: 2011-05-01 11:56:34 -0600

Seen: 3,624 times

Last updated: May 02 '11