-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_cam.py
39 lines (31 loc) · 1.03 KB
/
test_cam.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
import time
import cv2
from detector.cv_face_detector.model import CVFaceDetector
from models.m1.model import M1FaceAntiSpoofing
from models.m2.model import M2FaceAntiSpoofing
from models.m3.model import M3FaceAntiSpoofing
from models.m4.model import M4FaceAntiSpoofing
from models.m5.model import M5FaceAntiSpoofing
import os
face_detector = CVFaceDetector()
spoof_detector = M5FaceAntiSpoofing()
skip_frame = 3
cap = cv2.VideoCapture("rtsp://admin:admin@123@192.168.2.111:554")
count = 0
while True:
ret, bgr = cap.read()
if not ret:
break
count += 1
if count % skip_frame != 0:
continue
face_bboxes = face_detector.get_face_bboxes(bgr)
for bbox in face_bboxes:
real_score = spoof_detector.get_real_score(bgr, bbox)
print(real_score)
if real_score > 0.5:
cv2.rectangle(bgr, (bbox[0], bbox[1]), (bbox[2], bbox[3]), (0,255,0))
else:
cv2.rectangle(bgr, (bbox[0], bbox[1]), (bbox[2], bbox[3]), (0, 0, 255))
cv2.imshow("test", bgr)
cv2.waitKey(1)