I learning opencv and I'm stuck on this error:
Traceback (most recent call last):
File "/home/nicolas/Pulpit/programowanie/python/CV/opecv.py", line 10, in <module>
faces = face_cascade.detectMultiScale(img)
error: OpenCV(4.5.5) /io/opencv/modules/objdetect/src/cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'detectMultiScale'
I tried every possible solution from here: First the gray martix isn't empty, second the paths are good and don't toss errors, but I still don't know what is wrong... And that's my code:
import cv2 as cv
img = cv2.imread('img/face.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
face_cascade = cv2.CascadeClassifier('/home/nicolas/Pulpit/programowanie/python/CV/databases/haar_face.xml')
faces = face_cascade.detectMultiScale(gray)
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('img',img)
k = cv2.waitKey(0)
if k == 27: # wait for ESC key to exit
cv2.destroyAllWindows()