Skip to main content

Frigate NVR 和 Hailo 在 reComputer R2000 上连接 Home Assistant

介绍

Frigate NVR 是一个专为使用 AI 模型进行实时物体检测而设计的开源网络视频录像机(NVR)。它轻量级、功能强大,并通过 RTSP 协议与摄像头无缝协作。

Home Assistant(HA)是一个开源的智能家居自动化平台,让您能够控制和自动化家中的设备。

在本指南中,我们将引导您了解如何在配备 Hailo PCIereComputer AI 盒子上安装 Frigate,以及如何使用 MQTT 将其连接到您现有的 Home Assistant 设置,操作简单便捷。

先决条件

硬件要求

reComputer AI Industrial R2000reComputer AI R2000

安装 Hailo PCIe 驱动程序

步骤 1:Raspberry Pi 配置

sudo apt update
sudo raspi-config
  • 导航到 6 Advanced Options > A8 PCIe Speed
  • 选择 Yes 启用 PCIe Gen 3
  • 退出并选择 Finish

/boot/firmware/config.txt 文件末尾添加以下行:

dtoverlay=pciex1-compat-pi5,no-mip

Step 2: Install PCIe Driver

sudo apt update
sudo apt install dkms
git clone https://github.com/hailo-ai/hailort-drivers
cd hailort-drivers/linux/pcie
git checkout 24e7ff2fb58fab7029024c1a1d3f2d1914f56d7b
sudo make install_dkms

Step 3: Install Firmware

cd ../..
./download_firmware.sh
sudo mkdir -p /lib/firmware/hailo
sudo cp hailo8_fw*.bin /lib/firmware/hailo/hailo8_fw.bin

步骤 4:修复 PCIe 描述符大小问题

创建 /etc/modprobe.d/hailo_pci.conf 文件,内容如下:

options hailo_pci force_desc_page_size=4096

Step 5: Reboot and Verify

sudo reboot
ls /dev/hailo*

Expected output:

/dev/hailo0

使用 Docker 安装 Frigate NVR

前提条件

确保您的摄像头已配置为 1920x1080 分辨率的 RTSP 流。

更新系统

sudo apt update

Install Docker

curl -fsSL get.docker.com | bash
sudo usermod -aG docker $USER
sudo reboot

Pull Frigate Image

docker pull ghcr.io/blakeblackshear/frigate:0.15.0-rc2-h8l

Create Directory Structure

mkdir -p ~/frigate/config
mkdir -p ~/frigate/data/db
mkdir -p ~/frigate/data/storage
cd ~/frigate

Create Docker Compose File (frigate.yml)

nano frigate.yml
services:
frigate-hailo:
container_name: frigate-hailo
privileged: true
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:0.15.0-rc2-h8l
shm_size: 1024mb
devices:
- /dev/hailo0:/dev/hailo0
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config/:/config
- ./data/db/:/data/db
- ./data/storage:/media/frigate
- type: tmpfs
target: /tmp/cache
tmpfs:
size: 1g
ports:
- 5000:5000

Create Frigate Config File (config/config.yml)

nano config/config.yml
database:
path: /data/db/frigate.db

go2rtc:
streams:
home:
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0

cameras:
home:
ffmpeg:
inputs:
- path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
roles:
- record
- detect

mqtt:
enabled: False

objects:
track:
- person
- cat

detectors:
hailo8l:
type: hailo8l
device: PCIe

model:
width: 300
height: 300
model_type: ssd
path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef

version: 0.15-1

Start Frigate

docker compose -f frigate.yml up -d

访问 Web UI

访问:http://<your-device-ip>:5000

Home Assistant 集成

步骤 1:HACS 设置

假设您正在运行 Home Assistant(HA Green、HA Yellow 或类似的独立设备):

  • 如果尚未安装,请安装 HACS
  • 在 HACS 中,从社区商店安装 Frigate 集成

使用您的 Frigate AI 盒子的 IP 地址和端口进行配置

步骤 2:安装 MQTT 插件

按照 官方 MQTT 集成指南 安装和配置 MQTT 代理插件。

步骤 3:更新 Frigate 配置以支持 MQTT

mqtt:
host: <HA IP>
port: 1883
topic_prefix: frigate
client_id: frigate
user: <HA User Name>
password: <HA Password>

Example:

mqtt:
host: 10.0.0.136
port: 1883
topic_prefix: frigate
client_id: frigate
user: kasun
password: HiezenburgCook

full example :

database:
path: /data/db/frigate.db

go2rtc:
streams:
home:
- rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0

cameras:
home:
ffmpeg:
inputs:
- path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
roles:
- record
- detect

mqtt:
host: core-mosquitto
port: 1883
topic_prefix: frigate
client_id: frigate
user: kasun
password: HiezenburgCook

objects:
track:
- person
- cat

detectors:
hailo8l:
type: hailo8l
device: PCIe

model:
width: 300
height: 300
model_type: ssd
path: /config/model_cache/h8l_cache/ssd_mobilenet_v1.hef

version: 0.15-1


Step 4: Restart Frigate

docker compose -f frigate.yml down
sudo docker compose -f frigate.yml up -d

步骤 5:确认 MQTT 正常工作(可选)

  • 检查 HA 日志或 MQTT 插件日志以验证来自 Frigate 的消息
  • 在 HA 中,您现在可以在自动化中使用 Frigate 事件,例如运动警报、检测到的对象等。

技术支持与产品讨论

感谢您选择我们的产品!我们在这里为您提供不同的支持,以确保您使用我们产品的体验尽可能顺畅。我们提供多种沟通渠道,以满足不同的偏好和需求。

Loading Comments...