-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
102 lines (82 loc) · 2.47 KB
/
run.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import subprocess
import sys
import argparse
def parse_arguments():
parser = argparse.ArgumentParser(
description="Run projection.py, segmentation.py, scale_field.py, and normal_vectors.py \
scripts with the specified arguments."
)
parser.add_argument("date", help="Date in the format YYYY_MM_DD")
parser.add_argument("drive", type=int, help="Drive, positive integer")
parser.add_argument("cam", type=int, help="Camera number, 0, 1, 2, or 3")
parser.add_argument("--prompt", help="Segmentation prompt")
parser.add_argument(
"--interpolation", help="Interpolation method, linear, nearest, cubic, None"
)
parser.add_argument("--debug", action="store_true", help="Enable debug mode")
return parser.parse_args()
def run_script(script_name, args):
command = [sys.executable, script_name] + args
print(f"Running: {script_name} with {args}")
try:
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
universal_newlines=True,
)
for line in process.stdout: # type: ignore
print(line, end="")
process.wait()
if process.returncode != 0:
print(f"Error: {script_name} exited with status {process.returncode}")
except Exception as e:
print(f"Error running {script_name}: {e}")
def main():
args = parse_arguments()
date = args.date
drive = args.drive
cam = args.cam
prompt = args.prompt
interpolation = args.interpolation
debug = args.debug
# projection
args = [date, str(drive), str(cam)]
if debug:
args.append("--debug")
run_script("projection.py", args)
# segmentation
args = [date, str(drive), str(cam), "--prompt", prompt]
if debug:
args.append("--debug")
run_script("segmentation.py", args)
# scale_field
args = [
date,
str(drive),
str(cam),
"--prompt",
prompt,
"--interpolation",
interpolation,
]
if debug:
args.append("--debug")
run_script("scale_field.py", args)
# normal_vectors
args = [
date,
str(drive),
str(cam),
"--prompt",
prompt,
"--interpolation",
interpolation,
]
if debug:
args.append("--debug")
run_script("normal_vectors.py", args)
if __name__ == "__main__":
main()