Skip to content

Commit

Permalink
Merge pull request #139 from PavanTeja2005/facedet
Browse files Browse the repository at this point in the history
Added Face detector to the assisstant
  • Loading branch information
suryanshsk authored Oct 11, 2024
2 parents 3463bcc + c62597d commit f34870c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions face_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import cv2

def detect_faces(image_path):
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
image = cv2.imread(image_path)
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray_image, scaleFactor=1.1, minNeighbors=5)

for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x + w, y + h), (255, 0, 0), 2)

cv2.imshow('Detected Faces', image)
cv2.waitKey(0)
cv2.destroyAllWindows()

if __name__ == "__main__":
detect_faces('path_to_your_image.jpg')

0 comments on commit f34870c

Please sign in to comment.