Real-time Object Detection with Raspberry Pi AI HAT+

Quick Overview & Specifications

AttributeDetails
PublicationVinjo Engineering & Technology
CategoryAI
AuthorVinay
Article TypeTechnical Tutorial & Case Study
Published2026-12-04
Last Updated2026-12-04
License / AccessOpen Educational Resource
Core Engineering Highlights:
  1. Verified hardware architecture, schematics, and pinout diagrams.
  2. Comprehensive firmware routines, protocol benchmarks, and build steps.
  3. Production design rules, tolerances, and thermal considerations.
Related Topic Taxonomy:
  • #Raspberry Pi
  • #AI HAT+
  • #Object Detection
  • #Real-time AI
  • #YOLO
  • #Viam
  • #Hardware
  • #Machine Learning
  • #IoT Projects
  • #Embedded Systems

Real-time Object Detection with Raspberry Pi AI HAT+

Summary: This article provides a comprehensive guide to implementing real-time object detection using the Raspberry Pi AI HAT+ and a Raspberry Pi 5. It details the setup process from OS installation and hardware configuration to leveraging the Viam platform for machine management, webcam integration, and deploying YOLO-based vision services. The tutorial culminates in creating a live traffic dashboard, offering a practical example for embedding AI capabilities into standalone projects.

Key Takeaways

  • Accessible AI Integration: Learn to seamlessly integrate the Raspberry Pi AI HAT+ into embedded projects, moving beyond desktop GUI demos for practical, standalone applications.
  • Comprehensive Setup: Follow a step-by-step guide covering Raspberry Pi OS installation, SSH access, PCIe Gen 3.0 enablement, Hailo-all package setup, and USB webcam integration.
  • Viam for Streamlined Deployment: Utilize the Viam app to configure your Raspberry Pi machine, webcam, Hailo Runtime vision service, and object detection sensors, simplifying complex AI deployments.
  • Real-time Monitoring Dashboard: Build a live tele-operations dashboard to visualize real-time video streams and object detection data, such as traffic analysis, from your edge device.

Detailed Overview

As an enthusiast of Raspberry Pi projects, the prospect of integrating AI models without performance bottlenecks using the Raspberry Pi AI HAT+ was exciting. However, the existing documentation primarily focused on GUI app demos, which wasn't ideal for embedded, standalone applications. This guide addresses that gap by providing a reusable module and a step-by-step tutorial to set up real-time object detection. We'll build a live traffic dashboard using a Raspberry Pi 5, the AI HAT+, a USB webcam, and the Viam platform to showcase its capabilities.

Essential Supplies for Your AI Project

To get started with this project, you'll need the following components:

Follow the official documentation for instructions on installing the AI HAT+ on your Raspberry Pi 5.

Step 1: Setting Up Your Raspberry Pi

The Raspberry Pi boots from a microSD card, so the first step is to install Raspberry Pi OS.

Install Raspberry Pi OS

  1. Connect the microSD card to your computer.
  2. Download and launch the Raspberry Pi Imager. raspberry pi imager
  3. Click CHOOSE DEVICE and select Raspberry Pi 5.
  4. Click CHOOSE OS and select Raspberry Pi OS (64-bit).
  5. Click CHOOSE STORAGE and select your microSD card. raspberry pi storage
  6. Click Next and then EDIT SETTINGS to configure your Pi for remote access.
  7. Check Set hostname (e.g., test) and Set username and password (create a secure username and password).
  8. Check Configure wireless LAN and enter your Wi-Fi SSID and password. Set the Wireless LAN country. raspberry pi hostname username and password
  9. Go to the SERVICES tab, check Enable SSH, and select Use password authentication. raspberry pi enable SSH
  10. Save your settings, confirm to apply OS customization, and erase data.
  11. Once the installation is complete, remove the microSD card.

Connect with SSH

  1. Insert the microSD card into your Raspberry Pi and power it on.
  2. From a terminal, connect via SSH using the hostname and username you set:
    ssh <USERNAME>@<HOSTNAME>.local
    
  3. If prompted, type "yes" to continue connecting and enter your password. raspberry pi SSH login
  4. Update your Raspberry Pi's packages:
    sudo apt update
    sudo apt upgrade
    

Step 2: Hardware Configuration for AI HAT+

Now, let's set up the AI HAT+ hardware and its dependencies.

Set Up the Hardware

Enable PCIe Gen 3.0 speeds for the best performance

  1. Connect to your Pi via SSH.
  2. Open the Raspberry Pi Configuration interface:
    sudo raspi-config
    
  3. Select Advanced Options. Advanced Options selection in raspi-config
  4. Select PCIe Speed. PCI2 Speed selection in raspi-config
  5. Choose Yes to enable PCIe Gen 3 mode. Yes selection in raspi-config
  6. Select Finish and reboot your device:
    sudo reboot
    
  7. Reconnect to the Pi with SSH.

Set up system dependencies

  1. Install the "hailo-all" package, which includes firmware, drivers, and processing libraries for the AI HAT+:
    sudo apt install -y hailo-all
    
  2. Reboot the device:
    sudo reboot
    
  3. Reconnect to the Pi with SSH.
  4. Verify the installation:
    hailortcli fw-control identify
    
    You should see output similar to this:
    Executing on device: 0000:01:00.0
    Identifying board
    Control Protocol Version: 2
    Firmware Version: 4.17.0 (release,app,extended context switch buffer)
    Logger Version: 0
    Board Name: Hailo-8
    Device Architecture: HAILO8L
    Serial Number: HLDDLBB234500054
    Part Number: HM21LB1C2LAE
    Product Name: HAILO-8L AI ACC M.2 B+M KEY MODULE EXT TMP
    

Add your webcam

  1. Connect your webcam's USB lead to any USB port on your Raspberry Pi.

Raspberry Pi 5 with webcam pointed out a window

Step 3: Configuring Your Machine and Peripherals with Viam

Now, we'll configure your Raspberry Pi and its peripherals using the Viam app.

Configure your machine

  1. In the Viam app, navigate to the LOCATIONS tab, type a name for your machine, and click Add machine. add machine
  2. Click View setup instructions.
  3. Select Linux / Aarch64 as the platform and keep viam-agent as the installation method. select platform
  4. Run the provided viam-agent command from your Raspberry Pi's SSH prompt. installation agent
  5. The Viam app will indicate when your machine is successfully connected. successful toast

Configure your webcam

  1. In the Viam app under the CONFIGURE tab, click the + icon in the left menu and select Component.
  2. Choose camera and find the webcam module. Keep the default name camera-1.
  3. In the Attributes section, select a video_path. select video path
  4. Click Save.
  5. Expand the TEST section at the bottom of the camera-1 panel to verify the video feed. test camera

Configure your vision service

  1. In the Viam app under the CONFIGURE tab, click the + icon and select Service.
  2. Choose vision and find the hailo-rt module. Select "Add module" and keep the default name vision-1.
  3. In the Depends on section, select camera-1 from the "Search resources" dropdown. select camera dependency
  4. Click Save.
  5. Expand the TEST section of the vision-1 panel to see images from camera-1 with object detection boxes. test vision service

Configure your detections sensor

  1. In the Viam app under the CONFIGURE tab, click the + icon and select Component.
  2. Choose sensor and find the detections module. Keep the default name sensor-1.
  3. In the Attributes section, add the following JSON configuration:
    {
      "camera": "camera-1",
      "detector": "vision-1",
      "labels": ["car", "bus", "person"]
    }
    
    configure sensor component
  4. In the Data capture section, click "+ Add method". Set "Method" as "Readings" and "Frequency (hz)" as 1. Click "Create data management service" to automatically create data_manager-1. configure sensor component
  5. Click Save.
  6. Expand the TEST section of the sensor-1 panel to see a list of configured labels with detection counts. test camera

Step 4: Building Your Real-time Traffic Dashboard

With all components and services configured, let's create a live tele-operations dashboard.

Configure your teleop workspace

  1. In the Viam app, return to the home page.
  2. Under the TELEOP tab, click Create workspace. create workspace
  3. Click on "untitled-workspace" to rename your dashboard. set dashboard name
  4. Click "Select machine" and choose your configured Raspberry Pi. select active machine

Configure camera stream widget

  1. Click "+ Add widget" and select "Camera stream". select camera stream widget
  2. In the Camera panel, select camera-1 for "Camera name" and keep "Refresh type" as "Live". select camera component

Configure time series graph widget

  1. Click "+ Add widget" and select "Time series". select time series graph
  2. Set the "Title" to "Traffic" and "Time range (min)" to 30.
  3. Under the Lines section, click "+ Add line". Set "Resource name" to sensor-1, "Capture method" to Readings, "Title" to cars, and "Path" to readings.car. set graph line
  4. Add new lines for bus and person following the same pattern (e.g., "Title": bus, "Path": readings.bus).
  5. Click "Save changes" to view your live camera stream and updating traffic data.

working teleop dashboard


Conclusion & Resources

You have successfully created an edge device capable of real-time object detection and remote monitoring! This project serves as a robust foundation for numerous AI-powered applications. You can expand on this by:

  • Developing a smart city control system with simulated traffic lights using LEDs.
  • Integrating with smart home platforms like Home Assistant.
  • Making your AI system mobile by mounting it on a rover.

The default YOLO-based models can detect a wide range of objects. For a full list, refer to the module's repository. If your project requires different detection capabilities, explore the Hailo Model Zoo or consider retraining a model on a custom dataset.