-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
44 lines (32 loc) · 1.12 KB
/
demo.py
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
42
43
44
import torch
from face_detector import *
from face_landmark import *
def camera_run():
face_detector_handle = FaceDetector()
face_landmark_handle = FaceLandmark()
cap = cv2.VideoCapture(0)
while True:
ret, image = cap.read()
if image is None:
continue
detections, _ = face_detector_handle.run(image)
if len(detections) == 0:
continue
for detection in detections:
landmarks, states = face_landmark_handle.run(image, detection)
if landmarks is None:
continue
face_landmark_handle.show_result(image, landmarks)
def image_run():
face_detector_handle = FaceDetector()
face_landmark_handle = FaceLandmark()
image = cv2.imread('data/1.jpg')
detections, _ = face_detector_handle.run(image)
face_detector_handle.show_result(image, detections)
if len(detections) == 0:
return
for detection in detections:
landmarks, states = face_landmark_handle.run(image, detection)
face_landmark_handle.show_result(image, landmarks)
if __name__ == '__main__':
image_run()