I wonder what is the most effective way of cropping an IplImage in opencv. I currently do the following, but it seems too complicated and I'm sure there's a better way of doing things.
// set ROI on original image, create 'tmp' image and copy data over.
cvSetImageROI(orig_image, cvRect(55, 170, 530, 230));
IplImage *tmp = cvCreateImage(cvGetSize(orig_image),
orig_image->depth,
orig_image->nChannels);
cvCopy(m_depth_run_avg, tmp, NULL);
cvResetImageROI(orig_image);
// copy temporary image back to original image.
IplImage *orig_image= cvCreateImage(cvGetSize(tmp),
tmp->depth,
tmp->nChannels);
cvCopy(tmp, orig_image, NULL);
is there a better way to crop a image?