-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_oop.py
137 lines (109 loc) · 3.5 KB
/
test_oop.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
from yolov7_sort_count_oop import YoloSortCount
#################### TEST ####################
# INSTANCIATE
test = YoloSortCount()
"""
###### AVAILABLE SOURCES ######
WebCamera: 0 ---> DEFAULT
Youtube Video or stream: "https://www.youtube.com/watch?v=qP1y7Tdab7Y"
Stream URL: "http://IP/hls/stream_src.m3u8"
RSTP Stream: "http://192.168.1.3:4747/video"
Local video: "img_bank/cows_for_sale.mp4"
Local image: "img_bank/img.jpg" | "img_bank/img.png"
"""
test.video_path = 0#"https://www.youtube.com/watch?v=2wqpy036z24"
"""
###### FRAME PROPERTIES ######
- Set the max size of the frame (width)
- Set the max fps of the video
- Invert the image (In case of your WebCamera is mirrored, IE)
"""
test.max_width = 720
test.max_fps = 25 # Max 1000
test.inv_h_frame = True
"""
###### SHOWING RESULTS ######
- Show the results in your display (Interactive ROI, imshow of the out frame)
- In case of you are not showing the results, set the timer to stop the execution.
- Stop the frame with hold_image method in case you are using image as a source.
"""
test.show_img = True
test.ends_in_sec = 10
test.hold_img = False
"""
###### ROI ######
- Load the ROI manually.
-
- Load the ROI color.
"""
#test.roi = [0,0,0,0]
test.auto_load_roi = True
test.roi_color = (255, 255, 255)
"""
###### DETECTION MODEL ######
- Specify the path of the model.
- Select the ID of your Graphic Card (nvidia-smi)
- Select the classes to detect
- Set the image size (Check if the YOLO model allows that --> IE: yolov7.pt 640, yolov7-w6.pt 1280 or 640)
- Set the bounding box color
- Set the minimum confidence to detect.
- Set the minimum overlap of a predicted versus actual bounding box for an object.
"""
test.model_path = 'pretrained_weights/yolov7.pt'
test.graphic_card = 0
test.class_ids = [0]
test.img_sz = 640
test.color = (0, 255, 0)
test.conf_thres = 0.5
test.iou_thres = 0.65
"""
###### TRACKING MODEL ######
- Specify the path of the model.
- Set the max distance between two points to consider a tracking object.
- Set the max overlap of a predicted versus actual bounding box for an object.
- Set the image size (Check if the YOLO model allows that --> IE: yolov7.pt 640, yolov7-w6.pt 1280 or 640)
- Set max_age to consider a lost of a tracking object that get out of the seen area.
- Set the minimum frames to start to track objects.
- Set the value that indicates how many previous frames of feature vectors should be retained for distance calculation for each track.
- Set the color of the centroid and label of a tracking object.
"""
test.deep_sort_model = "osnet_x1_0"
test.ds_max_dist = 0.1
test.ds_max_iou_distance = 0.7
test.ds_max_age = 30
test.ds_n_init = 3
test.ds_nn_budget = 100
test.ds_color = (0, 0, 255)
"""
###### PLOT RESULTS ######
- Specify the min x (left to right) to plot the draws
- Specify the min y (top to bottom) to plot the draws
- Specify padding between rectangles and text
- Specify the text color.
- Specify the rectangles color.
"""
test.plot_xmin = 10
test.plot_ymin = 10
test.plot_padding = 2
test.plot_text_color = (255, 255, 255)
test.plot_bgr_color = (0, 0, 0)
"""
###### DEBUG TEXT ######
- Show the configs
- Show the detection output variables
- Show the tracking output variables
- Show counting output variables
"""
test.show_configs = False
test.show_detection = False
test.show_tracking = False
test.show_count = False
"""
###### SAVING RESULTS ######
- Select if you want to save the results
- Select a location to save the results
"""
test.save_vid = False
test.save_loc = "results/result"
# Run
test.run()