better haarcascades xml face for download code example

Example: where should the haarcascades should be stored\

import cv2import numpy as npface_classifier = cv2.CascadeClassifier('/haarcascade_frontalface_default.xml')gray = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY)''' Our classifier returns the ROI of the detected face as a tuple, It stores the top left coordinate and the bottom right coordiantes'''faces = face_classifier.detectMultiScale(gray, 1.0485258, 6)'''When no faces detected, face_classifier returns and empty tuple'''if faces is ():    print("No faces found")'''We iterate through our faces array and draw a rectangle over each face in faces'''for (x,y,w,h) in faces:    cv2.rectangle(resized, (x,y), (x+w,y+h), (127,0,255), 2)    cv2.imshow('Face Detection', resized)    cv2.waitKey(0)    cv2.destroyAllWindows()

Tags:

Misc Example