[ros-users] Error in ImgMsgToCv Method

mufaddal jhaveri mzjhaveri at gmail.com
Sun Nov 7 21:48:59 UTC 2010


I am using the set of wide stereo cameras in PR2 robot in ROS and
subscribing to the raw stereo image topics in a node to be able to do some
further processing on the pair of stereo images.
At the point of conversion from ROS image message to Open CV image, I'm
getting the following error:

Image Step is wrong () in cvInitMatHeader, file
line 162
/opt/ros/sturtle/ros/bin/rosrun: line35: 6859 Illegal Instruction $exepath

I have gone through the Ros Users Archive but I'm unable to figure this
problem out. Can anyone please clarify what am I missing here?

The code for my node is as follows:

void imageCallback(const ImageConstPtr& imageMsg)
//ROS_INFO("I heard something.");
ROS_INFO("Step: %d", imageMsg->step);
ROS_INFO("Width: %d", imageMsg->width);
ROS_INFO("Height: %d", imageMsg->height);
float bytesPerPixel = imageMsg->step / imageMsg->width;
sensor_msgs::CvBridge bridge;
IplImage* image = cvCreateImage(cvSize(imageMsg->width, imageMsg->height),
image->widthStep = imageMsg->width * bytesPerPixel;
//bridge.fromImage(*imageMsg, "passthrough");
//image = bridge.toIpl();
//image->width = imageMsg->width * 3;
image = bridge.imgMsgToCv(imageMsg, "mono8");
cvShowImage("Image Received", image);
catch (CvBridgeException& ex)
ROS_ERROR("[draw_frames] Failed to convert image");
catch (cv::Exception& ex)
ROS_ERROR("Error: %s", ex.err);

Thanks and Regards,
Mufaddal Jhaveri
CS Graduate Student
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20101107/7cd468b3/attachment-0002.html>

More information about the ros-users mailing list