Created
August 18, 2017 12:37
-
-
Save ysenutam912/4cf3c476f23b73b74bcf0ee42ec0024f to your computer and use it in GitHub Desktop.
Python + OpenCv + Dlib で顔検出
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 numpy as np | |
import dlib | |
import cv2 | |
if __name__ == '__main__': | |
detector = dlib.get_frontal_face_detector() | |
cap = cv2.VideoCapture(0) | |
cap.set(5, 30) # set FPS | |
while(True): | |
ret, img = cap.read() | |
img = cv2.resize(img, (320, 180)) | |
dets = detector(img, 1) | |
for det in dets: | |
cv2.rectangle(img, (det.left(), det.top()), (det.right(), det.bottom()), (0, 0, 255)) | |
cv2.imshow('img', img) | |
key = cv2.waitKey(1) | |
if key == ord('q'): | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment