Ask Your Question
1

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

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

hobibey gravatar image

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

2 answers

Sort by ยป oldest newest most voted
1

answered 2018-05-14 05:42:44 -0600

berak gravatar image

updated 2018-05-14 06:04:51 -0600

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.

edit flag offensive delete link more
1

answered 2020-04-18 00:44:21 -0600

pcvolokh gravatar image

You downloaded the html version of the xml file, not the actual raw version of the file, which is found here: [https://raw.githubusercontent.com/ope...]

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-05-14 05:16:44 -0600

Seen: 4,412 times

Last updated: May 14 '18