Ask Your Question
0

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

asked May 01 '11

this post is marked as community wiki

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

updated May 02 '11

Murph gravatar image Murph
483 1 14 35
http://localhost/

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.

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered May 01 '11

this post is marked as community wiki

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

updated May 01 '11

tfoote gravatar image tfoote flag of United States
11130 27 85 172
http://www.ros.org/

I suggest you take a look at the cv_bridge tutorials

link delete flag offensive edit

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 (May 02 '11)edit
All messages should do a full copy on assignment. tfoote (May 06 '11)edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

Follow

subscribe to rss feed

Stats

Asked: May 01 '11

Seen: 142 times

Last updated: May 02 '11