openCv裁剪图像 [英] openCv crop image
本文介绍了openCv裁剪图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到了问题,我的openCv IplImage裁剪。假设tmp和img都是IplImage *。使用代码:
I running into problems with my openCv IplImage cropping. Assuming both tmp and img are IplImage* . Using the code:
printf("Orig dimensions: %dx%d\n", img->width, img->height);
cvSetImageROI(img, cvRect(0, 0,500,500));
tmp = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);
cvCopy(img, tmp, NULL);
cvResetImageROI(img);
img = cvCloneImage(tmp);
printf("Orig dimensions after crop: %dx%d\n", tmp->width, tmp->height);
当我使用上面的cvRect时,我会得到裁剪为500 x500的图片。
when I use the the cvRect above I'll get an image cropped with a size of 500 x500 as expected, however when i use the rect (400,400,500,500) I'll get an image with the size 500 X 320.
推荐答案
这篇关于openCv裁剪图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文