refactor: remove --metrics-json from refine_ground_plane.py

This commit is contained in:
2026-02-09 09:59:43 +00:00
parent 3b471c2cae
commit 915c7973d1
4 changed files with 78 additions and 42 deletions
+7 -30
View File
@@ -11,7 +11,6 @@ from aruco.ground_plane import (
refine_ground_from_depth,
create_ground_diagnostic_plot,
save_diagnostic_plot,
GroundPlaneMetrics,
Mat44,
)
from aruco.depth_save import load_depth_data
@@ -39,11 +38,6 @@ from aruco.depth_save import load_depth_data
type=click.Path(dir_okay=False),
help="Output extrinsics JSON file.",
)
@click.option(
"--metrics-json",
type=click.Path(dir_okay=False),
help="Optional path to save metrics JSON.",
)
@click.option(
"--plot/--no-plot",
default=True,
@@ -100,7 +94,6 @@ def main(
input_extrinsics: str,
input_depth: str,
output_extrinsics: str,
metrics_json: Optional[str],
plot: bool,
plot_output: Optional[str],
max_rotation_deg: float,
@@ -197,6 +190,8 @@ def main(
# 5. Save Output Extrinsics
output_data = extrinsics_data.copy()
per_camera_diagnostics = {}
for serial, T_new in new_extrinsics.items():
if serial in output_data:
pose_str = " ".join(f"{x:.6f}" for x in T_new.flatten())
@@ -209,13 +204,13 @@ def main(
rot_deg = float(np.rad2deg(np.arccos(cos_angle)))
trans_m = float(np.linalg.norm(T_corr[:3, 3]))
output_data[serial]["ground_refine"] = {
per_camera_diagnostics[serial] = {
"corrected": True,
"delta_rot_deg": rot_deg,
"delta_trans_m": trans_m,
}
else:
output_data[serial]["ground_refine"] = {
per_camera_diagnostics[serial] = {
"corrected": False,
"reason": "skipped_or_failed",
}
@@ -239,32 +234,14 @@ def main(
"max_rotation_deg": metrics.rotation_deg,
"max_translation_m": metrics.translation_m,
},
"per_camera": per_camera_diagnostics,
}
logger.info(f"Saving refined extrinsics to {output_extrinsics}")
with open(output_extrinsics, "w") as f:
json.dump(output_data, f, indent=4, sort_keys=True)
# 6. Save Metrics JSON (Optional)
if metrics_json:
metrics_data = {
"success": metrics.success,
"message": metrics.message,
"num_cameras_total": metrics.num_cameras_total,
"num_cameras_valid": metrics.num_cameras_valid,
"skipped_cameras": metrics.skipped_cameras,
"max_rotation_deg": metrics.rotation_deg,
"max_translation_m": metrics.translation_m,
"camera_corrections": {
s: " ".join(f"{x:.6f}" for x in T.flatten())
for s, T in metrics.camera_corrections.items()
},
}
logger.info(f"Saving metrics to {metrics_json}")
with open(metrics_json, "w") as f:
json.dump(metrics_data, f, indent=4)
# 7. Generate Plot (Optional)
# 6. Generate Plot (Optional)
if plot:
if not plot_output:
plot_output = str(Path(output_extrinsics).with_suffix(".html"))
@@ -286,4 +263,4 @@ def main(
if __name__ == "__main__":
main()
main() # pylint: disable=no-value-for-parameter