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.
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.
-
thanks but this damn fortiguard blocks me for accessing that website, any other sites you know of? Jul 18, 2012 at 9:06
-
stackoverflow.com/questions/9015498/… The second comment, the download starts immediately. Did you check the opencv folder?– praxmonJul 18, 2012 at 9:08
-
Thanks, I'm looking for other objects as well such dogs, cats,etc. Basically anything found in pictures Jul 18, 2012 at 9: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.– praxmonJul 18, 2012 at 9:37
-
3The link doesn't work anymore. Moreover, answer by electrodrel refers to the OpenCV GitHub repository, that is a more consistent reference. Jul 9, 2014 at 8: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
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')
-
1
-
1@MohsenSichani i used the python code to find the cv2 route and i did indeed find them on the data folder May 27, 2020 at 15:07
-
2ended up using cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml') May 27, 2020 at 15:35
-
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
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
-
1These cascades seem to be somewhat timeless: e.g. this one raw.githubusercontent.com/opencv/opencv/master/data/… is 5 years old as of now. Mar 4, 2019 at 20:46
-
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
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.
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)
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
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