[ros-users] Error in ImgMsgToCv Method

Top Pagina
Bijlagen:
Bericht als e-mail
+ (text/plain)
+ (text/html)
Delete this message
Reply to this message
Auteur: User discussions
Datum:  
Aan: ros-users
CC: aninoy mahapatra
Onderwerp: [ros-users] Error in ImgMsgToCv Method
Hi,

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
tmp/buildd/ros-cturtle-vision-opencv-1.2.4/debian/ros-cturtle-vision-opencv/opt/ros/cturtle/stacks/vision_opencv/opencv2/build/open-svn/modules/core/src/array.cpp,
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),
IPL_DEPTH_8S, 1);
image->widthStep = imageMsg->width * bytesPerPixel;
try
{
//bridge.fromImage(*imageMsg, "passthrough");
//image = bridge.toIpl();
//image->width = imageMsg->width * 3;
image = bridge.imgMsgToCv(imageMsg, "mono8");
cvShowImage("Image Received", image);
cvWaitKey();
}
catch (CvBridgeException& ex)
{
ROS_ERROR("[draw_frames] Failed to convert image");
return;
}
catch (cv::Exception& ex)
{
ROS_ERROR("Error: %s", ex.err);
return;
}
}


Thanks and Regards,
Mufaddal Jhaveri
CS Graduate Student
USC