Inside AI
← Deep Dives
Deep dive / Edge AI

Inside the AI HAT+

Trace the path from a camera exposure to a bounding box, and find the parts of the pipeline that a TOPS rating leaves out.

Device profile · Raspberry Pi AI HAT+ ↗
FIG. 01 / INFERENCE PATH
Camera→Pi 5 host⇄Hailo NPU
Frames enter the host. The accelerator returns inference outputs over PCIe.

Follow one bottle

Put a bottle on a workbench and move it through a marked line. A detector can report the bottle dozens of times before it crosses. The application must decide whether those reports describe one crossing, several bottles or a stationary object.

From sensor to inference

The camera delivers a stream to the Pi 5. The published YOLOv8 example requests a 640 × 640 RGB low-resolution stream and picks yolov8s_h8l.hef or yolov8s_h8.hef for the corresponding board. The Pi submits that input to the Hailo device and waits for output tensors. Confirm the configuration shipped with your installed package before comparing runs. Raspberry Pi’s YOLOv8 configuration Raspberry Pi’s detection stage

From tensors to a visible box

On the Pi, the reference stage post-processes the tensors, filters by confidence and maps box coordinates back to the camera output. It stores surviving objects in the request’s object_detect.results metadata. A separate drawing stage consumes the results. The published configuration uses a 0.4 cutoff and a temporal filter, so two observers comparing visible overlays must also match those settings. Raspberry Pi’s detection stage Raspberry Pi’s YOLOv8 configuration

The extension point for an application

Keep the model fixed if the new behavior depends on existing classes. Hailo’s separate GStreamer application passes a buffer to a Python callback. The example reads detection labels and confidence and checks for a tracker ID. A counting rule can consume this metadata without copying RGB pixels into Python. This callback belongs to Hailo’s app; invoking rpicam-hello alone does not run it. Hailo’s tracking example Hailo’s Python callback

When a custom network earns its cost

If the goal is to distinguish two specific bottle caps, first test whether the shipped labels express that distinction. If they do not, select a supported network and train it for the new classes. Hailo directs Hailo-8/8L users to Model Zoo v2.x with Dataflow Compiler v3.x. Parse the network, use representative images during quantization, compile a HEF for the board target and validate it on held-out scenes. Match the input size, class map and output decoder to the new model before comparing boxes. Hailo’s compatibility table Hailo’s v2 compilation guide Hailo’s tracking example Raspberry Pi’s detection stage

Measure the path you intend to improve

For a user-facing overlay, film the physical target entering the scene and the monitor showing the first correct box in the same shot. For a downstream control action, film the target and the action indicator instead. These proposed intervals include different stages. A callback timer alone omits camera exposure, and processing rate in frames per second does not give either interval.

Bench evidence

Unrun. Record board variant, OS and package versions, model file, threshold, temporal settings, camera exposure and display setup. Report misses alongside the latency of successful detections. A fast successful subset can hide many missed objects.

Primary sources

Raspberry Pi · AI HAT+ Raspberry Pi · AI software guide Pi hardware guide Raspberry Pi’s YOLOv8 configuration Raspberry Pi’s detection stage Hailo’s tracking example Hailo’s Python callback Hailo’s compatibility table Hailo’s v2 compilation guide