void detect_eye_in_image()
{
CvRect *face = (CvRect*)cvGetSeqElem(faces, 0);
printf("\nIn detect_eye_in_image() %d %d %d %d\n\n",imgcpy->height,imgcpy->width,face->width,face->height);
cvSetImageROI(
imgcpy, /* the source image */
cvRect(
face->x, /* x = start from leftmost */
face->y , /* y = a few pixels from the top */
face->width, /* width = same width with the face */
face->height/3 /* height = 1/3 of face height */
)
);
printf("\nIn detect_eye_in_image()");
CvSeq *eyes = cvHaarDetectObjects(
imgcpy, /* the source image, with the
estimated location defined */
cascade, /* the eye classifier */
storage, /* memory buffer */
1.15, 3, 0, /* tune for your app */
cvSize(25,25) /* minimum detection scale */
);
printf("\nIn detect_eye_in_image()");
/* draw a rectangle for each detected eye */
// for( i = 0; i < (eyes ? eyes->total : 0); i++ )
{
/* get one eye */
CvRect *eye = (CvRect*)cvGetSeqElem(eyes, 0);
/* draw a red rectangle */
cvRectangle(
imgcpy,
cvPoint(eye->x, eye->y),
cvPoint(eye->x + eye->width, eye->y + eye->height),
CV_RGB(255, 0, 0),
1, 8, 0
);
}
printf("\nIn detect_eye_in_image()");
Show_Image(imgcpy);
cvResetImageROI(imgcpy);
}
在上面的函数中,我继续得到以下输出:
在detect_eye_in_image()154 154 154 154
OpenCV错误:断言失败(rect.width&gt; = 0&amp;&amp; rect.height&gt; = 0&amp;&amp; rect.x&lt; image-&gt; width&amp;&amp; rect.y&lt; image-&gt; height&amp;&amp; rect.x + rect.width&gt; =(int)(rect.widt h&gt; 0)&amp;&amp; rect.y + rect.height&gt; =(int)(rect.height&gt; 0))在未知函数中,file ........ \ ocv \ opencv \ src \ cxcore \ cxarray.cpp,line 3000
如何解决这个问题?
答案 0 :(得分:4)
您可能在图像尺寸之外工作。您传递给cvSetImageROI
函数的任何值是否位于图像boudaries之外?