reComputerで顔認識を展開する
はじめに
このwikiでは、Hailo NPUを搭載したreComputerを使用してリアルタイム顔認識を実装する方法をガイドします。このプロジェクトでは、効率的な顔検出のためにSCRFD-10Gを使用し、小さな顔を含む様々なスケールの顔を迅速かつ正確に検出し、リアルタイム性能を確保します。同時に、軽量な顔認識のためにArcFace-MobileFaceNetモデルを採用し、ArcFace損失関数を活用して認識精度を向上させ、効率的な身元確認を可能にします。
ハードウェアの準備
注意:入力としてUSBカメラが必要です。
Hailoソフトウェアのインストールと確認
システムの更新
sudo apt update
sudo apt full-upgrade
更新中に以下の問題が発生することがあります。
Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:4 http://archive.raspberrypi.com/debian bookworm InRelease [39.0 kB]
Reading package lists... Done
E: Release file for http://deb.debian.org/debian/dists/bookworm/InRelease is not valid yet (invalid for another 58d 8h 26min 35s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian-security/dists/bookworm-security/InRelease is not valid yet (invalid for another 84d 18h 23min 59s). Updates for this repository will not be applied.
E: Release file for http://archive.raspberrypi.com/debian/dists/bookworm/InRelease is not valid yet (invalid for another 84d 13h 13min 5s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/bookworm-updates/InRelease is not valid yet (invalid for another 85d 0h 52min 29s). Updates for this repository will not be applied.
これはRaspberry Piの時刻が正しく設定されていないためです。以下のコマンドでRaspberry Piの時刻を手動で設定する必要があります:
# This command only you can connect google.com
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
Raspberry Piの時刻を設定した後、Raspberry Piを更新できます。
PCIeをgen2/gen3に設定(gen3はgen2より高速)
/boot/firmware/config.txtに以下のテキストを追加します
#Enable the PCIe external connector
dtparam=pciex1
#Force Gen 3.0 speeds
dtparam=pciex1_gen=3
gen2を使用したい場合は、dtparam=pciex1_gen=3をコメントアウトしてください
hailo-allのインストールと再起動
Raspberry Pi5でターミナルを開き、以下のコマンドを入力してHailoソフトウェアをインストールします。
sudo apt install hailo-all
sudo apt-get -y install libblas-dev nlohmann-json3-dev
sudo reboot
ソフトウェアとハードウェアの確認
Raspberry Pi5でターミナルを開き、以下のコマンドを入力してhailo-allがインストールされているかを確認します。
hailortcli fw-control identify
正しい結果は以下のように表示されます:

Raspberry Pi5でターミナルを開き、以下のコマンドを入力してhailo-8Lが接続されているかを確認します。
lspci | grep Hailo
正しい結果は以下のように表示されます:

プロジェクトの実行
プロジェクトのインストール
cd ~ && git clone https://github.com/Seeed-Projects/hailo-apps-infra
cd hailo-apps-infra
./install.sh
source venv_hailo_apps/bin/activate
写真の追加
cd /resources/face_recon/train
# change name to the name of the person to be recognized
mkdir name
注意:認識対象の人物の写真を、作成したフォルダに配置してください。
データベースへの情報追加
cd ~/hailo-apps-infra/hailo_apps/hailo_app_python/apps/face_recognition
python face_recognition.py --mode train
正しい結果は以下のように表示されます:

プロジェクトの実行
以下のコマンドを入力すると、顔認識デモが表示されます:
python face_recognition.py --input usb
結果
技術サポートと製品ディスカッション
弊社製品をお選びいただき、ありがとうございます!弊社製品での体験が可能な限りスムーズになるよう、さまざまなサポートを提供しています。異なる好みやニーズに対応するため、複数のコミュニケーションチャンネルを提供しています。

