- IplImage* small_image = image;
- CvMemStorage* storage = cvCreateMemStorage(0);
- CvSeq* faces;
- int i, scale = 1;
-
- /* if the flag is specified, down-scale the input image to get a
- performance boost w/o loosing quality (perhaps) */
- if(do_pyramids)
- {
- small_image = cvCreateImage(cvSize(image->width/2,image->height/2),
- IPL_DEPTH_8U, 3);
- cvPyrDown(image, small_image, CV_GAUSSIAN_5x5);
- scale = 2;
- }
-
- /* use the fastest variant */
- faces = cvHaarDetectObjects(small_image, cascade, storage, 1.2, 2,
- CV_HAAR_DO_CANNY_PRUNING);
-
- update_idle(faces->total);
-
- /* draw all the rectangles */
- for(i = 0; i < faces->total; i++)
- {
- /* extract the rectangles only */
- CvRect face = *(CvRect*)cvGetSeqElem(faces, i);
- CvPoint upperLeft = cvPoint(face.x * scale, face.y * scale);
- CvPoint bottomRight = cvPoint((face.x + face.width) * scale,
- (face.y + face.height) * scale);
- cvRectangle(image, upperLeft, bottomRight, CV_RGB(255,0,0), 3);
- }
-
- if(small_image != image)
- cvReleaseImage(&small_image);
- cvReleaseMemStorage(&storage);
+ IplImage* small_image = image;
+ CvMemStorage* storage = cvCreateMemStorage(0);
+ CvSeq* faces;
+ int i, scale = 1;
+
+ /* if the flag is specified, down-scale the input image to get a
+ performance boost w/o loosing quality (perhaps) */
+ if(do_pyramids)
+ {
+ small_image = cvCreateImage(cvSize(image->width/2,
+ image->height/2),
+ IPL_DEPTH_8U, 3);
+ cvPyrDown(image, small_image, CV_GAUSSIAN_5x5);
+ scale = 2;
+ }
+
+ /* use the fastest variant */
+ faces = cvHaarDetectObjects(small_image, cascade, storage, 1.2, 2,
+ CV_HAAR_DO_CANNY_PRUNING);
+
+ update_idle(faces->total);
+
+ /* draw all the rectangles */
+ for(i = 0; i < faces->total; i++)
+ {
+ /* extract the rectangles only */
+ CvRect face = *(CvRect*)cvGetSeqElem(faces, i);
+ CvPoint upperLeft = cvPoint(face.x * scale, face.y * scale);
+ CvPoint bottomRight = cvPoint((face.x + face.width) * scale,
+ (face.y + face.height) * scale);
+ cvRectangle(image, upperLeft, bottomRight, CV_RGB(255,0,0), 3);
+ }
+
+ if(small_image != image)
+ cvReleaseImage(&small_image);
+ cvReleaseMemStorage(&storage);