-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_calc_board_height.py
More file actions
33 lines (27 loc) · 1 KB
/
Copy path_calc_board_height.py
File metadata and controls
33 lines (27 loc) · 1 KB
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
"""
_calc_board_height.py — called by launch.bat to calculate board height from image.
Usage: python _calc_board_height.py <image_path> <board_width>
Prints the board height as a single integer, or exits with code 1 on failure.
"""
import sys
import os
def main():
if len(sys.argv) < 3:
print("Usage: _calc_board_height.py <image_path> <board_width>", file=sys.stderr)
sys.exit(1)
image_path = sys.argv[1]
try:
board_w = int(sys.argv[2])
except ValueError:
print(f"Error: board_width must be an integer, got: {sys.argv[2]!r}", file=sys.stderr)
sys.exit(1)
if board_w <= 0:
print(f"Error: board_width must be positive, got: {board_w}", file=sys.stderr)
sys.exit(1)
script_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, script_dir)
from board_sizing import derive_board_from_width
result = derive_board_from_width(image_path, board_w)
print(result["board_height"])
if __name__ == "__main__":
main()