We have a new guide where we set up and use the AI HAT with a Python Object Detection pipeline. The AI HAT is a really cool piece of hardware but has had a bit rocky software side since launch - this guide hopes to help fix it. We go through the process of implementing your own Python code to run with YOLO object detection on the AI HAT, as well as looking at some cool sample codes we have written for it.
In this guide, we will be exploring how to set up YOLO object detection with the Raspberry Pi AI HAT, and more importantly, learning how to apply this in your Python projects. We will be taking a look at how to install the required hardware and firm…
Struggling to get this going. After I download the GitHub repository, run the install.sh I get a bunch of errors, am I missing something?
/usr/bin/python3: No module named venv.main; ‘venv’ is a package and cannot be directly executed
setup_env.sh: line 80: /home/transpoco/hailo-rpi5-examples/venv_hailo_rpi5_examples/bin/activate: No such file or directory
TAPPAS_POST_PROC_DIR set to /usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes
Sorry to hear that you’re having some issues with getting the AI hat working. With the errors that you’re receiving are you able to post all the content of your terminal so that we can see what commands you have entered and also all of the errors that you’re getting?
transpoco@raspberrypi:~ $ cd hailo-rpi5-examples
transpoco@raspberrypi:~/hailo-rpi5-examples $ ./install.sh
Setting up the environment...
Setting up the environment for hailo-tappas-core...
TAPPAS_VERSION is 3.30.0. Proceeding...
You are not in the venv_hailo_rpi5_examples virtual environment.
Virtual environment does not exist. Creating and activating...
/usr/bin/python3: No module named venv.__main__; 'venv' is a package and cannot be directly executed
setup_env.sh: line 80: /home/transpoco/hailo-rpi5-examples/venv_hailo_rpi5_examples/bin/activate: No such file or directory
TAPPAS_POST_PROC_DIR set to /usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes
DEVICE_ARCHITECTURE is set to: HAILO8
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "/usr/lib/python3/dist-packages/pip/_internal/build_env.py", line 6, in <module>
import pathlib
File "/usr/lib/python3.11/pathlib.py", line 13, in <module>
from urllib.parse import quote_from_bytes as urlquote_from_bytes
ModuleNotFoundError: No module named 'urllib.parse'
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "/usr/lib/python3/dist-packages/pip/_internal/build_env.py", line 6, in <module>
import pathlib
File "/usr/lib/python3.11/pathlib.py", line 13, in <module>
from urllib.parse import quote_from_bytes as urlquote_from_bytes
ModuleNotFoundError: No module named 'urllib.parse'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
rapidjson-dev is already the newest version (1.1.0+dfsg2-7.1).
The following packages were automatically installed and are no longer required:
dkms libwlroots12 linux-headers-6.1.0-28-arm64 linux-headers-6.1.0-28-common
linux-headers-arm64 linux-kbuild-6.1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Downloading HAILO8 models
File ‘./resources/yolov5m_wo_spp.hef’ already there; not retrieving.
File ‘./resources/yolov8m_pose.hef’ already there; not retrieving.
File ‘./resources/yolov8s_pose.hef’ already there; not retrieving.
File ‘./resources/yolov6n.hef’ already there; not retrieving.
File ‘./resources/yolov8s.hef’ already there; not retrieving.
File ‘./resources/yolov5m_seg.hef’ already there; not retrieving.
File ‘./resources/yolov5n_seg.hef’ already there; not retrieving.
File ‘./resources/yolov8m.hef’ already there; not retrieving.
File ‘./resources/yolov8s-hailo8l-barcode.hef’ already there; not retrieving.
File ‘./resources/detection0.mp4’ already there; not retrieving.
File ‘./resources/barcode.mp4’ already there; not retrieving.
Traceback (most recent call last):
File "/usr/bin/meson", line 29, in <module>
from pathlib import Path
File "/usr/lib/python3.11/pathlib.py", line 13, in <module>
from urllib.parse import quote_from_bytes as urlquote_from_bytes
ModuleNotFoundError: No module named 'urllib.parse'
ninja: error: loading 'build.ninja': No such file or directory
ninja: error: loading 'build.ninja': No such file or directory
transpoco@raspberrypi:~/hailo-rpi5-examples $ ^C
transpoco@raspberrypi:~/hailo-rpi5-examples $ cd ..
transpoco@raspberrypi:~ $ python3
Python 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> eof
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'eof' is not defined
>>> EOF
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'EOF' is not defined
>>>
transpoco@raspberrypi:~ $
transpoco@raspberrypi:~ $
transpoco@raspberrypi:~ $ cd hailo-rpi5-examples
transpoco@raspberrypi:~/hailo-rpi5-examples $ dir
basic_pipelines community_projects doc install.sh README.md run_tests.sh
build.release compile_postprocess.sh download_resources.sh LICENSE requirements.txt setup_env.sh
ci.yaml cpp hailort.log meson.build resources tests
transpoco@raspberrypi:~/hailo-rpi5-examples $
I’m now trying to draw a virtual finishline from top to bottom so I can use it for a timing system, but whatever I try, I am not able to render the line on the camera output.
Even (sorry to mention here) ChatGTP cant help me with this :-/
Hey Zach, I’m running into issues running the shell script installer. It gives me the error: metadata-generation-failed and gives the note “This error originates from a subprocess, and is likely not a problem with pip.” Any thoughts? I have never worked with rpi’s before and I am already lost.
seniordesign@raspberrypi:~/hailo-rpi5-examples $ ./install.sh
Sourcing environment variables and activating virtual environment…
Setting up the environment…
Setting up the environment for hailo-tappas-core…
TAPPAS_VERSION is 3.30.0. Proceeding…
You are not in the venv_hailo_rpi5_examples virtual environment.
Virtual environment exists. Activating…
TAPPAS_POST_PROC_DIR set to /usr/lib/aarch64-linux-gnu/hailo/tappas/post_processes
DEVICE_ARCHITECTURE is set to: HAILO8L
Installing additional system dependencies…
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
rapidjson-dev is already the newest version (1.1.0+dfsg2-7.1).
The following package was automatically installed and is no longer required:
libwlroots12
Use ‘sudo apt autoremove’ to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Installing required Python dependencies…
Looking in indexes: Simple index, piwheels - Simple index
Collecting git+https://github.com/hailo-ai/hailo-apps-infra.git (from -r requirements.txt (line 4))
Cloning GitHub - hailo-ai/hailo-apps-infra to /tmp/pip-req-build-3pprx40d
Running command git clone --filter=blob:none --quiet GitHub - hailo-ai/hailo-apps-infra /tmp/pip-req-build-3pprx40d
Resolved GitHub - hailo-ai/hailo-apps-infra to commit a80ab902121fd8e6ef14df34c78b720c82c0294a
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [49 lines of output]
INFO:main:Reading requirements…
INFO:main:Compiling C++ code…
INFO:main:Running command: ./compile_postprocess.sh
Configuring project with Meson…
The Meson build system
Version: 1.0.1
Source dir: /tmp/pip-req-build-3pprx40d
Build dir: /tmp/pip-req-build-3pprx40d/build.release
Build type: native build
Project name: hailo_rpi5_examples
Project version: 1.1.1
C compiler for the host machine: cc (gcc 12.2.0 “cc (Debian 12.2.0-14) 12.2.0”)
C linker for the host machine: cc ld.bfd 2.40
C++ compiler for the host machine: c++ (gcc 12.2.0 “c++ (Debian 12.2.0-14) 12.2.0”)
C++ linker for the host machine: c++ ld.bfd 2.40
Host machine cpu family: aarch64
Host machine cpu: aarch64
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Run-time dependency hailo-tappas-core found: YES 3.30.0
Build targets in project: 4
hailo_rpi5_examples 1.1.1
User defined options
buildtype: release
Found ninja-1.11.1 at /usr/bin/ninja
Generating targets: 0%| | 0/4 [00:00<?, ?it/s]
Writing build.ninja: 0%| | 0/36 [00:00<?, ?it/s]
Building project with Ninja...
[1/8] Compiling C++ object cpp/libremove_labels.so.p/remove_labels.cpp.o
[2/8] Linking target cpp/libremove_labels.so
[3/8] Compiling C++ object cpp/libyolo_hailortpp_postprocess.so.p/yolo_hailortpp.cpp.o
FAILED: cpp/libyolo_hailortpp_postprocess.so.p/yolo_hailortpp.cpp.o
c++ -Icpp/libyolo_hailortpp_postprocess.so.p -Icpp -I../cpp -I/usr/include/hailo/tappas -I/usr/include/hailo/tappas/gsthailometa -I/usr/include/hailo/tappas/general -I/usr/include/hailo/tappas/plugins/common -I/usr/include/hailo/tappas/tracking -I/usr/include/hailo/tappas/sources/Catch2/include -I/usr/include/hailo/tappas/sources/cxxopts/include -I/usr/include/hailo/tappas/sources/pybind11/include -I/usr/include/hailo/tappas/sources/rapidjson/include -I/usr/include/hailo/tappas/sources/xtensor-blas/include -I/usr/include/hailo/tappas/sources/xtensor/include -I/usr/include/hailo/tappas/sources/xtl/include -I/usr/include/hailo/ -I/usr/include/gstreamer-1.0/gst/hailo/ -I/usr/include/opencv4 -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -I/usr/include/aarch64-linux-gnu -fvisibility=default -fdiagnostics-color=always -Wall -Winvalid-pch -std=c++17 -O3 -Wno-psabi -Wno-class-memaccess -Wno-deprecated-declarations -fPIC -fvisibility=default -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -Wpessimizing-move -Wredundant-move -fconcepts -fPIC -pthread -isystem/usr/include/hailo/tappas/sources/rapidjson/include -MD -MQ cpp/libyolo_hailortpp_postprocess.so.p/yolo_hailortpp.cpp.o -MF cpp/libyolo_hailortpp_postprocess.so.p/yolo_hailortpp.cpp.o.d -o cpp/libyolo_hailortpp_postprocess.so.p/yolo_hailortpp.cpp.o -c ../cpp/yolo_hailortpp.cpp
In file included from ../cpp/yolo_hailortpp.cpp:12:
../cpp/hailo_nms_decode.hpp: In constructor ‘HailoNMSDecode::HailoNMSDecode(HailoTensorPtr, std::map<unsigned char, std::__cxx11::basic_string<char> >&, float, uint, bool)’:
../cpp/hailo_nms_decode.hpp:68:78: error: ‘HAILO_FORMAT_ORDER_HAILO_NMS_BY_CLASS’ was not declared in this scope; did you mean ‘HAILO_FORMAT_ORDER_HAILO_NMS’?
68 | if ((HAILO_FORMAT_ORDER_HAILO_NMS != _vstream_info.format.order) && (HAILO_FORMAT_ORDER_HAILO_NMS_BY_CLASS != _vstream_info.format.order))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| HAILO_FORMAT_ORDER_HAILO_NMS
[4/8] Compiling C++ object cpp/libyolov8pose_postprocess.so.p/yolov8pose_postprocess.cpp.o
[5/8] Compiling C++ object cpp/libyolov5seg_postprocess.so.p/yolov5seg.cpp.o
ninja: build stopped: subcommand failed.
ERROR:__main__:Failed to compile C++ code. Exit code: 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
When developing the guide I tried to draw elements on the camera preview window but had very little success with it (even using ChatGPT AND Claude). A lot of the camera preview is handled by something called gstreamer and is very deeply embedded in the Pipeline. If ChatGPT had any chance of doing it, you would need to paste in all the pipeline scripts as well as your main file.
Another option may be to create your own camera preview window to draw elements over, but I also ran into issues as the pipeline doesn’t seem to handle sharing the camera at all.
Another solution may be to use something like OpenCV to draw your own version of it all without the camera preview. You could create a window, draw the line, and then use the location data (which we extract in the 3rd example), to draw the location of the detected objects without the camera. If you dig deeper into the output data, you will also find the bounding box that is drawn around the object, and you could pair this with the labels of the object to essentially recreate the window, but without the camera feed.
It may not be what you are after but is probably the most achievable.
I just followed the guide instructions (incase Hailo has released an update that broke the installation), and I managed to install it. I haven’t seen that error message before and it looks like a bit of a curveball. Right now my only recommendation is to maybe try it on a fresh installation of Bookworm OS, and follow the steps in the written guide to the tee. Its very easy to miss a command or step in these things.
I had already tried again after reading that it fixed the error that Vincent ran into and I ran into the same errors again, I will try again though and let you know. Just to simplify the steps I want to verify them: I hook the sd card into my reader to my computer, I flash the os onto it using the pi imager, then I eject and insert the sd card into the raspberry pi 5, I then hook the pi 5 into the display and power cord. It then boots up (after a couple cycles of on and off) then does the normal setup. I then open the terminal and type in “sudo apt update && sudo apt full-upgrade” after this it will then say no updates available and then type in “sudo apt install hailo-all” and then after that I reboot. Then I type “git clone GitHub - hailo-ai/hailo-rpi5-examples” and have a new directory titled rpi5-examples in my files. Next I change the directory to work in with the command “cd hailo-rpi5-examples” and then type in “./install.sh”. This is where the issue always seems to arise so I won’t list out the further steps. Please let me know if I missed any steps along the way.
And also to give an idea on what I am attempting to do: a golf cart that follows a human being using AI detection and UWB distance measuring, UWB will be running constantly and feeding serial data into the pi 5, the camera will detect where the person is in the frame (objective is to be at x=0.5 at the center of the frame, thus the cart will be pointed at the person) and find the difference of that value and 0.5, with these 2 variables (distance and x coordinate of the frame) use a lookup table to send a precoded pwm signal to each of 2 drive motors to steer and drive towards the person it is following.
That is exactly the correct steps, let us know how it goes.
Also sounds like you have a great project on your hands, very creative combination of ultra wide band and machine vision. I trust you already have you ducks in a row and have some safety procedures in place so there are no golf cart hit and runs. Awesome project though, a real testament to what you can do with maker hardware nowadays!
It looks like they updated the GitHub code yesterday (1-19-2025), and none of the “custom” codes (e.g., example code 1, example code 2, and example code 3) are working anymore.
When starting, the terminal closes instantly without showing any errors.
All other original code is working fine.
They even have a new video for the detection.py
I hate to say it but that’s reassuring to me at least I’m not the only one running into the problem I posted about (even though it’s a different problem it might be the cause for my error). I’m trying some workarounds for my error right now, I’m reflashing the os with pi os full (with some apps preinstalled) and with the ssh turned on in the settings to hopefully allow me to run the shell without spitting an error at me. I’ll let you and jaryd know how it goes in a couple of minutes.
Traceback (most recent call last):
File “/home/leon/hailo-rpi5-examples/basic_pipelines/watcher3.py”, line 8, in
ModuleNotFoundError: No module named ‘hailo_rpi_common’