From f1f1277755ff02a587fdc45a8b7e7c09afd03af5 Mon Sep 17 00:00:00 2001 From: henrytherobot Date: Mon, 25 May 2026 12:23:53 +0200 Subject: [PATCH] fix: report negotiated color resolution in /status Read width/height/fps from the live pipeline profile instead of hardcoding 640x480, so /status reflects the firmware-accepted resolution (e.g. the USB 2.x 640x480@15 fallback) rather than the requested config. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/backend/api/routes.py | 2 +- src/backend/services/camera.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/backend/api/routes.py b/src/backend/api/routes.py index dd631d6..4e9d5f0 100644 --- a/src/backend/api/routes.py +++ b/src/backend/api/routes.py @@ -126,7 +126,7 @@ async def status(): "color_available": _camera.is_color_available() if (_camera and _camera.is_open()) else False, "usb_type": _camera.usb_type() if (_camera and _camera.is_open()) else None, "frame_count": _frame_count, - "resolution": {"width": 640, "height": 480}, + "resolution": _camera.resolution() if (_camera and _camera.is_open()) else None, "intrinsics": _calibration_payload(), }) diff --git a/src/backend/services/camera.py b/src/backend/services/camera.py index b0db4f9..cf4a5c3 100644 --- a/src/backend/services/camera.py +++ b/src/backend/services/camera.py @@ -135,6 +135,21 @@ class RealSenseD435: def usb_type(self) -> str: return self._usb_type + def resolution(self) -> Optional[dict]: + """Negotiated color stream resolution, or None if not open. + + Reads from the live pipeline profile so the value reflects what the + firmware actually accepted — on USB 2.x this is the forced 640x480@15 + fallback, not the configured `_width/_height`. + """ + if not self._open or self._profile is None: + return None + try: + stream = self._profile.get_stream(rs.stream.color).as_video_stream_profile() + return {"width": stream.width(), "height": stream.height(), "fps": stream.fps()} + except Exception: + return None + def init(self) -> bool: try: self._ctx = rs.context()