Inside AI
← Build & Hack
Manufacturer demo / Edge AI

Separate an object from its background

The segmentation demo colors the pixels belonging to a recognized object. Compare that shape with a rectangular detection box.

Device profile · Raspberry Pi AI HAT+ ↗

What you need

Use a Raspberry Pi 5, the original 13 or 26 TOPS AI HAT+, a supported camera and a display. Follow the linked Raspberry Pi AI software guide for the 64-bit OS and hailo-all setup. Check the camera preview before starting.

Run the supplied demo

Put a recognizable object in view. Run the preview and watch how the colored mask changes as the object moves in front of a different background.

rpicam-hello -t 30000 --post-process-file /usr/share/rpi-camera-assets/hailo_yolov5_segmentation.json --framerate 20

Build on it · proposed extension

Build a silhouette camera. Use the mask to keep the subject and replace the background with a solid color. Test the boundary around thin edges and overlapping objects.

Primary sources

Raspberry Pi · AI software guide