init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
|
||||
DEFAULT_ROTATION1 = {
|
||||
"rotation_angle": 90,
|
||||
"flip_x": True,
|
||||
"flip_y": False,
|
||||
}
|
||||
|
||||
DEFAULT_ROTATION2 = {
|
||||
"rotation_angle": 90,
|
||||
"flip_x": False,
|
||||
"flip_y": False,
|
||||
}
|
||||
|
||||
|
||||
def normalize_rotation_config(value, default_config):
|
||||
if value is None:
|
||||
return copy.deepcopy(default_config)
|
||||
if isinstance(value, dict):
|
||||
return copy.deepcopy(value)
|
||||
if isinstance(value, str):
|
||||
text = value.strip()
|
||||
if not text or text.lower() == "default":
|
||||
return copy.deepcopy(default_config)
|
||||
if text.startswith("{"):
|
||||
return json.loads(text)
|
||||
return value
|
||||
|
||||
|
||||
def write_temp_rotation_config(config, label):
|
||||
path = os.path.join(tempfile.gettempdir(), f"gripper_{label}_rotation.json")
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
json.dump(config, f, ensure_ascii=False, indent=2)
|
||||
return path
|
||||
Reference in New Issue
Block a user