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

convert iplImage to sensor_msgs::ImageConstPtr

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

RosFaceNoob gravatar image

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

ngrennan gravatar image

Hi everyone,
I have some problem to understand how to convert images with cvbridge. I red the tutorial : .

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

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

BennyRe gravatar image

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

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


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 -0600 )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 -0600 )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 -0600 )edit

Question Tools


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

Seen: 1,110 times

Last updated: Apr 16 '14