Count Number of Faces Using Python - OpenCV
Count Number of Faces Using Python - OpenCV
Count Number of Faces Using Python - OpenCV
Python – OpenCV
# Capture frame-by-frame
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
import numpy as np
import dlib
detector = dlib.get_frontal_face_detector()
# Capture frame-by-frame
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
# RGB to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = detector(gray)
x, y = face.left(), face.top()
x1, y1 = face.right(), face.bottom()
cv2.rectangle(frame, (x, y), (x1, y1), (0, 255, 0), 2)
break
Output: