From 4a83305b5e9e8c0dad235390ad482bf1e35edf9f Mon Sep 17 00:00:00 2001 From: Adriano Dal Pastro Date: Wed, 13 May 2026 11:13:20 +0200 Subject: [PATCH] fix(work_plane): project fit inliers from CV-frame pts_cv (not raw pc) NuwaClient.pointcloud_roi's docstring claims OpenCV frame, but in practice the raw payload arrives in Nuwa native frame (Z<0 forward). nuwa_to_cv_frame is what actually flips it. Using `pts_cv` (post-flip + post-outlier-mask) makes the projection drop none of the inliers. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/presa_mano/api/work_plane_routes.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/presa_mano/api/work_plane_routes.py b/src/presa_mano/api/work_plane_routes.py index edd0b1b..011cb59 100644 --- a/src/presa_mano/api/work_plane_routes.py +++ b/src/presa_mano/api/work_plane_routes.py @@ -115,8 +115,10 @@ def fit(req: FitReq) -> dict[str, Any]: # Project the inliers used for the fit back to RGB pixels so the GUI can # overlay them on the live image (verify visually which depth pixels were - # actually fed to fit_plane_svd). pc is in OpenCV camera frame already - # (per pointcloud_roi docstring); use Nuwa's RGB intrinsics. + # actually fed to fit_plane_svd). NOTE: pointcloud_roi's docstring claims + # CV frame, but in practice the raw `pc` arrives in Nuwa native frame + # (Z<0 forward). After nuwa_to_cv_frame + outlier mask, `pts_cv` is the + # canonical CV-frame inlier set, so use it. fit_points_px: list[list[int]] = [] try: intr_full = nuwa.intrinsics() @@ -127,9 +129,8 @@ def fit(req: FitReq) -> dict[str, Any]: H = int(rgb_intr.get("height", 480)) rgb_intr = {**rgb_intr, "width": W, "height": H} K = K_from_intrinsics(rgb_intr) - inliers_cv = pc[inlier_mask, :3] # original CV-frame coords with sw.step("project_inliers"): - fit_points_px = project_camera_to_pixels(inliers_cv, K, (W, H)).tolist() + fit_points_px = project_camera_to_pixels(pts_cv, K, (W, H)).tolist() except Exception as e: log.warning("could not project fit inliers to RGB pixels: %s", e)