"""
Created on Fri Oct 1 23:17:07 2021
@author: 23608
"""
import numpy as np
import cv2
cap = cv2.VideoCapture(1)
face_cascade = cv2.CascadeClassifier('C:/Program Files/Python38/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml')
while 1:
bool_value, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(frame)
for (x,y,w,h) in faces:
cv2.rectangle(frame, (x,y), (x + w, y + h), (0, 255, 0), 2)
cv2.putText(frame, "face", (x, y), 3, 1.2, (255, 0, 0))
cv2.imshow("frame", frame)
if cv2.waitKey(30) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
|