abidrahmank/OpenCV2-Python-Tutorials

Loading Haar Cascade data for Face Detection tutorial

bnlcas opened this issue · 0 comments

The tutorial for Face Detection with Haar Cascades is a really helpful resource. Unfortunately on some installations of opencv the xml file for the trained haar model is not properly linked. A call of cv2.data.haarcascades should resolve this issue for people.

I would like to propose the following change:
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
to:
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')

I would be happy to submit a pull request to switch this if there are no issues here.