gigafide / simple_opencv_pi_face_detector

This is a simple Raspberry Pi OpenCV face detector
30 stars 24 forks source link

HAAR_SCALE_IMAGE not working #1

Closed melvin2204 closed 6 years ago

melvin2204 commented 6 years ago

Error: flags=cv2.cv.CV_HAAR_SCALE_IMAGE AttributeError: 'module' object has no attribute 'cv'

Windows 10 Python 3.4 CV 3.4.0

AnthyG commented 6 years ago

Removing that erroneous line fixed it for me, and it still works!

Markb1337 commented 6 years ago

The legacy 'cv' submodule has been removed from OpenCV 3+. Also the name of the "CV_HAAR_SCALE_IMAGE" has been altered, along with some other things.

To fix the issue, change the following line: flags=cv2.cv.CV_HAAR_SCALE_IMAGE

With this line: flags=cv2.CASCADE_SCALE_IMAGE

That should fix the issue you're having. Also, I noticed that the code refers to the cascade file as "haarcascade.xml" even tough the name is "haarcascade_.xml" in the repository (notice the underscore). Add the underscore in your code, or change the filename to fix this as well.

Tarasus commented 6 years ago

I had to change "haarcascade.xml"to full path to it, like /home/username/simple_opencv_pi_face_detector/haarcascade.xml