Review: I tried making an AI camera by attaching the retrofit AI processing module 'Raspberry Pi AI HAT +' to the Raspberry Pi 5
The '
AI HAT+ - Raspberry Pi Documentation
https://www.raspberrypi.com/documentation/accessories/ai-hat-plus.html
AI software - Raspberry Pi Documentation
https://www.raspberrypi.com/documentation/computers/ai.html
hailo-rpi5-examples/doc/basic-pipelines.md at main · hailo-ai/hailo-rpi5-examples · GitHub
https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/basic-pipelines.md
·table of contents
◆1: Checking the appearance of the Raspberry Pi AI HAT+
◆2: Attach the Raspberry Pi AI HAT+ to the Raspberry Pi 5
3. Build an environment for running AI cameras
◆4: Run the official Raspberry Pi AI camera demo
◆5: Hailo's AI camera demo
◆1: Checking the appearance of the Raspberry Pi AI HAT+
The Raspberry Pi AI HAT + package looks like this. The Raspberry Pi AI HAT + comes in two models with AI processing capabilities: 13 TOPS and 26 TOPS. This time, the 26 TOPS model was sent to me by the Raspberry Pi development team.
The package contained the Raspberry Pi AI HAT+ itself, a GPIO stacking header, spacers, and screws.
This is the Raspberry Pi AI HAT+.
The back looks like this.
In the center is the Hailo-8 AI accelerator. The 13TOPS model is equipped with the Hailo-8L .
◆2: Attach the Raspberry Pi AI HAT+ to the Raspberry Pi 5
To create the AI camera, we prepared the 'Raspberry Pi AI HAT+', 'Raspberry Pi 5', and 'Raspberry Pi Camera Module 3'. When installing the Raspberry Pi AI HAT+, it is recommended to attach the official air-cooled '
First, boot up your Raspberry Pi 5 and update the software and firmware.
First, update your software to the latest version.
[code]sudo apt update
sudo apt upgrade[/code]
Next, update the EEPROM firmware. Execute the following command to check the current version and the latest version available.
[code]sudo rpi-eeprom-update[/code]
The execution result is as follows. If the firmware is a version earlier than December 6, 2023, you will need to change the settings according to
*** UPDATE AVAILABLE ***
BOOTLOADER: update available
CURRENT: Wed 17 Apr 12:54:23 UTC 2024 (1713358463)
LATEST: Mon 23 Sep 13:02:56 UTC 2024 (1727096576)
RELEASE: default (/lib/firmware/raspberrypi/bootloader-2712/default)
Use raspi-config to change the release.
Update the firmware with the following command and reboot:
[code]sudo rpi-eeprom-update -a
sudo reboot[/code]
Once it boots up successfully, shut down the Raspberry Pi 5 and move on to installing the Raspberry Pi AI HAT+. First, attach the spacer and GPIO stacking header to the Raspberry Pi 5. The screws were made of plastic, so be careful not to screw them in too tightly.
Next, connect the Raspberry Pi AI HAT+ with a ribbon cable.
Secure with four screws.
Next, connect the Raspberry Pi Camera Module 3.
Finally, you need to fix the camera in place and you're ready to go. In this case, I simply stuck it to an empty box.
◆3: Building an environment for running AI cameras
Switch to PCIe Gen 3.0
The Raspberry Pi 5 runs on PCIe Gen 2.0 by default, but it can be switched to PCIe Gen 3.0. It is recommended to switch to PCIe Gen 3.0 when using the Raspberry Pi AI HAT+.
To run it on PCIe Gen 3.0, just add the following line to ' /boot/firmware/config.txt '.
[code]dtparam=pciex1_gen=3[/code]
After you edit the configuration file, reboot.
[code]sudo reboot[/code]
・Install the required packages
To install the AI accelerator drivers, run the following command and then reboot.
[code]sudo apt install hailo-all
sudo reboot[/code]
・Check if the installation was successful
To check if the Raspberry Pi AI HAT+ is installed and the software is installed correctly, run the following command.
[code]hailortcli fw-control identify[/code]
It's OK if the firmware version and the name of the AI accelerator are output as shown below. The document also displayed the serial number and product name, but this time '
Executing on device: 0000:01:00.0
Identifying board
Control Protocol Version: 2
Firmware Version: 4.18.0 (release,app,extended context switch buffer)
Logger Version: 0
Board Name: Hailo-8
Device Architecture: HAILO8
Serial Number:
Part Number:
Product Name:
You can also check for AI accelerator-related events in the kernel log with the following command:
[code]dmesg | grep -i hailo[/code]
The results this time were something like this.
[ 3.884998] hailo: Init module. driver version 4.18.0
[ 3.885122] hailo 0000:01:00.0: Probing on: 1e60:2864...
[ 3.885127] hailo 0000:01:00.0: Probing: Allocate memory for device xtension, 11632
[ 3.885144] hailo 0000:01:00.0: enabling device (0000 -> 0002)
[ 3.885150] hailo 0000:01:00.0: Probing: Device enabled
[ 3.885168] hailo 0000:01:00.0: Probing: mapped bar 0 - 0000000b494ee36 16384
[ 3.885175] hailo 0000:01:00.0: Probing: mapped bar 2 - 00000000f43891e 4096
[ 3.885181] hailo 0000:01:00.0: Probing: mapped bar 4 - 00000001f13937c 16384
[ 3.885185] hailo 0000:01:00.0: Probing: Force setting ax_desc_page_size to 4096 (recommended value is 16384)
[ 3.885195] hailo 0000:01:00.0: Probing: Enabled 64 bit dma
[ 3.885198] hailo 0000:01:00.0: Probing: Using userspace allocated dma buffers
[ 3.885201] hailo 0000:01:00.0: Disabling ASPM L0s
[ 3.885206] hailo 0000:01:00.0: Successfully disabled ASPM L0s
[ 4.171121] hailo 0000:01:00.0: Firmware was loaded successfully
[ 4.184529] hailo 0000:01:00.0: Probing: Added board 1e60-2864, /dev/hailo0
You can check whether the camera module is recognized by using the following command.
[code]rpicam-hello -t 10s[/code]
It's OK if the 'window displaying camera footage' is displayed for 10 seconds.
◆4: Run the official Raspberry Pi AI camera demo
Next, let's try running the AI camera demo released by the Raspberry Pi development team. First, clone the latest commit of the repository containing the demo with the following command.
[code]git clone --depth 1 https://github.com/raspberrypi/rpicam-apps.git ~/rpicam-apps[/code]
Once the cloning is complete, run the following command to start the 'camera AI that identifies object types.'
[code]rpicam-hello -t 0 --post-process-file ~/rpicam-apps/assets/hailo_yolov6_inference.json --lores-width 640 --lores-height 640[/code]
The execution result looks like this. The person and laptop in the camera are correctly recognized.
However, the terminal displays an error message saying, 'This AI model was created for the Hailo-8L, but this device is equipped with a Hailo-8. This will not provide optimal performance.' It was done.
◆5: Run Hailo's AI camera demo
At the time of writing, the only official demo available from the Raspberry Pi development team was the 'AI model for Hailo-8L,' so we decided to use
When checking the source code of ' hailo-rpi5-examples/basic_pipelines/detection_pipeline.py ' included in the demo, it says 'If the system is equipped with Hailo-8, load 'yolov8m.hef', and if the system is equipped with Hailo-8L, load 'yolov8m.hef'. You can see that it contains the code 'load 'yolov8s_h8l.hef' when the program is started.' In other words, by running this demo, you can fully demonstrate the capabilities of Hailo-8, which has a processing performance of 26 TOPS.
First, clone the repository, install the required packages, and then run the installation script:
[code]git clone https://github.com/hailo-ai/hailo-rpi5-examples.git
cd hailo-rpi5-examples
sudo apt install meson
./install.sh[/code]
Once the installation is complete, you can run the object recognition camera AI included in the Hailo demo by running the following command.
[code]source setup_env.sh
python basic_pipelines/detection.py -i rpi[/code]
The execution result looks like this. Humans and smartphones were correctly recognized.
By adding the '-f' option to the command, the frame rate per second will be displayed on the screen.
[code]python basic_pipelines/detection.py -i rpi -f[/code]
The average frame rate per second was 30.04 FPS.
Below is a video recording of how the object recognition camera AI works. By using Raspberry Pi AI HAT +, you can experience and develop AI functions like this.
I tried turning Raspberry Pi 5 into an AI camera by attaching 'Raspberry Pi AI HAT +' - YouTube
Related Posts: