I have followed a tutorial to draw rectangle around the face i track. I already write the code same as the tutorial. But when i ran it, it just show the video from the webcam and there is no rectangle drawn around the face. I have no idea why it is happen.
This is my code,
import cv2
import numpy as np
a = cv2.CascadeClassifier('haarcascade_frontalface_default.xml');
cam = cv2.VideoCapture(0);
while(True):
ret,img=cam.read();
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces = a.detectMultiScale(gray,1.3,5)
for(x,y,w,h) in faces :
cv2.rectangle(img, (x,y), (x+w,y+h), (0,0,255), 2)
cv2.imshow("Face", img);
if(cv2.waitKey(1) == ord('q')):
break;
cam.release()
cv2.destroyAllWindows()
This is my directory with the haarcascade