OpenCV Error: Unknown error code -49 (persistence.cpp error=

asked 2018-05-14 05:16:44 -0500

Hi,

i tried use opencv and detect face, but this pyhton code given to this cascade error: i was downloaded cascades files from this link.

https://github.com/opencv/opencv/tree...

where i was wrong? thanks.

import cv2 as cv
face_cascade = cv.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv.CascadeClassifier('haarcascade_eye.xml')
img = cv.imread('X.JPG')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

OpenCV Error: Unknown error code -49 (Input file is empty) in cvOpenFileStorage, file C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp, line 4484 cv2.error: C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp:4484: error: (-49) Input file is empty in function cvOpenFileStorage

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:/opencv/x.py", line 3, in <module> face_cascade = cv.CascadeClassifier('haarcascade_frontalface_default.xml') SystemError: <class 'cv2.cascadeclassifier'=""> returned a result with an error set

edit retag flag offensive close merge delete

Comments

have a look at those cascade files (e.g. with a text editor). do they really contain valid xml ?

(download errors do happen, there might just be a html errormsg in there, not valid xml)

also, when using weird python ide's like pycharm, do yourself a favour, and use an absolute file path for anything, that needs to be loaded from disk.

berak gravatar imageberak ( 2018-05-14 05:42:44 -0500 )edit