Claude: Kameras in Vizual
This commit is contained in:
@@ -1324,6 +1324,21 @@ def main() -> None:
|
||||
out_dir = args.outDir or os.path.dirname(args.detections[0]) or "."
|
||||
os.makedirs(resolve_path(out_dir), exist_ok=True)
|
||||
|
||||
# camera poses in world (for viewer frusta): centre C = -R^T t, view axis = R[2]
|
||||
cameras_section = []
|
||||
for idx, (K, D, R_wc, t_wc) in enumerate(cameras):
|
||||
C = -R_wc.T @ t_wc
|
||||
cam_id = str(idx)
|
||||
base = os.path.basename(str(obs_metadata[idx].get("pose_file", ""))) if idx < len(obs_metadata) else ""
|
||||
if base.startswith("render_") and "_camera_pose" in base:
|
||||
cam_id = base[len("render_"):base.index("_camera_pose")]
|
||||
cameras_section.append({
|
||||
"camera_id": cam_id,
|
||||
"position_m": [float(v) for v in C],
|
||||
"position_mm": [float(v * 1000.0) for v in C],
|
||||
"direction": [float(v) for v in R_wc[2]],
|
||||
})
|
||||
|
||||
initial_output_markers = []
|
||||
for marker_id, position in sorted(initial_pos.items()):
|
||||
normal = marker_meta.get(marker_id, {}).get("normal", None)
|
||||
@@ -1346,6 +1361,7 @@ def main() -> None:
|
||||
"num_markers": len(initial_pos),
|
||||
"num_constraints": len(constraints),
|
||||
},
|
||||
"cameras": cameras_section,
|
||||
"markers": initial_output_markers,
|
||||
}
|
||||
initial_out_file = os.path.join(out_dir, "aruco_positions_initial.json")
|
||||
@@ -1407,6 +1423,7 @@ def main() -> None:
|
||||
"num_markers": len(optimized_pos),
|
||||
"num_constraints": len(constraints),
|
||||
},
|
||||
"cameras": cameras_section,
|
||||
"markers": output_markers,
|
||||
}
|
||||
out_file = os.path.join(out_dir, "aruco_positions_optimized.json")
|
||||
|
||||
@@ -160,12 +160,25 @@ def main() -> None:
|
||||
"edge_length_mm": edge_mm,
|
||||
})
|
||||
|
||||
# camera poses in world (for viewer frusta): centre C = -R^T t, view axis = R[2]
|
||||
cameras_out = []
|
||||
for cid in sorted(cams.keys()):
|
||||
cam = cams[cid]
|
||||
C = -cam["R"].T @ cam["t"]
|
||||
cameras_out.append({
|
||||
"camera_id": cid,
|
||||
"position_m": [float(v) for v in C],
|
||||
"position_mm": [float(v * 1000.0) for v in C],
|
||||
"direction": [float(v) for v in cam["R"][2]],
|
||||
})
|
||||
|
||||
out_path = args.out or os.path.join(args.evalDir, "aruco_marker_poses.json")
|
||||
output = {
|
||||
"schema_version": "1.0",
|
||||
"schema_version": "1.1",
|
||||
"stage": "corner_marker_poses",
|
||||
"created_utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||
"summary": {"num_cameras": len(cams), "num_markers": len(markers_out)},
|
||||
"cameras": cameras_out,
|
||||
"markers": markers_out,
|
||||
}
|
||||
json.dump(output, open(out_path, "w", encoding="utf-8"), indent=2)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user