There is something wrong happening in xml file

I downloaded the xml file but when putting it in cv2.CascadeClassifier(“abc.xml”)–> it shows error nd doesn’t open …I even tried opening xml file it doesn’t open either…also i have already tried taking from the original github location.

Hello @nikhil_sarda,

You are not supposed to open the xml file. If you let us know the error, then only we will be able to solve your issue. Make sure you download the xml file in the correct way.
Continue here in this thread with the error as well as the way you downloaded the XML.

Thanks

I tried downloading from -

  1. github repository of codingblocks
  2. the original repository of haarcascade

Now when i kept in the folder where I am opening the jupyter notebook , when i typed
“face_cascade=cv2.CascadeClassifier(“haarcascade_frontalface_alt (1).xml”)”

it gave error -

"error Traceback (most recent call last)
error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\core\src\persistence.cpp:719: error: (-49:Unknown error code -49) Input file is invalid in function ‘cv::FileStorage::Impl::open’

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

SystemError Traceback (most recent call last)
in
2 cap=cv2.VideoCapture(0)
3 #print(face_cascade.load(“haarcascade_frontalface_alt.xml”))
----> 4 face_cascade=cv2.CascadeClassifier(“c:\Codingblocks\haarcascade_frontalface_alt (1).xml”)
5 #cv2.data.haarcascades(“haarcascade_frontalface_alt (1).xml”)
6 while True:

SystemError: <class ‘cv2.CascadeClassifier’> returned a result with an error set"

(The error ends)

Now i was trying different stuffs and then it gave error in the other command:

Command : faces=face_cascade.detectMultiScale(frame)

Error:

"error Traceback (most recent call last)
in
8 if(ret==False):
9 continue
—> 10 faces=face_cascade.detectMultiScale(frame)
11 cv2.imshow(‘Video’,frame)
12 for (x,y,w,h) in faces:

error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function ‘cv::CascadeClassifier::detectMultiScale’ "

Please help me fix this…as I have spent like almost two days on it without any clue from internet.