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

convert iplImage to sensor_msgs::ImageConstPtr

asked 2014-04-16 05:35:50 -0500

RosFaceNoob gravatar image

updated 2016-10-24 08:36:51 -0500

ngrennan gravatar image

Hi everyone,
I have some problem to understand how to convert images with cvbridge. I red the tutorial : http://wiki.ros.org/cv_bridge/Tutoria... .

But I can't find a way to convert a openCV images to ROS images message. I succed to convert from ROS to openCV. I wanted to use the function toImageMsg() but it returns a sensor_msgs::Image but I want a sensor_msgs::ImageConstPtr.
Can somebody help me please?
Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2014-04-16 06:14:36 -0500

BennyRe gravatar image

updated 2014-04-16 22:12:45 -0500

Try the following:

sensor_msgs::Image my_image = <somehow get this image with toImageMsg()>;
sensor_msgs::ImageConstPtr my_image_const_ptr = &my_image;

sensor_msgs::ImageConstPtr is nothing else than a constant shared pointer to a sensor_msgs::Image.

edit flag offensive delete link more

Comments

I did :
sensor_msgs::ImageConstPtr img_const = &img;
I have this error: conversion from ‘IplImage** {aka _IplImage**}’ to non-scalar type ‘sensor_msgs::ImageConstPtr {aka boost::shared_ptr<const sensor_msgs::image_<std::allocator<void=""> > >}’ requested
I declared "img" like :
IplImage *img

RosFaceNoob gravatar image RosFaceNoob  ( 2014-04-16 21:53:23 -0500 )edit

I updated my answer. my_image should be the result of toImageMsg() I guess

BennyRe gravatar image BennyRe  ( 2014-04-16 22:12:22 -0500 )edit

So first I have to conver my IplImage to a cv_bridge::CvImagePtr, because you can only use toImageMsg() on a cv_bridge::CvImagePtr. Do you know how to do it?

RosFaceNoob gravatar image RosFaceNoob  ( 2014-04-16 22:26:29 -0500 )edit

Question Tools

Stats

Asked: 2014-04-16 05:35:50 -0500

Seen: 1,141 times

Last updated: Apr 16 '14