ChitraPathak / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Face detection result in a inaccurate cvRect's height #156

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

this.grayImage = cvLoadImage("tmp/full_rate.jpg", CV_LOAD_IMAGE_GRAYSCALE);

private CvRect findFace()
{
    IplImage cvImg = this.grayImage;

     IplImage equImg = IplImage.create(cvImg.width(), cvImg.height(), IPL_DEPTH_8U, 1);
     cvEqualizeHist(cvImg, equImg);

     CvSeq faces = cvHaarDetectObjects(equImg, this.classifier, this.storage, 1.1, 1, CV_HAAR_DO_ROUGH_SEARCH | CV_HAAR_FIND_BIGGEST_OBJECT);  

      int total = faces.total();
      if (total == 0) {
         resetROI();
         return null;
       }

       CvRect rect = new CvRect(cvGetSeqElem(faces, 0));

       cvClearMemStorage(this.storage);
       return rect;
}

Trying to use above code to get the first face detected but the height of the 
cvRect result is somehow very strange like this:
x: 265, y:214, width:84, height:117309508

What is the expected output? What do you see instead?
a normal height value

What version of the product are you using? On what operating system?
latest JavaCV and Windwos 7

Please provide any additional information below.

Original issue reported on code.google.com by kylau...@gmail.com on 17 Feb 2012 at 9:40

GoogleCodeExporter commented 9 years ago
The case is very random sometimes the value is normal but sometimes is not

Original comment by kylau...@gmail.com on 17 Feb 2012 at 9:41

GoogleCodeExporter commented 9 years ago
Memory returned by cvGetSeqElem() is not going to be valid after calling 
cvClearMemStorage(). Do not call cvClearMemStorage() until you no longer need 
the memory. And please read OpenCV's documentation if you intend on using 
OpenCV.

Original comment by samuel.a...@gmail.com on 17 Feb 2012 at 9:46