Skip to content

Commit c77a10d

Browse files
Merge pull request #40 from abhiramasonny/updates
updates to cloth and main
2 parents fbbfa0d + 0092612 commit c77a10d

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

main.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def main(tryall=True):
88
gun_detection = GunDetection(weight_path_gun, config_path_gun)
99

1010
if not tryall:
11-
cam1 = cv2.VideoCapture(0)
11+
cam1 = cv2.VideoCapture(1)
1212
#cam2 = cv2.VideoCapture(1)
1313
cameras = [
1414
(cam1, "Zone 1")#, (cam2, 'Zone 2')
@@ -37,7 +37,23 @@ def main(tryall=True):
3737
clothes_detection = ClothesDetection(len(cameras))
3838
wearing,colour = clothes_detection.run_detection(cameras)
3939
print(f"wearing {wearing} and RGB {colour}")
40+
while True:
41+
for i in gun_detection.run_detection(cameras):
42+
#print(f'{i}')
43+
print(type(i))
44+
if type(i) == dict:
45+
if 1 in list(i.values()):
46+
for key, value in i.items():
47+
if value == 1:
48+
print(f'Gunman in {key}')
49+
#sendP(key[-1])
50+
else:
51+
print('No Gunman found')
52+
53+
#sendP(i)
54+
#if type(i) != int:
55+
# break
4056

4157
if __name__ == "__main__":
42-
main()
58+
main(tryall=False)
4359

-530 Bytes
Binary file not shown.

src/yolov3/detection.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -166,24 +166,4 @@ def get_avg_rgb(self, box_array: list, frame: np.ndarray) -> list:
166166
return avg_rgb_values
167167
def colour_from_RGB(avg_rgb_values):
168168
pass
169-
170-
def get_color_category(self, avg_rgb_values: list) -> str:
171-
color_thresholds = {
172-
'Red': (150, 30, 30),
173-
'White': (220, 220, 220),
174-
'Black': (30, 30, 30),
175-
'Blue': (30, 30, 150),
176-
'Green': (30, 150, 30)
177-
}
178-
179-
min_distance = float('inf')
180-
color_category = None
181-
182-
for category, threshold in color_thresholds.items():
183-
distance = np.linalg.norm(np.array(avg_rgb_values) - np.array(threshold))
184-
if distance < min_distance:
185-
min_distance = distance
186-
color_category = category
187-
188-
return color_category
189169

0 commit comments

Comments
 (0)