problem with cv_bridge [closed]

asked 2012-11-08 22:24:41 -0500

schizzz8 gravatar image

updated 2012-11-09 02:04:32 -0500

I'm having trouble with using imgMsgToCv() function. I'm using it in a subscriber node to convert images acquired from a camera to opencv IplImage:

void imageCallback(const sensor_msgs::ImageConstPtr& msg)

{

sensor_msgs::CvBridge bridge;

IplImage* imgB = bridge.imgMsgToCv( msg, "mono8");

.

.

in this way things work but I need imgB to be a global variable and when I try to write things like this:

IplImage* imgB;

void imageCallback(const sensor_msgs::ImageConstPtr& msg)

{

sensor_msgs::CvBridge bridge;

imgB = bridge.imgMsgToCv( msg, "mono8");

.

I get this error:

.

/home/dede/electric_workspace/sandbox/labrob_ros_quadrotor/labrob_project/src/viewer.cpp:20:49: error: no match for ‘operator=’ in ‘imgB = bridge.sensor_msgs::CvBridge::imgMsgToCv(boost::shared_ptr<const sensor_msgs::image_<std::allocator<void=""> > >((* & msg)), std::basic_string<char>(((const char)"mono8"), ((const std::allocator<char>*)(& std::allocator<char>()))))’

/home/dede/electric_workspace/sandbox/labrob_ros_quadrotor/labrob_project/src/viewer.cpp:20:49: note: candidate is: /usr/include/opencv-2.3.1/opencv2/core/types_c.h:447:16: note: _IplImage& _IplImage::operator=(const _IplImage&) /usr/include/opencv-2.3.1/opencv2/core/types_c.h:447:16: note: no known conversion for argument 1 from ‘IplImage* {aka _IplImage*}’ to ‘const _IplImage&’

/home/dede/electric_workspace/sandbox/labrob_ros_quadrotor/labrob_project/src/viewer.cpp:25:25: error: ‘sensor_msgs::CvBridge::cv_bridge’ has not been declared

but I can't understand where is the problem, any hints on it?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-06-26 19:49:37.734081

Comments

I even cannot find the definition of the method imgMsgToCv that you are trying to use. Which ROS distro are you using? Make sure you have read http://ros.org/wiki/Support and check out http://www.ros.org/wiki/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages

Lorenz gravatar image Lorenz  ( 2012-11-09 02:48:06 -0500 )edit