inteintegrity2026-08-18

Pothole Detection with Raspberry Pi 5 and Hailo-8

Detect road potholes from video using a YOLOv8n HEF model on Hailo-8, with ROI road-area filtering, temporal gap-fill tracking, and a browser MJPEG dashboard on Raspberry Pi 5.

CVObject DetectionRoad SafetyGitHub

This project uses a Raspberry Pi 5 and Hailo-8 accelerator to detect road potholes from video using a YOLOv8n model compiled to Hailo HEF format. It provides both batch video inference with annotated output and a real-time MJPEG web preview with FPS, pothole count, and cumulative event counter. A road-area ROI filter suppresses sky and sidewalk false positives, while a temporal tracker bridges short detection gaps with yellow gap-fill boxes.

Source code: https://github.com/Seeed-Projects/reComputer-AI-Lab-Project/tree/main/pi_project/pothole_detection

Features

  • Hailo-8 accelerated YOLOv8n inference on Raspberry Pi 5
  • Single-class pothole detection with Hailo NMS postprocessing
  • Road-area ROI trapezoidal filter to reject non-road detections
  • Temporal tracker with short gap-fill (yellow boxes, max 3 missed frames)
  • Cumulative event counter for unique pothole tracks
  • Video batch inference with FPS overlay and confidence labels
  • Browser-based MJPEG preview and status API on port 8000
  • Included demo video, HEF model, and device validation tools
  • Bare-metal and Docker deployment options
  • 35 no-hardware unit tests for syntax, config, and postprocessing

Hardware and Software

ComponentRequirement
BoardRaspberry Pi 5, 64-bit ARM (aarch64)
AcceleratorHailo-8 M.2 Key M 2280 (/dev/hailo0)
HailoRT4.23.0
Python3.11
Bare-metal OSRaspberry Pi OS 64-bit Bookworm
Container runtimeDocker with arm64 support

The host driver, firmware, shared library, and Python package must use compatible HailoRT versions. The included HEF model targets Hailo-8 rather than Hailo-8L.

Model Information

PropertyValue
ArchitectureYOLOv8n
Classes1 (pothole)
Input size640 × 640 RGB
Input modeuint8 (quantized)
OutputHailo NMS (YXYX coordinates + confidence)
HEF SHA-2566acec07e677cf4ae54919e0dd7105799ea8a50f1f48bd72528a6550b611b6856

Box Color Legend

ColorMeaning
OrangeDirect Hailo detection (with confidence label)
YellowTracked gap-fill — detection missed this frame, bridged from previous frames

The tracker assigns unique IDs to each pothole. When a detection is briefly lost (e.g., motion blur), the yellow box bridges the gap to avoid flickering. After max_missed consecutive misses (default 3), the track is removed.

Quick Start with Docker

Pull the prebuilt linux/arm64 image from GHCR:

bash
sudo docker pull \
  ghcr.io/seeed-projects/recomputer-ai-lab-project/pothole_detection:latest

Run the bundled video and web dashboard:

bash
sudo docker run --rm \
  --name rpi5-hailo8-pothole-detection \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.4.23.0:/usr/lib/libhailort.so.4.23.0:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-ai-lab-project/pothole_detection:latest \
  python web_detection.py \
    --config configs/runtime.json \
    --source input/demo.mp4 \
    --host 0.0.0.0 \
    --port 8000

Open the following address from a browser on the same network:

text
http://<PI_IP>:8000

The dashboard shows the annotated video stream, inference FPS, visible pothole count, cumulative event count, and frame number.

Get the Project

bash
git clone https://github.com/Seeed-Projects/reComputer-AI-Lab-Project.git
cd reComputer-AI-Lab-Project

Run on Raspberry Pi OS

Install the board dependencies and create a Python virtual environment:

bash
cd pi_project/pothole_detection
chmod +x scripts/*.sh
./scripts/install_rpi5.sh

The installer checks aarch64 and Python 3.11, installs system packages, creates a .venv with --system-site-packages, installs fastapi and uvicorn from pip, and installs HailoRT from the bundled local wheel — no internet download or version upgrade. After installing, reboot if the Hailo PCIe driver was newly installed. Then verify the accelerator and models:

bash
./scripts/probe.sh
python3 tools/check_deployment.py

Start the browser dashboard with the bundled video:

bash
python3 web_detection.py \
  --config configs/runtime.json \
  --source input/demo.mp4

To generate a processed MP4 without the Web dashboard, run:

bash
./scripts/run_demo.sh

The processed result is saved to outputs/pothole_demo_hailo8.mp4 with a companion .json report containing frame count, FPS, and detection statistics.

Build the Container from Source

The repository includes the Dockerfile and matching HailoRT 4.23.0 Python 3.11 aarch64 wheel. Build the image from the repository root:

bash
sudo docker build \
  -f docker/hailo8/pothole_detection.dockerfile \
  -t pothole_detection:latest \
  pi_project/pothole_detection

If HailoRT is installed to a different host path, adjust the two shared-library mounts while keeping the host and container versions compatible.

Web API

  • GET /: browser dashboard with live MJPEG stream and metrics
  • GET /api/video_feed: MJPEG annotated video stream
  • GET /api/status: JSON with FPS, pothole count, cumulative events, and error state
  • GET /healthz: service and inference health check

Validate the Configuration Only

Use --check-config to check paths and configuration structure without loading HailoRT:

bash
cd pi_project/pothole_detection
python3 app/infer_video_hailo.py --check-config
python3 web_detection.py --check-config

Configuration Parameters

configs/runtime.json controls all runtime behavior:

SectionKeyDefaultDescription
modelpathmodels/hef/pothole_yolov8n_hailo8.hefHEF model path
modelimgsz640Input dimension (must match HEF)
modelconfidence0.18Minimum detection confidence
modeliou0.55NMS IoU threshold
road_roienabledtrueEnable road-area filtering
road_roihorizon_y0.18Horizon line (top of road area)
temporalmax_missed3Max consecutive missed frames before track removal
temporalmin_hits2Minimum hits before showing a track

Command-line overrides: --source, --output, --confidence, --iou.

Use Another Video

Update configs/runtime.json to select another input and output path, or pass --source on the command line. For a live camera, use --source 0.

Project Structure

text
pi_project/pothole_detection/
├── app/                 # Video inference entry point
├── configs/             # Model and runtime configuration
├── input/               # Bundled demo video
├── models/hef/          # Hailo-8 HEF model
├── pothole_monitor/     # Frame processor and temporal tracker
├── runtime/             # HailoRT integration and YOLO post-processing
├── scripts/             # Installation, probing, Docker, and demo scripts
├── tools/               # Deployment validation utilities
├── tests/               # No-hardware unit tests
└── web_detection.py     # FastAPI dashboard and MJPEG stream