hylo.manip.perception¶
Package: hylo-manip · Core contracts
perception ¶
Perception from RGB-D: back-projection and fusion, the table plane (RANSAC), segmenters behind one interface (environment segmentation, named colours, VLM marks), per-object point clouds, oriented boxes and ICP.
COLOURS
module-attribute
¶
COLOURS: dict[str, tuple[float, float, float, float, float, float]] = {'red': (345, 15, 0.45, 1, 0.25, 1), 'orange': (15, 40, 0.45, 1, 0.6, 1), 'brown': (10, 45, 0.35, 1, 0.15, 0.6), 'yellow': (40, 70, 0.45, 1, 0.35, 1), 'green': (70, 165, 0.35, 1, 0.2, 1), 'cyan': (165, 195, 0.35, 1, 0.3, 1), 'blue': (195, 255, 0.35, 1, 0.2, 1), 'purple': (255, 290, 0.3, 1, 0.2, 1), 'pink': (290, 345, 0.3, 1, 0.3, 1), 'magenta': (290, 345, 0.3, 1, 0.3, 1), 'white': (0, 360, 0, 0.15, 0.8, 1), 'black': (0, 360, 0, 1, 0, 0.18), 'gray': (0, 360, 0, 0.15, 0.25, 0.8), 'grey': (0, 360, 0, 0.15, 0.25, 0.8)}
EnvSegmenter ¶
The environment's instance segmentation (<cam>.seg with extra["segments"] labels). A query matches the
segment labels with equal content words; failing that, those sharing the most words (score = overlap).
ColourSegmenter ¶
Named colours in HSV (red, orange, brown, yellow, green, cyan, blue, purple, pink, magenta, white, black, gray): a label's colour word selects pixels, split into connected components (one Mask each, score 1.0). Other words of the label are ignored, so "red block" and "red bowl" both match every red region.
MarkSegmenter ¶
MarkSegmenter(choose: Callable[[ndarray, list[ndarray], str], list[int]], propose: Callable[[View], dict[str, list[ndarray]]] | None = None, min_pixels: int = 20)
A vision-language model picks among numbered regions (set-of-marks). propose(view) gives candidate regions
per camera ({camera: [mask, ...]}; default: connected regions standing above the table in depth); choose(rgb,
regions, label) is the model adapter: it draws the numbers, asks the model and returns the chosen indices.
backproject ¶
World points of the camera's valid depth pixels (optionally only inside mask).
remove_outliers ¶
Statistical outlier removal: drop points whose mean distance to k neighbours exceeds mean + std * sigma.
components ¶
Index arrays of the groups of points connected by steps shorter than radius, largest first.
ransac_table ¶
ransac_table(points: ndarray, rng: Generator, iters: int = 300, thresh: float = 0.008, max_tilt_deg: float = 15.0, hint: float | None = None) -> Table
The near-horizontal plane with the most inliers (within 0.15 m of hint when given), refined by least
squares; height is the inliers' mean z.
above_table ¶
Points higher than min_height above the table plane.
label_score ¶
1.0 when the content words are equal; else their Jaccard overlap (0 when none shared).
detect_objects ¶
detect_objects(view: View, masks: Sequence[Mask], table: Table, voxel: float = 0.004, merge_radius: float = 0.015, min_points: int = 15) -> list[Detection]
Per label (and instance when known): masked depth back-projected (mask eroded by one pixel against edge pixels), points on or under the table and statistical outliers dropped (a flat marking on the table keeps its points within 1 cm of the plane), cameras merged, then split into 3D connected components: one Detection each, largest first.
fit_box ¶
Minimum-area rectangle of the xy footprint (convex hull, rotating edges; extents from the 1st and 99th percentiles), z from the top of the points down to the table (or the lowest point without one).
icp ¶
icp(model: ndarray, observed: ndarray, init: ndarray | None = None, iters: int = 40, tol: float = 0.005, yaw_steps: int = 12) -> Fit
Point-to-point ICP of model onto observed (each observed point to its nearest model point, so a partial
view fits). Without init: centroids aligned and yaw_steps yaws about +z tried, the best refined.