This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_tracking.py
83 lines (68 loc) · 2.43 KB
/
main_tracking.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
#!/usr/bin/env python3
import traceback
import warnings
from algorithm.algorithm import Algorithm
from algorithm.object_detector import ObjectDetector, ObjectDetectorWriterLayer, DataSet
from algorithm.object_labeler import ObjectLabeler, ObjectLabelerWriterLayer
from algorithm.object_tracker import ObjectTracker, ObjectTrackerWriterLayer
from algorithm.pickle import PickleWriter
from algorithm.readers import VideoReader
from algorithm.writers import VideoWriter
from env import get_output_path, get_video_input_path, get_label_input_path, get_pickle_path
from logger import set_file_logger
# Remove tensorflow warnings
warnings.filterwarnings('ignore')
def run_tracking_algo(filename, fps):
tag = 'tiny'
output_path = get_output_path('algo-{}-{}fps-{}'.format(filename, fps, tag))
set_file_logger('{}.log'.format(output_path))
algo = Algorithm(
output_path=output_path,
reader=VideoReader(get_video_input_path(filename), fps),
pipeline=[
ObjectLabeler(get_label_input_path(filename)),
ObjectDetector(score=0.25, dataset=DataSet.tiny),
ObjectTracker(max_age=10),
PickleWriter(pickle_path=get_pickle_path(filename, fps, tag=tag)),
VideoWriter(filename='{}+detection+tracking+label'.format(output_path),
layers=[
ObjectDetectorWriterLayer(),
ObjectTrackerWriterLayer(),
ObjectLabelerWriterLayer()
])
]
)
algo.run()
def run_all():
filenames = [
# '041_gate1-480x270',
# '041_gate1-960x540',
# '041_gate1-1920x1080',
# '041_stairs-480x270',
# '041_stairs-960x540',
'041_stairs-1920x1080',
# '041_gate2-1920x1080',
# '041_hallway-1920x1080',
]
fps = [
# 1,
# 3,
# 5,
# 10,
15,
30
]
errors = []
for filename in filenames:
for f in fps:
try:
run_tracking_algo(filename, f)
except Exception as ex:
traceback.print_exc()
errors.append((filename, f, ex))
print('Found {} errors:'.format(len(errors)))
for filename, f, ex in errors:
print('\t- {} at {}fps with {}'.format(filename, f, ex.__class__.__name__))
if __name__ == "__main__":
# run_tracking_algo('041_gate2-1920x1080', 15)
run_all()