IplImage *src = cvCreateImage(cvSize(1000,800), IPL_DEPTH_8U,3);
dst = cvCreateImage(cvGetSize(src), 8, 3);
//以下rheight、rwidth、rx、ry是經過擬合函數的坐標值等信息計算得出的
float rheight=box.size .height *abs(cos(box.angle))+box.size.width*abs(sin(box.angle ));
float rwidth=box.size .height*abs(sin(box.angle))+box.size.width*abs(cos(box.angle ));
float rx=(center.x-rwidth/2)>0?(center.x-rwidth/2):0;
float ry=(center.y-rheight/2)>0?(center.y-rheight/2):0;
CvRect rect = cvRect(rx,ry,rheight,rwidth);
IplImage * dst11 = cvCreateImage(dst_size11, dst->depth, dst->nChannels);
//以上是這個函數的參數,在某一函數內調用這個函數如下格式:
GetImageRect(dst, rect, dst11);
//函數內部如下:
void GetImageRect(IplImage* orgImage, CvRect rectInImage, IplImage* imgRect)//從圖像orgImage中提取一塊(rectInImage)子圖像imgRect
{
//從圖像orgImage中提取一塊(rectInImage)子圖像imgRect
IplImage *result=imgRect;
CvRect size;
size.x=rectInImage.x;
size.y=rectInImage.y;
size.width=rectInImage.width;
size.height=rectInImage.height;
result=cvCreateImage(cvGetSize(orgImage), orgImage->depth, orgImage->nChannels );
//從圖像中提取子圖像
cvSetImageROI(orgImage,size);
cvCopy(orgImage,result);
cvResetImageROI(orgImage);
}
程序出現了錯誤,如下圖:
在cmd中卻出現了如下提示:
加斷點看出的梁圖片變量也未覺不妥;
求大神們幫幫忙解答一下,我究竟要如何修改代碼呢?
妹紙先在此謝過了~
cvCopy(orgImage,result);你的圖片深度或者大小不匹配,導致圖像拷貝出錯