-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbright dark webcam.py
97 lines (44 loc) · 1.67 KB
/
bright dark webcam.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
import os
import glob
import cv2
import numpy as np
import cvzone
import matplotlib.pyplot as plt
from cvzone.FaceMeshModule import FaceMeshDetector
cap = cv2.VideoCapture(0)
detector= FaceMeshDetector(maxFaces=1)
while(True):
ret, frame = cap.read()
frame = cv2.resize(frame, (640, 360))
frame,faces= detector.findFaceMesh(frame)
thresh=0.5
frame= frame/np.max(frame)
def isbrightF():
if np.mean(frame) > thresh:
cvzone.putTextRect(frame, 'bright', (50, 150), scale=1.5,
colorR=(255, 0, 255))
color=(0,128,0)
stroke=2
start_point = (10, 10)
end_point = (630, 350)
cv2.rectangle(frame,start_point,end_point,color,stroke)
else:
cvzone.putTextRect(frame, 'dark', (50, 150), scale=1.5,
colorR=(255, 0, 255))
cvzone.putTextRect(frame, 'increase the intensity of light', (50, 250), scale=1.5,
colorR=(255, 0, 255))
color=(255,69,0)
stroke=2
start_point = (10, 10)
end_point = (630, 350)
cv2.rectangle(frame,start_point,end_point,color,stroke)
isbrightF()
cv2.imshow('frame',frame)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
# In[ ]: