我想从相机中获取部分图像。我有这个代码。这段代码在相机上显示的是矩形。我需要得到矩形包含图像。
for(int i=0;i<(detectRect_face ? detectRect_face->total:0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem(detectRect_face, i);
CvPoint pt1 = { r->x+20, r->y+20 };
CvPoint pt2 = { r->x + r->width-20, r->y + r->height-10 };
cvRectangle(frame, pt1, pt2, CV_RGB(255,0,0), 1,8, 0);
//I need to write here a method to get this rectangle include image.
}发布于 2013-04-09 10:17:31
您可以使用cvSetImageROI和cvCopy方法裁剪图像。
IplImage *dst = // Prepare partition size image.
cvSetImageROI(frame, r);
cvCopy(frame, dst);
cvResetImageROI(frame);https://stackoverflow.com/questions/15879395
复制相似问题