-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtest_cam.py
56 lines (44 loc) · 1.7 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import cv2
import numpy as np
from mtcnn.mtcnn import MTCNN
detector = MTCNN()
filename = "video/video10.mp4"
# cv2.namedWindow('Attendence_Tracker', cv2.WINDOW_NORMAL)
# cap = cv2.VideoCapture(filename)
# # cap = cv2.VideoCapture(0)
# while True:
# #Capture frame-by-frame
# __, frame = cap.read()
# #Use MTCNN to detect faces
# result = detector.detect_faces(frame)
# if result != []:
# for person in result:
# bounding_box = person['box']
# keypoints = person['keypoints']
# cv2.rectangle(frame,
# (bounding_box[0], bounding_box[1]),
# (bounding_box[0]+bounding_box[2], bounding_box[1] + bounding_box[3]),
# (0,155,255),
# 2)
# cv2.circle(frame,(keypoints['left_eye']), 2, (0,155,255), 2)
# cv2.circle(frame,(keypoints['right_eye']), 2, (0,155,255), 2)
# cv2.circle(frame,(keypoints['nose']), 2, (0,155,255), 2)
# cv2.circle(frame,(keypoints['mouth_left']), 2, (0,155,255), 2)
# cv2.circle(frame,(keypoints['mouth_right']), 2, (0,155,255), 2)
# #display resulting frame
# cv2.imshow('Attendence_Tracker',frame)
# if cv2.waitKey(1) &0xFF == ord('q'):
# break
# #When everything's done, release capture
# cap.release()
# cv2.destroyAllWindows()
img = "align/3.jpg"
def adjust_gamma(image, gamma=1.5):
invGamma = 1.0 / gamma
table = np.array([((i / 255.0) ** invGamma) * 255
for i in np.arange(0, 256)]).astype("uint8")
return cv2.LUT(image, table)
image = cv2.imread(img)
img = adjust_gamma(image)
result = detector.detect_faces(image)
print(result)