feat: /api/intrinsics gives what an align outside the SDK needs
Already there: fx/fy/cx/cy and k1,k2,k3,p1,p2 of both streams, extrinsics depth->color (rotation row-major, translation mm). Added, as new keys only: width, height and distortion model name (an rs.distortion member) in "ir" and "rgb", and depth_scale_m at the top. Docstring states the extrinsics convention: p_rgb = R p_ir + t, R row-major (the SDK's is column-major). Same keys in /api/status and /api/open, which share the payload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e11565de04
commit
f58b81cb73
2 files changed
+29
-1
No files matched your search
@@ -269,7 +269,13 @@ def _frame_to_dict(frame: CameraFrame, include_images: bool = True) -> dict:
|
||||
|
||||
|
||||
def _calibration_payload() -> dict | None:
|
||||
"""Full calibration (intrinsics + distortion + extrinsics) or None."""
|
||||
"""Full calibration (intrinsics + distortion + extrinsics) or None.
|
||||
|
||||
Enough to align depth to color outside the SDK: per stream width, height
|
||||
and distortion model (rs.distortion member name), depth_scale_m (meters per
|
||||
raw unit). extrinsics_ir_to_rgb: p_rgb = R p_ir + t, R row-major (the SDK's
|
||||
is column-major), t in millimeters.
|
||||
"""
|
||||
if not _camera or not _camera.intrinsics:
|
||||
return None
|
||||
i = _camera.intrinsics
|
||||
@@ -280,19 +286,26 @@ def _calibration_payload() -> dict | None:
|
||||
def _d(d):
|
||||
return None if d is None else {"k1": d.k1, "k2": d.k2, "k3": d.k3, "p1": d.p1, "p2": d.p2}
|
||||
|
||||
def _stream(name):
|
||||
width, height = _camera.stream_sizes.get(name, (None, None))
|
||||
return {"width": width, "height": height, "model": _camera.distortion_models.get(name)}
|
||||
|
||||
return {
|
||||
"ir": {
|
||||
"fx": i.fx_ir, "fy": i.fy_ir, "cx": i.cx_ir, "cy": i.cy_ir,
|
||||
"distortion": _d(dir_),
|
||||
**_stream("ir"),
|
||||
},
|
||||
"rgb": {
|
||||
"fx": i.fx_rgb, "fy": i.fy_rgb, "cx": i.cx_rgb, "cy": i.cy_rgb,
|
||||
"distortion": _d(drgb),
|
||||
**_stream("rgb"),
|
||||
},
|
||||
"extrinsics_ir_to_rgb": None if e is None else {
|
||||
"rotation": list(e.rotation),
|
||||
"translation": list(e.translation),
|
||||
},
|
||||
"depth_scale_m": _camera.depth_scale(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user