Adding a MaxSize parameter in cvHaarDetectObjects (Feature #523)


Added by Yves Quemener over 14 years ago. Updated about 12 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:objdetect
Target version:2.4.3
Difficulty: Pull request:

Description

Hello,
I had the need for a MaxSize parameter in cvHaarDetectObjects in order to speed up the detection of small human faces for this project : http://bitbucket.org/iv/headcounter/wiki/Home

So I did in what I suppose must be the right way : I modified haar.cpp to not assume that the maximum size of the object to be detected is the image size but to instead use the optional parameter maxSize. This resulted in a significant performance improvement in my application (~2 or 3 times faster).

I have seen one person requesting this feature in the Yahoo Group so I guess the included patch can be useful.


patch.20100812.maxsizeforobjdetect (4.2 kB) Yves Quemener, 2010-08-12 12:37 am


Related issues

related to Bug #2142: Undocumented flags in cv::detectMultiScale Open 2012-07-04

Associated revisions

Revision ec45453b
Added by Takahiro Horikawa over 12 years ago

#523 Fix the problem where the MaxSize parameter in cvHaarDetectObjects does not work when the flag CV_HAAR_SCALE_IMAGE is not set.

Revision e68901bb
Added by Andrey Kamaev about 12 years ago

Merge pull request #523 from taka-no-me:fix_2815

History

Updated by Vadim Pisarevsky over 14 years ago

the feature is implemented in SVN version

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Updated by Benjamin Ross almost 14 years ago

Using the latest SVN version, the max size parameter does not seem to take effect. I wrote a face detector with minimum set to cvSize(30,30) and maximum set to cvSize(40,40) on a 640x480 image. What I expected to happen was that faces greater than 40x40 pixels in size would not be detected, however my face was detected with me standing right in front of the camera, with a size of about 400x400 pixels. Please verify this works correctly.

  • Status changed from Done to Cancelled
  • (deleted custom field) deleted (fixed)

Updated by Benjamin Ross almost 14 years ago

I should note, I am using the older "c" style opencv commands. I am using cvHaarDetectObjects(...), rather than the c++ implementation. I compiled the SVN trunk for x64.

Updated by Maria Dimashova almost 14 years ago

I could not reproduced your problem. I got r5419 and run sample facedetect.cpp (with modified detectMultiScale() call to set minimum size to Size(30, 30) and maximum size to Size(40, 40) as you). Also I printed to the screen the found rectangles size. To run cvHaarDetectObjects(), existing here opencv/data/haarcascades/haarcascade_frontalface_alt.xml old cascade was used. Images are got from camera. I varied distance to the camera, but I got rectangles (faces) of size in the range 30..40 only.
Also judging by the code of cvHaarDetectObjects the problem should not be.

  • Status changed from Cancelled to Done
  • (deleted custom field) set to fixed

Updated by Benjamin Ross over 13 years ago

I just tried this with the latest svn. Please re-investigate this. The max face size parameters ONLY works for the LBP cascades and NOT for the HAAR cascades.

  • Status changed from Done to Cancelled
  • (deleted custom field) deleted (fixed)

Updated by Yves Quemener over 12 years ago

Recently I tried to update my old project to newer versions of OpenCV and I discovered a condition for this bug : it only occurs when the flag CV_HAAR_SCALE_IMAGE is not set. Try commenting the line 209 in the example facedetect.cpp, add a maximum size and this bug should reappear.

I filled a documentation bug ( http://code.opencv.org/issues/2142 ) to indicate that this flags is absent from the documentation. I can not say, however, if the resulting behavior is normal, therefore I'll let someone more knowledgeable reopen or not this report.

Updated by Yves Quemener over 12 years ago

Tested both with Debian's 2.3.1 and latest 2.4.9 from the SVN

Updated by Kirill Kornyakov over 12 years ago

We'll try to check it. MaxSize is useful parameter, especially for slow Haar detector...

  • Status changed from Cancelled to Open
  • Category changed from imgproc, video to objdetect

Updated by Takahiro Horikawa over 12 years ago

Hello, I just sent pull request for fixing this issue. My commit should make MaxSize parameter work even when the flag CV_HAAR_SCALE_IMAGE is not set. Please check and merge : https://github.com/Itseez/opencv/pull/29

Updated by Andrey Kamaev over 12 years ago

Thanks Takahiro, your pull request is merged to master.

  • Target version deleted ()
  • Status changed from Open to Done
  • Assignee set to Andrey Kamaev

Updated by Andrey Kamaev about 12 years ago

  • Target version set to 2.4.3

Also available in: Atom PDF