-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (40 loc) · 1.21 KB
/
main.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
from multiprocessing import JoinableQueue, Process
from rtsp_processor.stream.process import process_job
from rtsp_processor.stream.stream import stream_job
import yaml
from argparse import ArgumentParser
import os
import sys
sys.path.append(os.getcwd())
def parse_args():
parser = ArgumentParser()
parser.add_argument(
"-b",
"--backend",
type=str,
default="opencv",
choices=["opencv", "ffmpeg"],
help="Backend to be used for streaming",
)
parser.add_argument(
"-c",
"--config-path",
type=str,
default="./config.yaml",
help="Path for the config file",
)
args = parser.parse_args()
return args
if __name__ == "__main__":
args = parse_args()
root = os.path.split(__file__)[0]
config_path = os.path.abspath(os.path.join(root, args.config_path))
with open(config_path) as handler:
config = yaml.load(handler, yaml.FullLoader)
image_queue = JoinableQueue()
producer = Process(target=process_job, args=(image_queue, config))
consumer = Process(target=stream_job, args=(image_queue, config, args.backend))
producer.start()
consumer.start()
producer.join()
consumer.join()