Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented flags in cv::detectMultiScale #4387

Closed
opencv-pushbot opened this issue Jul 27, 2015 · 4 comments
Closed

Undocumented flags in cv::detectMultiScale #4387

opencv-pushbot opened this issue Jul 27, 2015 · 4 comments

Comments

@opencv-pushbot
Copy link

@opencv-pushbot opencv-pushbot commented Jul 27, 2015

Transferred from http://code.opencv.org/issues/2142

|| Yves Quemener on 2012-07-04 17:10
|| Priority: Low
|| Affected: None
|| Category: documentation
|| Tracker: Bug
|| Difficulty: None
|| PR: None
|| Platform: None / None

Undocumented flags in cv::detectMultiScale

In order for cv::detectMultiScale to take into account the MaxSize parameter, the flag CV_HAAR_SCALE_IMAGE must be set. This flag is not documented. The current documentation redirects to the old documentation for cvHaarDetectObjects which only mentions a single flag : CV_HAAR_DO_CANNY_PRUNING

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

History

@StevenPuttemans

This comment has been minimized.

Copy link
Contributor

@StevenPuttemans StevenPuttemans commented Aug 7, 2015

This is indeed still the case for the old cascades, but not for the cascades generated by the newer train_cascade interface. Since we were told that the haartraining interface will no longer be developed and actually be removed in the OpenCV3 interface, we should close down this bug, because fixing deprecated software is just not manageable.

@StuartIanNaylor

This comment has been minimized.

Copy link

@StuartIanNaylor StuartIanNaylor commented Nov 30, 2016

Going back to the flags in cv::detectMultiScale apols as I am an OpenCV noob but why is there a lack of flags in the detect method so devs have more control over processing power vs accuracy?

I have been playing with a Raspberry Pi 3 which copes but does provide high latency via cv::detectMultiScale CV_HAAR_SCALE_IMAGE.

I managed to route out some code for cv.HaarDetectObjects which uses the flag

CV_HAAR_DO_CANNY_PRUNING

I am finding cv.HaarDetectObjects is more than 100% processor efficient than cv::detectMultiScale in fact way, way faster.
I am presuming much of this is due to the flag CV_HAAR_DO_CANNY_PRUNING which subtracts huge areas of featureless ROI.

DO_CANNY_PRUNING
If it is set, the function uses Canny edge detector to reject some image regions that contain too few or too much edges and thus can not contain the searched object. The particular threshold values are tuned for face detection and in this case the pruning speeds up the processing

SCALE_IMAGE
For each scale factor used the function will downscale the image rather than "zoom" the feature coordinates in the classifier cascade. Currently, the option can only be used alone, i.e. the flag can not be set together with the others

FIND_BIGGEST_OBJECT
If it is set, the function finds the largest object (if any) in the image. That is, the output sequence will contain one (or zero) element(s)

DO_ROUGH_SEARCH
It should be used only when CV_HAAR_FIND_BIGGEST_OBJECT is set and min_neighbors > 0. If the flag is set, the function does not look for candidates of a smaller size as soon as it has found the object (with enough neighbor candidates) at the current scale. Typically, when min_neighbors is fixed, the mode yields less accurate (a bit larger) object rectangle than the regular single-object mode (flags=CV_HAAR_FIND_BIGGEST_OBJECT), but it is much faster, up to an order of magnitude. A greater value of min_neighbors may be specified to improve the accuracy.

Is cv.HaarDetectObjects going to receive support as it is so much faster and also those flags do actually make much difference?

@StevenPuttemans

This comment has been minimized.

Copy link
Contributor

@StevenPuttemans StevenPuttemans commented Nov 30, 2016

@StuartIanNaylor let me give you some answers

Is cv.HaarDetectObjects going to receive support as it is so much faster and also those flags do actually make much difference?

I guess not. The cv interface is the C-based API and is only still there because it is legacy code. However, it will be gone some day, so no support will be given for it.

If the flags do make so much difference, then maybe you should provide a PR that integrates the flags and accompanied code into the current detectMultiScale functionality. I guess that is the only way you are getting it in.

I am presuming much of this is due to the flag CV_HAAR_DO_CANNY_PRUNING which subtracts huge areas of featureless ROI.

Actually, there is nothing holding you back to run do this technique yourself. Why should the actual detector do this for you? You can basically make a mask and run the detector only there. I do it all the time in my research.

other flags

Most of them are actually there, but not as flags but as actual parameters to be set. Scaling can be influenced. Getting largest object is simply looping over your returned data.

The only one seeming to be missing is the rough search now.

@StuartIanNaylor

This comment has been minimized.

Copy link

@StuartIanNaylor StuartIanNaylor commented Dec 3, 2016

Actually it works on cv::detectMultiScale and its a choice of SCALE_IMAGE alone or if not included any of the other flags.

FIND_BIGGEST_OBJECT and FIND_BIGGEST_OBJECT are part of the function and can not be done before and as said

but it is much faster, up to an order of magnitude

Doing this after will not be any faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.