-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctksum.py
175 lines (143 loc) · 5.84 KB
/
ctksum.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
import random
import centroidtracker as ctk
import cv2
from trackable_object import TrackableObject
import xlsx2
from datetime import datetime
import xlsx
ct = ctk.CentroidTracker()
def count_current_person(REC, frame, count, data,
number_txt, count2, txt_class, now, data_people):
'''nowtime = now
date = nowtime.strftime("%d-%m-%Y")
H = int( nowtime.strftime("%H") )
M = int( nowtime.strftime("%M") )'''
color_rank = []
while len(color_rank) <= 2:
rank_c = random.randrange(0,255)
color_rank.append(rank_c)
color = (color_rank[0],color_rank[1],color_rank[2])
objects = ct.update(REC)
for (objectID, centroid) in objects.items():
text = "ID {}".format(objectID)
#print(text,'person')
#cv2.putText(frame, text, (centroid[0] -10, centroid[1] -10 ),cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
cv2.circle(frame, (centroid[0], centroid[1]), 4, color, -1)
if(centroid[0] > 30 and centroid[0] < 394):
if(objectID not in data):
#count += 1
data.append(objectID)
#x = len(data)
#x += 1
#xlsx2.date_time_people(x, now)
#xlsx.data_xlsx_people(x, now)
#print(now)
#del data[0]
#print(data,'person')
elif(objectID in data) :
data.pop()
elif(objectID not in data):
data.append(objectID)
elif(objectID in data):
data.pop()
'''elif(centroid[0] < 60 or centroid[0] > 356):
if(objectID in data):
data.pop()'''
count2 = objectID
def count_current_mask(REC, frame, count, data,
number_txt, count2, txt_class, now):
color_rank = []
while len(color_rank) <= 2:
rank_c = random.randrange(0,255)
color_rank.append(rank_c)
color = (color_rank[0],color_rank[1],color_rank[2])
objects = ct.update(REC)
for (objectID, centroid) in objects.items():
text = "ID {}".format(objectID)
#print(text,'mask')
#cv2.putText(frame, text, (centroid[0] -10, centroid[1] -10 ),cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
cv2.circle(frame, (centroid[0], centroid[1]), 4, color, -1)
if(centroid[0] < 30 or centroid[0] > 394):
if(objectID not in data):
#count += 1
data.append(objectID)
#x = len(data)
#x += 1
#xlsx2.date_time_mask(x, now)
#xlsx.data_xlsx_mask(x, now)
#del data[0]
#print(data,'mask')
elif(objectID in data):
data.pop()
elif(objectID not in data):
data.append(objectID)
elif(objectID in data):
data.pop()
'''elif(centroid[0] > 60 and centroid[0] < 356):
if(objectID in data):
data.pop()'''
count2 = objectID
def count_current_nomask(REC, frame, count, data,
number_txt, count2, txt_class, now):
color_rank = []
while len(color_rank) <= 2:
rank_c = random.randrange(0,255)
color_rank.append(rank_c)
color = (color_rank[0],color_rank[1],color_rank[2])
objects = ct.update(REC)
for (objectID, centroid) in objects.items():
text = "ID {}".format(objectID)
#cv2.putText(frame, text, (centroid[0] -10, centroid[1] -10 ),cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
cv2.circle(frame, (centroid[0], centroid[1]), 4, color, -1)
if(centroid[0] < 30 or centroid[0] > 394):
if(objectID not in data):
#count += 1
data.append(objectID)
#x = len(data)
#x += 1
#xlsx2.date_time_nomask(x, now)
#xlsx.data_xlsx_nomask(x, now)
#del data[0]
#print(data,txt_class)
elif(objectID in data):
data.pop()
elif(objectID not in data):
data.append(objectID)
elif(objectID in data):
data.pop()
'''elif(centroid[0] > 60 and centroid[0] < 356):
if(objectID in data):
data.pop()'''
count2 = objectID
def count_current_wrongmask(REC, frame, count, data,
number_txt, count2, txt_class, now):
color_rank = []
while len(color_rank) <= 2:
rank_c = random.randrange(0,255)
color_rank.append(rank_c)
color = (color_rank[0],color_rank[1],color_rank[2])
objects = ct.update(REC)
for (objectID, centroid) in objects.items():
text = "ID {}".format(objectID)
#cv2.putText(frame, text, (centroid[0] -10, centroid[1] -10 ),cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
cv2.circle(frame, (centroid[0], centroid[1]), 4, color, -1)
if(centroid[0] < 30 or centroid[0] > 394):
if(objectID not in data):
#count += 1
data.append(objectID)
#x = len(data)
#x += 1
#xlsx2.date_time_wrongmask(x, now)
#xlsx.data_xlsx_wrongmask(x, now)
#del data[0]
#print(data,txt_class)
elif(objuectID in data):
data.pop()
elif(objectID not in data):
data.append(objectID)
elif(objectID in data):
data.pop()
'''elif(centroid[0] < 60 and centroid[0] > 356):
if(objectID in data):
data.pop()'''
count2 = objectID