-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmouth_detect_dot_RGB.py
More file actions
41 lines (33 loc) · 1 KB
/
Copy pathmouth_detect_dot_RGB.py
File metadata and controls
41 lines (33 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import dlib
import cv2
# 追記か
"""
# dlibで学習したモデルを読み込む
detector = dlib.simple_object_detector("droid_detector.svm")
"""
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")
cap = cv2.VideoCapture(0)
# fps調整
cap.set(5, 60)
while True:
ret, frame = cap.read()
#cv2.imshow("me", frame) # 確認用
# ここに処理を追加していく ----
dets = detector(frame[:, :, ::-1])
if len(dets):
parts = predictor(frame, dets[0]).parts()
parts = parts[48:68] #口認識は48~67
# RGB化
img = frame #* 0
for i in parts:
cv2.circle(img, (i.x, i.y), 3, (255, 0, 0), -1)
#for det in dets:
# cv2.rectangle(img, (det.left(), det.top()), (det.right(), det.bottom()), (0, 0, 255))
cv2.imshow("me", img)
# 確認用 ここまで ---
# ここまで ----
if cv2.waitKey(1) == 27:
break
cap.release()
cv2.destroyAllWindows()