Conveyor Segmentation using SAM
SUMMARY
Monitor and identify products, parts, or packages as they move along a conveyor belt for counting, sorting, quality inspection, or robotic pick-and-place. segment_image_using_sam segments each object in a frame and returns a mask and bounding box per item, which downstream tracking logic can use to assign and follow consistent IDs across frames.
Raw Sensor Input


Raw sensor input showing packages on a conveyor belt.
Segmentation and Boxes


Segmented image showing masks and bounding boxes for each detected package.
Code
python
from telekinesis import cornea
# `image` is a datatypes.Image (or np.ndarray) of one conveyor frame.
# `bboxes` is one [x1, y1, x2, y2] box per package in this frame —
# 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 package. Feed the boxes/masks into
# a tracker (e.g. SORT, DeepSORT, or centroid matching) frame-by-frame
# to assign consistent IDs as packages move along the belt.
for result in segmentation_results:
box = result.bbox
score = result.score
mask = result.segmentation
