-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
25 lines (23 loc) · 1.08 KB
/
utils.py
File metadata and controls
25 lines (23 loc) · 1.08 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
import numpy as np
def load_color_range(color_name, file_path="colors.txt"):
with open(file_path, "r") as f:
for line in f:
if line.startswith("#") or not line.strip():
continue
parts = line.strip().split(",")
if parts[0].lower() == color_name.lower():
lower = np.array(list(map(int, parts[1:4])))
upper = np.array(list(map(int, parts[4:])))
return lower, upper
raise ValueError(f"Color '{color_name}' not found in {file_path}")
def load_shape_params(shape_name, file_path="shapes.txt"):
with open(file_path, "r") as f:
for line in f:
if line.startswith("#") or not line.strip():
continue
parts = line.strip().split(",")
if parts[0].lower() == shape_name.lower():
circ_min, circ_max = float(parts[1]), float(parts[2])
ar_min, ar_max = float(parts[3]), float(parts[4])
return circ_min, circ_max, ar_min, ar_max
raise ValueError(f"Shape '{shape_name}' not found in {file_path}")