forked from luxonis/depthai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibrate_and_test.py
executable file
·48 lines (36 loc) · 1.1 KB
/
calibrate_and_test.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
#!/usr/bin/env python3
# Calibration script is not yet migrated to Gen2
raise NotImplementedError("Calibration is not yet available in Gen2 demo. To calibrate your device, switch to \"gen1_main\" branch and try again")
import os
import signal
import subprocess
import atexit
import sys
import time
global p
global return_code
p=None
def cleanup():
if(p is not None):
print('Stopping subprocess with pid: ', str(p.pid))
os.killpg(os.getpgid(p.pid), signal.SIGTERM)
print('Stopped!')
args=""
for arg in sys.argv[1:]:
args+="'"+arg+"' "
calibrate_cmd = "python3 calibrate.py " + args
test_cmd = """python3 depthai_demo.py -co '{"streams": [{"name": "depth", "max_fps": 12.0}]}'"""
atexit.register(cleanup)
p = subprocess.Popen(calibrate_cmd, shell=True, preexec_fn=os.setsid)
p.wait()
return_code = p.returncode
p=None
print("Return code:"+str(return_code))
time.sleep(3)
if(return_code == 0):
p = subprocess.Popen(test_cmd, shell=True, preexec_fn=os.setsid)
p.wait()
return_code = p.returncode
p=None
print("Return code:"+str(return_code))
exit(return_code)