Last active
February 17, 2020 14:11
-
-
Save WittmannF/5e992ae67b5f8e37f3d512cf59c5d659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2, os | |
BLUE_COLOR = (255, 0, 0) | |
STROKE = 2 | |
xml_path = 'haarcascade_frontalface_alt2.xml' | |
clf = cv2.CascadeClassifier(xml_path) | |
cap = cv2.VideoCapture(0) | |
while(not cv2.waitKey(20) & 0xFF == ord('q')): | |
ret, frame = cap.read() | |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
faces = clf.detectMultiScale(gray) | |
for x, y, w, h in faces: | |
cv2.rectangle(frame, (x, y), (x+w, y+h), BLUE_COLOR, STROKE) | |
cv2.imshow('frame',frame) | |
cap.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment