0

So this is the code :

`
from cv2 import COLOR_BGR2GRAY, imshow
import pyautogui as py
import cv2
detector = cv2.CascadeClassifier(r'C:\\Desktop\\New Folder\\hace.xml')
cap = cv2.VideoCapture(0)
while True:
    
    ret, frame = cap.read()
    cv2.imshow('image', frame)
    gray = cv2.cvtColor(frame, COLOR_BGR2GRAY)
    pos2 = detector.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5,)
    cv2.rectangle(pos2)
    if cv2.waitKey(1) & 0xFF == ord('q'):

        break`

Whenever i run this, it shows me this error message: line 11, in <module> pos2 = detector.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5,) cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale

and then terminates the terminal, and I cannot figure out why. I am just starting with python, so I won't be very good.

Red Dog324
  • 49
  • 2

0 Answers0