Rob Lourens
Rob Lourens

Reputation: 16099

Loading haar cascade file in OpenCV -> "OpenCV returned NULL"

OpenCV 2.1 with Python 2.6 bindings:

>>> cv.Load('~/Desktop/data/haarcascades/haarcascade_eye.xml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: OpenCV returned NULL

Any explanations for this? This happens on OS X and Ubuntu. The same error is given for every file. It worked in (I think) 2.0.

Edit- I guess it only breaks sometimes.

>>> cv.Load('/Users/rob/Downloads/OpenCV-2.1.0/data/haarcascades/haarcascade_frontalface_alt.xml')
<HaarClassifierCascade 0x1003a3a40>
>>> cv.Load('/opt/local/var/macports/software/opencv/2.1.0_0/opt/local/share/opencv/haarcascade_frontalface_alt.xml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: OpenCV returned NULL

Upvotes: 3

Views: 5308

Answers (2)

Yousef Golnahali
Yousef Golnahali

Reputation: 55

Replace cv.Load() with cv.CascadeClassifier() and try

Upvotes: 0

Neon22
Neon22

Reputation: 630

Looks like the filepath is not resolving properly (e.g. ~/...) but its not really clear

suggest you use OS package to find basepath and join using os.path functions to get full pathnames

Upvotes: 1

Related Questions