New version of config converter
Camera calibration is moved to the camera config.
This commit is contained in:
+18
-21
@@ -42,25 +42,8 @@ def convert_config(old_base_dir, new_cam_base_dir, new_pipeline_base_dir, new_ba
|
||||
mirror_x = old_config["camera"].get("mirror_x", False)
|
||||
mirror_y = old_config["camera"].get("mirror_y", False)
|
||||
rotate = old_config["camera"].get("rotate", 0)
|
||||
|
||||
config_name = os.path.splitext(basename(old_config_file))[0]
|
||||
|
||||
new_cam_config = OrderedDict({"name": config_name,
|
||||
"prefix": prefix,
|
||||
"mirror_x": mirror_x,
|
||||
"mirror_y": mirror_y,
|
||||
"rotate": rotate})
|
||||
|
||||
cam_config_filename = os.path.join(new_cam_base_dir, config_name + ".json")
|
||||
with open(cam_config_filename, 'w') as outfile:
|
||||
json.dump(new_cam_config, outfile, indent=4)
|
||||
|
||||
new_pipeline_config = OrderedDict({"name": config_name,
|
||||
"camera_name": config_name})
|
||||
|
||||
# Camera calibration - we need to move this to the pipeline config.
|
||||
calibration = old_config["camera"].get("calibration")
|
||||
if calibration:
|
||||
if calibration is not None:
|
||||
new_calibration = {"reference_marker": calibration.get("reference_marker", DEFAULT_REFERENCE_MARKER),
|
||||
"reference_marker_width": calibration.get("reference_marker_width",
|
||||
DEFAULT_REFERENCE_MARKER_WIDTH),
|
||||
@@ -70,10 +53,24 @@ def convert_config(old_base_dir, new_cam_base_dir, new_pipeline_base_dir, new_ba
|
||||
DEFAULT_HORIZONTAL_CAMERA_ANGLE),
|
||||
"angle_vertical": calibration.get("vertical_camera_angle",
|
||||
DEFAULT_VERTICAL_CAMERA_ANGLE)}
|
||||
|
||||
new_pipeline_config["camera_calibration"] = new_calibration
|
||||
else:
|
||||
new_pipeline_config["camera_calibration"] = DEFAULT_CAMERA_CALIBRATION
|
||||
new_calibration = DEFAULT_CAMERA_CALIBRATION
|
||||
|
||||
config_name = os.path.splitext(basename(old_config_file))[0]
|
||||
|
||||
new_cam_config = OrderedDict({"name": config_name,
|
||||
"prefix": prefix,
|
||||
"mirror_x": mirror_x,
|
||||
"mirror_y": mirror_y,
|
||||
"rotate": rotate,
|
||||
"camera_calibration": new_calibration})
|
||||
|
||||
cam_config_filename = os.path.join(new_cam_base_dir, config_name + ".json")
|
||||
with open(cam_config_filename, 'w') as outfile:
|
||||
json.dump(new_cam_config, outfile, indent=4)
|
||||
|
||||
new_pipeline_config = OrderedDict({"name": config_name,
|
||||
"camera_name": config_name})
|
||||
|
||||
# We have pipeline parameters.
|
||||
old_pipeline_config_file = os.path.join(old_base_dir, config_name + "_parameters.json")
|
||||
|
||||
Reference in New Issue
Block a user