I am learning OpenCV through Python v3.8.5 since last few days, got stuck in CascadeClassifier on Facedetection. Following the same code as the tutor : https://www.youtube.com/watch?v=LopYA64KmdE Timestamp: 08:40
I have the image and haarcascade_frontalface_default.xml files in the resources folder
Still, I don't get any output for this below code. I tried changing images files too but still no output. When I tried printing it print till 'foo1'. So I suspect the issue is around detectMultiScale() method.
Here is my code:
import cv2
face_cascade = cv2.CascadeClassifier('resources\haarcascade_frontalface_default.xml')
# img = cv2.imread('resources\\lena.jpg')
# img = cv2.imread('D:\photos\house\DSCF2736 copy.jpg')
img = cv2.imread('resources\\messi5.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
print('foo1')
faces = face_cascade.detectMultiScale(gray,1.1,4)
print('foo2')
for (x,y,w,h) in faces:
cv2.rectangle(img,(x,y),(x+h,y+w),(0,255,0),2)
cv2.imshow('out',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
I am using Windows7 32 bit PC. Is this due to OS support issue? Please let me know the solution.
Thanks