Advertisement
slik1977

Faces_web_camera_recognition 1.0

Feb 11th, 2022
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. import cv2
  2.  
  3. face_cascade_db = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
  4. cap = cv2.VideoCapture(0)
  5.  
  6. while True:
  7.     success, img = cap.read()
  8.     img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  9.  
  10.     faces = face_cascade_db.detectMultiScale(img_gray, 1.1, 19)
  11.     for (x,y,w,h) in faces:
  12.         cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0),2)
  13.  
  14.     cv2.imshow('result', img)
  15.     if cv2.waitKey(1) & 0xff == ord('q'):
  16.         break
  17.  
  18. cap.release()
  19. cv2.destroyAllWindows()
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement