1

I am try to get face detection working on using a python script and OpenCV but I keep getting this error:

Traceback (most recent call last)
    File "face_detect.py", line 19, in <module>
        cascade = cv.Load(options, cascade)
TypeError: OpenCV returned NULL

The code I used is here: https://github.com/mitchtech/py_servo_facetracker

I don know what is causing this error or how to fix it. Thanks in advance.

3 Answers 3

1

if you put on your goggles ;)

you'll see, that it's not

cascade = cv.Load(options, cascade)

in the original code, but :

cascade = cv.Load(options.cascade)

( and a remark: the old cv api got removed in newer opencv versions, you probably should avoid it in favour of cv2 )

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same issue. For me, the relative-path of the haarcascade was incorrect. It thought the data folder was one level up, instead it was two.

My changes

Original:
parser.add_option("-c", "--cascade", action="store", dest="cascade", type="str", help="Haar cascade file, default %default", default = "../data/haarcascades/haarcascade_frontalface_alt.xml")

Modified:
parser.add_option("-c", "--cascade", action="store", dest="cascade", type="str", help="Haar cascade file, default %default", default = "../../data/haarcascades/haarcascade_frontalface_alt.xml")

Comments

0

I met the same issue, and it seems like the file path of haarcascade_frontalface_alt.xml is not correct.

You should download haarcascade_frontalface_alt.xml to your computer from http://eclecti.cc/files/2008/03/haarcascade_frontalface_alt.xml.

So I fixed it by changing the file path of haarcascade_frontalface_alt.xml. Hope it will help!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.