Haarcascades implementation

163 views
Skip to first unread message

Abdeali Kothari

unread,
Jun 12, 2016, 10:37:18 AM6/12/16
to scikit-image
Hi, I recently switched from opencv to skimage as I found it much more pythonic and easier to install.

There is one feature which I seem to be missing - The Haarcascades and CascadeClassifier[1]. Is there plan to add this in skimage ? I'm quite new to haarcascades, but my understanding is that first there are HAAR features that are found from the image and then these features are classified using multiple weak classifiers (using adaboost) to "detect" an object.

It seems to me that to get this functionality I would need skimage (to create the haar features) and sklearn (for the adaboost setup). I found issues/1431[2] which seems to talk about creating HAAR features.

Am I on the right track ? Is there already some example code available which uses skimage and sklearn using one of the haarcascadde xml files provided by opencv ?

Regards,
Abdeali JK


Daniil Pakhomov

unread,
Jun 12, 2016, 7:12:09 PM6/12/16
to scikit-image
Hello, Abdeali Kothari.

The detection module is about to be integrated.

The respective Pool Request can be found here:

You can clone it, compile, and test. The examples of usage can be found in the /examples or /tests.
Please, report if you have any problems when using it. Also, don't hesitate to ask for help in installing it.

It uses Multi-Block Local Binary Patterns (MB-LBP) instead of Haar Features.
This was done because of speed concerns.
You can use any .xml file from OpenCV directory /lbp to run it.
To run it, you don't need OpenCV dependency though.

Cheers,
Daniil
 
воскресенье, 12 июня 2016 г., 10:37:18 UTC-4 пользователь Abdeali Kothari написал:

Daniil Pakhomov

unread,
Jun 12, 2016, 7:23:36 PM6/12/16
to scikit-image
Also, this might be useful:


воскресенье, 12 июня 2016 г., 10:37:18 UTC-4 пользователь Abdeali Kothari написал:
Hi, I recently switched from opencv to skimage as I found it much more pythonic and easier to install.

Abdeali Kothari

unread,
Jun 12, 2016, 8:54:58 PM6/12/16
to scikit...@googlegroups.com
Hi Daniil,

Thank you very much for that mail

The LBP features do look interesting, and I had no idea OpenCV had that ! It seems LBP is considerably faster than HAAR, but not as accurate[1]. Which makes me wonder whether that is the right choice. Also, there are more pre-trained haarcascades than lbpcascades which makes me favor haarcascade more.

But this implementation is something that I can read and understand how to do it myself better ! Thanks :)

I'm wondering as to why sklearn was not used in pull/1570 [2] ? It seems to me like a lot of the code in skimage/future/detect/cascade.pyx [3] would already be available there (Probably in sklearn.ensemble.AdaBoostClassifier [4])? It could be made an "optional" feature which only works if sklearn is installed ?

Regards,
Abdeali JK


--
You received this message because you are subscribed to a topic in the Google Groups "scikit-image" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/scikit-image/PIpELINpmek/unsubscribe.
To unsubscribe from this group and all its topics, send an email to scikit-image...@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/bb52ccad-e9fe-4a61-b980-26778bab2267%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Daniil Pakhomov

unread,
Jun 13, 2016, 7:00:27 PM6/13/16
to scikit-image
You are welcome.

In the original paper, the authors got better results using MB-LBP than using Haar features:
http://www.cbsr.ia.ac.cn/users/scliao/papers/Zhang-ICB07-MBLBP.pdf

The scikit-learn wasn't used because:
1) They don't have gentle adaboost.
2) Their implementation is based on pure Python, which is slow.

Overall, the implementation aims to provide very fast detection with good precision.
The implementation also enables one to use OpenMP, which makes it almost real-time for some cases.

воскресенье, 12 июня 2016 г., 17:54:58 UTC-7 пользователь Abdeali Kothari написал:
Reply all
Reply to author
Forward
0 new messages