-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_multicam.py
70 lines (51 loc) · 1.51 KB
/
run_multicam.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
from multiprocessing import Process
def process_viewer(camera):
"""Processes a viewer instance as a subprocess.
Parameters
----------
camera : int
An integer specifying the camera ID to be loaded.
"""
import psutil
import cv2
from utils.model_loader import ModelLoader
from utils.viewer import Viewer
mapper = {
0: 'A',
1: 'B'
}
MODEL_NAME = 'posenet_mobilenet_v1_100_257x257_multi_kpt_stripped.tflite'
MODEL_PATH = 'models/' + MODEL_NAME
VIEWER_SPECS = {
'WINDOW_NAME': 'Pose Estimation',
'MIRROR_IMAGE': True,
'POINT_COLOR': (66, 245, 156),
'LINK_COLOR': (66, 185, 245),
'THICKNESS': 1,
'THRESHOLD': 0.85
}
# Specify output file
OUT_FILE = "C:\Users\Estandarte Digital\Documents\Registros"
OUT_FILE += f'\out_{mapper[camera]}.json'
# Psutil Process (CPU affinity)
p = psutil.Process()
p.cpu_affinity([camera + 1])
# Initialize videocapture
CAPTURE = cv2.VideoCapture(camera)
# Creates model instance
model = ModelLoader(MODEL_PATH)
# Creates viewer instance and runs capture
viewer = Viewer(model, CAPTURE, VIEWER_SPECS, OUT_FILE)
viewer.run()
if __name__ == "__main__":
camera = -1
procs = 2
jobs = []
for i in range(procs):
camera += 1
process = Process(target=process_viewer, args=([camera]))
jobs.append(process)
for job in jobs:
job.start()
for job in jobs:
job.join()