0

I am facing an error - File "", line 159, in main()

File "", line 155, in main face.detect_face() 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

the code is

def detect_face(self): face_cascade = cv2.CascadeClassifier(self.CASE_PATH)

    video_capture = cv2.VideoCapture(0)
    # infinite loop, break by key ESC
    while True:
        if not video_capture.isOpened():
            sleep(5)
        # Capture frame-by-frame
        ret, frame = video_capture.read()
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        faces = face_cascade.detectMultiScale(
            gray,
            scaleFactor=1.2,
            minNeighbors=10,
            minSize=(self.face_size, self.face_size)
        )

or the full code is here

after searching so many answers I think this is an issue of OpenCV version or the haarcascade_frontalface_alt.xml file is not loaded. but I am not find any solution. please help me.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Ashutosh
  • 27
  • 1
  • 7

0 Answers0