- 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.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class GeometryFrame:
|
|
depth: object
|
|
validity: object
|
|
intrinsics: object
|
|
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"
|
|
)
|