Pedestrian Segmentation with SAM
SUMMARY
Isolate people in a scene precisely enough for safety and navigation logic, even in crowded or cluttered scenes where bounding boxes overlap. segment_image_using_sam returns a pixel-accurate mask per person, supporting safety-zone enforcement, people counting, and dynamic obstacle avoidance for robots and AGVs.
Raw Sensor Input


Raw sensor input showing pedestrians in a public space.
Segmentation and Masks


Segmented image showing masks for each detected pedestrian.
Code
python
from telekinesis import cornea
# `image` is a datatypes.Image (or np.ndarray) of the scene.
# `bboxes` is one [x1, y1, x2, y2] box per pedestrian — typically from
# an object detector run on the same frame.
segmentation_results = cornea.segment_image_using_sam(
image=image,
bboxes=bboxes,
mask_threshold=0.5,
)
# Each result carries a bounding box, a mask-quality score, and an
# encoded segmentation mask for that person — feed the mask into
# safety-zone, counting, or obstacle-avoidance logic instead of the
# raw box.
for result in segmentation_results:
box = result.bbox
score = result.score
mask = result.segmentation
