I'm looking for a website to download haar cascades xml files from. It can be for any objects as long as its a properly working cascade.
-
You don't need any website: https://stackoverflow.com/questions/11537585/where-can-i-find-haar-cascades-xml-files/67897482#67897482 – Jeru Luke Jun 29 '22 at 11:52
10 Answers
Go to the opencv folder and check the data folder. You'll find haar-cascades for eyes, face, ears, upper body...:) And they do work properly.
Here's one site http://alereimondo.no-ip.org/OpenCV/34/ Don't know if they work though.

- 5,009
- 22
- 74
- 121
-
thanks but this damn fortiguard blocks me for accessing that website, any other sites you know of? – user1401950 Jul 18 '12 at 09:06
-
http://stackoverflow.com/questions/9015498/need-haar-casscades-for-nose-eyes-lipsmouth The second comment, the download starts immediately. Did you check the opencv folder? – praxmon Jul 18 '12 at 09:08
-
Thanks, I'm looking for other objects as well such dogs, cats,etc. Basically anything found in pictures – user1401950 Jul 18 '12 at 09:35
-
1So, you need the whole world? :P For dogs etc etc you'll have to create your own xml files i guess. People usually need/want face/ears/nose/lips etc. – praxmon Jul 18 '12 at 09:37
-
3The link doesn't work anymore. Moreover, answer by [electrodrel](http://stackoverflow.com/users/558222/electrodrel) refers to the [OpenCV GitHub repository](https://github.com/Itseez/opencv/tree/master/data/haarcascades), that is a more consistent reference. – Vito Gentile Jul 09 '14 at 08:08
As the link in the previous answer seems to be dead, you can also try to download them from the OpenCV GitHub repository here

- 365
- 2
- 8
If you're using opencv from python, you can use this code snippet to use the built-in haar cascades:
import os
import cv2
cv2_base_dir = os.path.dirname(os.path.abspath(cv2.__file__))
haar_model = os.path.join(cv2_base_dir, 'data/haarcascade_frontalface_default.xml')

- 767
- 4
- 20

- 41,333
- 31
- 129
- 167
-
1
-
1@MohsenSichani i used the python code to find the cv2 route and i did indeed find them on the data folder – Mr-Programs May 27 '20 at 15:07
-
2ended up using cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') – Mr-Programs May 27 '20 at 15:35
-
https://stackoverflow.com/questions/11537585/where-can-i-find-haar-cascades-xml-files/67897482#67897482 – Jeru Luke Jun 29 '22 at 11:51
Wherever you have cloned the opencv-contrib
(if you have made it from source) follow this path afterward and in OpenCV3.1.0 I have these for Python
in Ubuntu16
:
mona@mona:~/computer_vision/face_detection/opencv_contrib/modules/face/data/cascades$ ls
haarcascade_mcs_eyepair_big.xml haarcascade_mcs_nose.xml
haarcascade_mcs_eyepair_small.xml haarcascade_mcs_rightear.xml
haarcascade_mcs_leftear.xml haarcascade_mcs_righteye_alt.xml
haarcascade_mcs_lefteye_alt.xml haarcascade_mcs_righteye.xml
haarcascade_mcs_lefteye.xml haarcascade_mcs_upperbody.xml
haarcascade_mcs_mouth.xml

- 34,860
- 64
- 239
- 408
In the official repo of openCV in the data
folder: https://github.com/opencv/opencv/tree/master/data
Remember: Not everyone uses latest version of openCV therefore you can choose the version of the library through tags in the git repo.
Cheers

- 3,696
- 3
- 33
- 46
-
1These cascades seem to be somewhat timeless: e.g. this one https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml is 5 years old as of now. – Tomasz Gandor Mar 04 '19 at 20:46
-
The xml files can be accessed directly from cv2 like so
cv2.data.haarcascades
heres a more detialed example
face_cascade_name = cv2.data.haarcascades + 'haarcascade_frontalface_alt.xml'
face_cascade = cv2.CascadeClassifier()
if not face_cascade.load(cv2.samples.findFile(face_cascade_name)):
print("Error loading xml file")
exit(0)

- 115
- 5
in the opencv 3.1 you can find
C:\opencv3\data\lbpcascades
C:\opencv3\data\haarcascades_cuda
C:\opencv3\opencv_contrib-master\modules\face\data\cascades

- 761
- 6
- 22
You don't need to go to other websites to find the cascade classifier files. you just need to go to the opencv releases site. There download the appropriate release. then open the downloaded file. In there direct as followed : sources > data > haarcascades ; In that file you should find the all default haarcascade files.

- 51
- 4
Here's the direct link to download haar-cascade-files from github link:-
https://github.com/anaustinbeing/haar-cascade-files
Just, clone or download as zip to get all the haar cascade xml files

- 136
- 4
This is how I do it with git v2.25.0, also tested with v2.26.2. This trick doesn't work with v2.30.1
TLDR
git clone --no-checkout --filter=tree:0 https://github.com/opencv/opencv
cd opencv
# requires git 2.25.x to 2.26.2
git sparse-checkout set data/haarcascades
You can use Docker to avoid installing a specific version of git
git clone --no-checkout --filter=tree:0 https://github.com/opencv/opencv
cd opencv
# requires git 2.25.x to 2.26.2
docker run --rm -it -v $PWD/:/code/ --workdir=/code/ alpine/git:v2.26.2 sparse-checkout set data/haarcascades
Full solution
# bare minimum clone of opencv
$ git clone --no-checkout --filter=tree:0 https://github.com/opencv/opencv
...
Resolving deltas: 100% (529/529), done.
# Downloaded only ~7.3MB , takes ~3 seconds
# du = disk usage, -s = summary, -h = human-readable
$ du -sh opencv
7.3M opencv/
# Set target dir
$ cd opencv
$ git sparse-checkout set data/haarcascades
...
Updating files: 100% (17/17), done.
# Takes ~10 seconds, depending on your specs
# View downloaded files
$ du -sh data/haarcascades/
9.4M data/haarcascades/
$ ls data/haarcascades/
haarcascade_eye.xml haarcascade_frontalface_alt2.xml haarcascade_licence_plate_rus_16stages.xml haarcascade_smile.xml
haarcascade_eye_tree_eyeglasses.xml haarcascade_frontalface_alt_tree.xml haarcascade_lowerbody.xml haarcascade_upperbody.xml
haarcascade_frontalcatface.xml haarcascade_frontalface_default.xml haarcascade_profileface.xml
haarcascade_frontalcatface_extended.xml haarcascade_fullbody.xml haarcascade_righteye_2splits.xml
haarcascade_frontalface_alt.xml haarcascade_lefteye_2splits.xml haarcascade_russian_plate_number.xml
References

- 2,870
- 1
- 24
- 34