Dear, James, Thanks for the response! CvMat subframe; { cvGetSubRect(frame, &subframe, cvRect(0, 0, height/2, height/2)); pub_omni_.publish(bridge.cvToImgMsg((IplImage *)&subframe, "bgr8")); } works fine for me. (I need to add (IplImage *) before &subframe) FYI. Another option is to use cv::Mat in fromIpltoRosImage @@ -359,7 +359,11 @@ dest.height = cvm->height; dest.step = cvm->step; dest.data.resize(cvm->step * cvm->height); - memcpy((char*)(&dest.data[0]), source->imageData, cvm->step * cvm->height); + + //memcpy((char*)(&dest.data[0]), source->imageData, cvm->step * cvm->height); + cv::Mat m = cv::cvarrToMat(source); + memcpy((char*)(&dest.data[0]), m.data, cvm->step * cvm->height); + return true; } or copy from source->imageData to dest.data for every line. On Fri, Apr 23, 2010 at 10:07 PM, James Bowman wrote: > Hmm, suggest instead of IplImage you use CvMat, as in > > CvMat subframe; > cvGetSubRect(frame, &subframe, cvRect(width/2, height/2, width/2, > height/2)); > pub_narrow_.publish(bridge.cvToImgMsg(&subframe, "bgr8")); > > (I think you are right; cv_bridge does not handle IplImage with ROI > correctly.  But IplImage is deprecated in OpenCV in favor of CvMat.) > > On Fri, Apr 23, 2010 at 4:57 AM, Kei Okada > wrote: >> >> Hi, >> >> Does cv_bridge support converting ROI image to ROS msg? >> >> I'm trying to publish ROI cropped image as followings, however the >> hoge.ppm and published image message are differ. >> hoge.ppm start from (width/2 height/2) of the original image but >> published image starts from (0 0).Both image size are width/2 and >> height/2. >> >>          IplImage *frame = ....; >>          int width = frame->width, height = frame->height; >>          cvSetImageROI(frame, cvRect(width/2, height/2, width/2, >> height/2)); >>          cvSaveImage("hoge.ppm", frame); >>          pub_narrow_.publish(bridge.cvToImgMsg(frame, "bgr8")); >> >> == >> Kei Okada >> _______________________________________________ >> ros-users mailing list >> ros-users@code.ros.org >> https://code.ros.org/mailman/listinfo/ros-users > > > > -- > J. > > > _______________________________________________ > ros-users mailing list > ros-users@code.ros.org > https://code.ros.org/mailman/listinfo/ros-users > >