title: OpenCV Error: Assertion failed
body: <pre><code>void detect_eye_in_image()
  {
      CvRect *face = (CvRect*)cvGetSeqElem(faces, 0);
              
  printf(&quot;\nIn detect_eye_in_image() %d %d %d %d\n\n&quot;,imgcpy-&gt;height,imgcpy-&gt;width,face-&gt;width,face-&gt;height);
          cvSetImageROI(
          imgcpy,                    /* the source image */
          cvRect(
              face-&gt;x,            /* x = start from leftmost */
              face-&gt;y , /* y = a few pixels from the top */
              face-&gt;width,        /* width = same width with the face */
              face-&gt;height/3    /* height = 1/3 of face height */
          )
      );
  
  printf(&quot;\nIn detect_eye_in_image()&quot;);
          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(&quot;\nIn detect_eye_in_image()&quot;);
      /* draw a rectangle for each detected eye */
     // for( i = 0; i &lt; (eyes ? eyes-&gt;total : 0); i++ ) 
      {
          /* get one eye */
          CvRect *eye = (CvRect*)cvGetSeqElem(eyes, 0);
          /* draw a red rectangle */
          cvRectangle(
              imgcpy,
              cvPoint(eye-&gt;x, eye-&gt;y),
              cvPoint(eye-&gt;x + eye-&gt;width, eye-&gt;y + eye-&gt;height),
              CV_RGB(255, 0, 0),
              1, 8, 0
          );
      }
  printf(&quot;\nIn detect_eye_in_image()&quot;);
      Show_Image(imgcpy);
  
  cvResetImageROI(imgcpy);
  }
  </code></pre>
  <p>In the above function i keep getting the following output:</p>
  <blockquote>
  <p>In detect_eye_in_image() 154 154 154 154</p>
  <p>OpenCV Error: Assertion failed (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)) in unknown function, f ile ........\ocv\opencv\src\cxcore\cxarray.cpp, line 3000</p>
  </blockquote>
  <p>How to fix this problem?</p>