From 491d1b60aab26d64f3c30700da10319192ed811d Mon Sep 17 00:00:00 2001 From: Adriano Dal Pastro Date: Wed, 13 May 2026 11:59:15 +0200 Subject: [PATCH] =?UTF-8?q?revert(find=5Fmodel):=20drop=20plane=20filter?= =?UTF-8?q?=20=E2=80=94=20pass=20full=20SAM21=20cluster=20to=20Open3DModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pre-SAM21 depth filter and post-SAM21 partition_by_plane were fighting each other and drowning the actual object cluster. Per operator request, send Open3DModel the raw SAM21 cluster and let RANSAC handle outliers itself. The accepted/excluded/SAM21 overlays in the GUI continue to work; excluded is now always empty and accepted == SAM21 cluster. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/presa_mano/api/grasp_routes.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/presa_mano/api/grasp_routes.py b/src/presa_mano/api/grasp_routes.py index 16b85c4..c36ec43 100644 --- a/src/presa_mano/api/grasp_routes.py +++ b/src/presa_mano/api/grasp_routes.py @@ -232,26 +232,20 @@ def find_model(req: FindModelReq) -> dict[str, Any]: top = dets[0] bbox = _bbox_to_roi(top["bbox"]) - # 2. SAM21, with depth pre-filter so the segmentation cannot leak onto - # the table around the object: pixels whose back-projection sits below - # the plane have their depth zeroed BEFORE SAM21 sees them, so they - # never end up in the cloud regardless of the mask outline. + # 2. SAM21 — full cluster, no plane filtering at all. try: - seg = segment_with_sam21(nuwa, sam21, bbox, sw, - pre_filter_plane=get_work_plane()) + seg = segment_with_sam21(nuwa, sam21, bbox, sw) except Sam21Fallback as e: raise HTTPException(status_code=422, detail=f"SAM21 fail: {e}") - # 3. Partition by plane - with sw.step("partition_plane"): - accepted_m, excluded_m, plane_info = partition_by_plane( - seg.points_cv_m, get_work_plane() - ) + accepted_m = seg.points_cv_m + excluded_m = np.empty((0, 3), dtype=np.float64) + plane_info = {"plane_applied": False, + "n_points_before_plane": int(accepted_m.shape[0])} if accepted_m.shape[0] < 10: raise HTTPException( status_code=422, - detail=f"too few accepted points after plane filter: {accepted_m.shape[0]}" - f" (before plane: {plane_info['n_points_before_plane']})" + detail=f"too few SAM21 points: {accepted_m.shape[0]}" ) # 4. Open3DModel pose