Skip to content

Forklift Segmentation with SAM

SUMMARY

Isolate forklifts in a warehouse or factory scene precisely enough to support safety and navigation logic, not just detect that one is present. segment_image_using_sam returns a pixel-accurate mask per forklift, which downstream logic can use for dynamic obstacle avoidance, safety-zone enforcement, or fleet monitoring.

Raw Sensor Input
Forklift Segmentation Input
Raw sensor input of a warehouse or factory.
Segmentation and Mask
Forklift Segmentation Output
Segmented image with mask and bounding box for the detected forklift.

Code

python
from telekinesis import cornea

# `image` is a datatypes.Image (or np.ndarray) of the warehouse scene.
# `bboxes` is one [x1, y1, x2, y2] box per forklift — 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 forklift — feed the mask into
# safety-zone or obstacle-avoidance logic instead of the raw box.
for result in segmentation_results:
    box = result.bbox
    score = result.score
    mask = result.segmentation