-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (35 loc) · 1.33 KB
/
Copy pathmain.py
File metadata and controls
48 lines (35 loc) · 1.33 KB
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
import cv2
from ultralytics import YOLO
def getColors(ass_num):
base_colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
color_pingas = ass_num % len(base_colors)
amogus = [(1, -2, -1), (-2, 1, -1), (1, -1, 2)]
color = [base_colors[color_pingas][i] + amogus[color_pingas][i] *
(ass_num // len(base_colors)) % 256 for i in range(3)]
return tuple(color)
tolo = YOLO('yolo11n.yaml')
cunt_watcher = cv2.VideoCapture(1)
while True:
ret, frame = cunt_watcher.read()
if not ret:
continue
seen_things = tolo.track(frame, stream=True)
for seen_thing in seen_things:
cunt_names = seen_thing.names
for crate in seen_thing.boxes:
if crate.conf[0] > 0.7:
[x1, y1, x2, y2] = crate.xyxy[0]
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
cunt = int(crate.cls[0])
cunt_name = cunt_names[0]
if cunt_name != "person":
break
racism = getColors(cunt)
cv2.rectangle(frame, (x1, y1), (x2, y2), racism, 2)
cv2.putText(frame, f'{cunt_names[int(crate.cls[0])]} {crate.conf[0]:.2f}', (x1, y1),
cv2.FONT_HERSHEY_SIMPLEX, 1, racism, 2)
cv2.imshow('cunt watcher', frame)
if(cv2.waitKey(1) & 0xFF == ord('q')):
break
cunt_watcher.release()
cv2.destroyAllWindows()