i am unable to solve this plz help as soon as possible the cascade and the code is in the same file but i still get this error
hi everyone i am getting the same error what ever i do i even tried using the normal method(entering only the name) but still didnt work plz help as soon as possible, sorry for not arranged an an neat manner because i am using it first time and i dont know to use it properly
Traceback (most recent call last): File "/home/programmer/Desktop/project/face recg.py", line 11, in <module> faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5) cv2.error: OpenCV(3.4.5) /io/opencv/modules/objdetect/src/cascadedetect.cpp:1698: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'
my code is given below for face recognizer
import numpy as np
import cv2
face_cascade = cv2.CascadeClassifier('/home/programmer/Desktop/project/cascades/data/cascades/data/haarcascade_fontalface_alt2.xml')
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
for(x, y, w, h) in faces:
print(x,y,w,h)
cv2.imshow('frame',frame)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()