>> cv.Load('~/Desktop/data/haar...">

Download cascading haar file to OpenCV & # 8594; "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 explanation for this? This happens on OS X and Ubuntu. The same error is given for each file. It worked (I think) 2.0.

Edit- I guess it 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
+3
source share
2 answers

It looks like the file path is incorrectly resolved (e.g. ~ / ...), but its not very clear

I suggest you use the OS package to search for basepath and connect using os.path functions to get full paths

+1
source

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

0
source

Source: https://habr.com/ru/post/1776133/


All Articles