Skip to content

Commit

Permalink
Merge pull request #11 from jwillikers/hailo2
Browse files Browse the repository at this point in the history
Add support for using the Raspberry Pi AI accelerator
  • Loading branch information
jwillikers authored Oct 28, 2024
2 parents 3cfeb0d + da5fb33 commit bebb299
Show file tree
Hide file tree
Showing 14 changed files with 506 additions and 274 deletions.
10 changes: 6 additions & 4 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ init-dev: && sync
set -euxo pipefail
distro=$(awk -F= '$1=="ID" { print $2 ;}' /etc/os-release)
if [ "$distro" = "debian" ]; then
sudo apt-get --yes install ffmpeg libatlas-base-dev python3-dev python3-picamera2 python3-venv
sudo apt-get --yes install ffmpeg hailo-all libatlas-base-dev python3-dev python3-picamera2 python3-venv
fi
[ -d venv ] || python -m venv --system-site-packages venv
venv/bin/python -m pip install --requirement requirements-dev.txt
Expand All @@ -66,11 +66,13 @@ install-system: init
sudo cp xmp_utils.py /usr/local/bin/xmp_utils.py
sudo chown root:root /usr/local/bin/xmp_utils.py
sudo mkdir --parents /usr/local/etc/detectionator/
sudo cp config/fast-and-close-config.toml /usr/local/etc/detectionator/config.toml
sudo cp config/hailo-config.toml /usr/local/etc/detectionator/config.toml
sudo chown --recursive root:root /usr/local/etc/detectionator
sudo mkdir --parents /usr/local/share/detectionator/
sudo cp --recursive models /usr/local/share/detectionator/models
sudo cp models/* /usr/local/share/detectionator/models
sudo chown --recursive root:root /usr/local/share/detectionator
sudo mkdir /var/log/detectionator
sudo chown detectionator:detectionator /var/log/detectionator
sudo -H -u detectionator bash -c '[ -d /home/detectionator/venv ] || python -m venv --system-site-packages /home/detectionator/venv'
sudo -H -u detectionator bash -c '/home/detectionator/venv/bin/python -m pip install --requirement requirements.txt'
sudo systemctl enable detectionator.service
Expand All @@ -80,7 +82,7 @@ install-user: init
[ -d venv ] || python -m venv --system-site-packages venv
venv/bin/python -m pip install --requirement requirements.txt
mkdir --parents {{ config_directory() }}/detectionator
cp config/fast-and-close-config.toml {{ config_directory() }}/detectionator/config.toml
cp config/hailo.toml {{ config_directory() }}/detectionator/config.toml
mkdir --parents {{ config_directory() }}/systemd/user
ln --force --relative --symbolic etc/systemd/user/* {{ config_directory() }}/systemd/user/
systemctl --user daemon-reload
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"gpsdctl",
"grayscale",
"gstreamer",
"hailo",
"hynix",
"Hyperpixel",
"ifdef",
Expand Down
6 changes: 3 additions & 3 deletions LICENSE.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= GNU General Public License

_Version 3, 29 June 2007_
_Copyright © 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;_
_Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>_

Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Expand Down Expand Up @@ -584,11 +584,11 @@ for a GUI interface, you would use an “about box”.
You should also get your employer (if you work as a programmer) or school, if any, to
sign a “copyright disclaimer” for the program, if necessary. For more
information on this, and how to apply and follow the GNU GPL, see
&lt;<http://www.gnu.org/licenses/>&gt;.
<http://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may consider it
more useful to permit linking proprietary applications with the library. If this is
what you want to do, use the GNU Lesser General Public License instead of this
License. But first, please read
&lt;<http://www.gnu.org/philosophy/why-not-lgpl.html>&gt;.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
2 changes: 2 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The project is largely based off of the tensorflow example in the {picamera2} pr

The Detectionator is based off of the Raspberry Pi 5 and the Camera Module 3.
It incorporates a GPS HAT for the Raspberry Pi to obtain the geolocation data to embed in the photographs.
The Raspberry Pi AI Kit is recommended, as it reduces the CPU usage dramatically on the Pi.

[NOTE]
====
Expand All @@ -66,6 +67,7 @@ The https://www.samsung.com/us/computing/memory-storage/memory-cards/pro-ultimat
This is 4 17mm M2.5 Hex socket-socket standoffs and 8 6mm M2.5 screws.
* https://shop.pimoroni.com/products/booster-header?variant=47414520906[Booster Header]
This header has a standard 8.5mm height with 5mm tall pins.
* https://www.raspberrypi.com/products/ai-kit/[Raspberry Pi AI Kit] This is component is optional.

[TIP]
====
Expand Down
2 changes: 1 addition & 1 deletion config/fast-and-close-config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This config template is tweaked for capturing fast-moving creatures, such as birds.
# Note that without global shutter, there can be distortions in the image when the creature is moving quickly.
# Rolling shutter also makes it more diffult to successfully detect fast-moving objects.
# Rolling shutter also makes it more difficult to successfully detect fast-moving objects.
[detectionator]

# Capture several photographs upon a successful detection.
Expand Down
43 changes: 43 additions & 0 deletions config/hailo-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This config template is tweaked for capturing fast-moving creatures, such as birds.
# Note that without global shutter, there can be distortions in the image when the creature is moving quickly.
# Rolling shutter also makes it more difficult to successfully detect fast-moving objects.
[detectionator]

# Capture several photographs upon a successful detection.
# Re-running the detection algorithm before taking another photograph may lead to a considerable delay before another picture.
burst = 1

# Use the exact ratio for the Hailo chip.
align_resolutions = false

# Focus the lens on the closest part of the range.
# todo Test how well the Macro range works.
# autofocus-range = "macro"
autofocus-range = "full"

autofocus-mode = "auto"

# Focus the lens as quickly as possible.
autofocus-speed = "fast"

detection-threshold = 0.4

encoder-quality = "high"

focal-detection-threshold = 0.25

# capture-mode = "video"
#stream = "mediamtx.lan.jwillikers.io:8554/detectionator"
#rtsp-tcp = false

# Don't use a gap after a successful detection but start searching again immediately.
gap = 0

hailo = true

# Below are standard options.
label = "/usr/local/share/detectionator/models/coco_labels_hailo.txt"
log-level = "info"
match = ["bird", "bear", "cat", "cow", "dog", "elephant", "giraffe", "horse", "sheep", "zebra"]
model = "/usr/share/hailo-models/yolov8s_h8l.hef"
output = "~/Pictures"
Loading

0 comments on commit bebb299

Please sign in to comment.