Add image selection refinement functionality with BEN2 integration

- Implemented viewport.py for handling 3D view projections, gestures, and overlay drawing.
- Created refine_image_selection.py to manage the refinement of gesture masks and output image bounds.
- Added selection module with refine_selection.py to process and crop images based on alpha channel visibility.
- Introduced __init__.py for selection module to expose refine_selection function.
This commit is contained in:
2026-08-31 22:10:05 +08:00
parent 14d63001d2
commit c97b4a3e41
76 changed files with 2127 additions and 1137 deletions

View File

@@ -4,8 +4,29 @@ from dataclasses import dataclass
@dataclass
class GeometryFrame:
depth: object
points: object | None
validity: object
intrinsics: object
valid_mask: object
confidence: object | None = None
model_mask: object | None = None
normal: object | None = None
points: object | None = None
def __post_init__(self):
import numpy as np
depth = np.asarray(self.depth)
validity = np.asarray(self.validity)
intrinsics = np.asarray(self.intrinsics)
if depth.dtype != np.float32 or depth.ndim != 2:
raise ValueError("Geometry depth must be a 2D float32 field")
if validity.dtype != np.float32 or validity.shape != depth.shape:
raise ValueError("Geometry validity must match the depth as float32")
if intrinsics.dtype != np.float32 or intrinsics.shape != (3, 3):
raise ValueError("Geometry intrinsics must be a 3x3 float32 matrix")
for name in ("normal", "points"):
value = getattr(self, name)
if value is None:
continue
field = np.asarray(value)
if field.dtype != np.float32 or field.shape != (*depth.shape, 3):
raise ValueError(
f"Geometry {name} must match the depth as three-channel float32"
)