import cv2 as cv
img=cv.imread('photo/goku3.jpg')
cv.imshow('image', img)
gray=cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('gray', gray)
haar_cascade=cv.CascadeClassifier('faces.xml')
faces_rect=haar_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbours=3)
print(f"Number of faces found = {len(faces_rect)}")
for (x,y,w,h) in faces_rect:
cv.rectangle(img, (x,y), (x+w,y+h), (0,255,0), thickness=2)
cv.imshow('detected face', img)
cv.waitKey(0)
Traceback (most recent call last):
File "e:\imageRecognitionProj\faceDetect.py", line 9, in <module>
faces_rect=haar_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbours=3)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'detectMultiScale'
> Overload resolution failed:
> - 'minNeighbours' is an invalid keyword argument for CascadeClassifier.detectMultiScale()
> - 'minNeighbours' is an invalid keyword argument for CascadeClassifier.detectMultiScale()
inside the haar_cascade variable i have defined the cascadeClassifier() with the xml file
I think the function detectMultiScale() is not available. I tried to reinstall open-cv but it didn't worked.