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
/
Copy pathmain_camera.py
51 lines (42 loc) · 1.66 KB
/
main_camera.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
#!/usr/bin/env python3
import warnings
from algorithm.algorithm import Algorithm
from algorithm.counter.area_strategy import AreaCountingStrategy
from algorithm.counter.gate import GateWriterLayer, ScsGang
from algorithm.object_counter import ObjectCounter, ObjectCounterWriterLayer
from algorithm.object_detector import ObjectDetector
from algorithm.object_labeler import ObjectLabelerWriterLayer, ObjectNoLabel
from algorithm.object_tracker import ObjectTracker
from algorithm.readers import CameraReader
from algorithm.utils import PrintCounter
from algorithm.writers import VideoWriter
from env import get_output_path
from logger import set_file_logger
# Remove tensorflow warnings
warnings.filterwarnings('ignore')
def run_camera(filename, strategy):
tag = 'tiny'
output_path = get_output_path('camera-{}-{}-{}'.format(filename, tag, strategy.name))
set_file_logger('{}.log'.format(output_path))
algo = Algorithm(
output_path=output_path,
reader=CameraReader(),
pipeline=[
# ScaleFrame(scale=0.5),
ObjectNoLabel(),
ObjectDetector(score=0.25, tiny=True),
ObjectTracker(max_age=10),
ObjectCounter(strategy=strategy),
PrintCounter(),
VideoWriter(filename='{}+counting'.format(output_path),
layers=[
GateWriterLayer(strategy.gate_region),
ObjectCounterWriterLayer(),
ObjectLabelerWriterLayer()
])
]
)
algo.run()
if __name__ == "__main__":
strategy = AreaCountingStrategy(ScsGang)
run_camera('scs-gang', strategy)