1. 前言
Frigate 是一个基于Docker的开源网络视频录像机(NVR),能够监控和检测摄像头视频流中的物体。在这篇文章中,我将介绍如何在树莓派5上部署Frigate,并使用CPU进行检测。
- https://docs.frigate.video/
2. 准备工作
硬件要求:
- 树莓派5
- 摄像头(例如,海康威视摄像头)
软件要求:
- 最新的Raspberry Pi OS
- Docker和Docker Compose
3. 安装和配置
1. 更新系统
在开始之前,确保你的树莓派系统已更新:
sudo apt update
sudo apt upgrade
2. 安装Docker
通过以下命令安装Docker和Docker Compose:
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose
3. 配置Frigate
创建Frigate的配置文件夹和文件:
mkdir -p /home/user/frigate/config
nano /home/user/frigate/config/config.yml
在config.yml中添加摄像头配置:
mqtt:
enabled: false
detectors:
cpu1:
type: cpu
cameras:
living_room:
enabled: true
ffmpeg:
inputs:
- path: rtsp://admin:passw0rd@192.168.100.113:554/Streaming/Channels/101 # 根据自己的视频流进行填写
roles:
- detect
version: 0.14
4. 配置Docker Compose
在/home/user/frigate目录下创建docker-compose.yml文件:
version: "3.9"
services:
frigate:
container_name: frigate
privileged: true
restart: unless-stopped
image: ghcr.io/blakeblackshear/frigate:stable
shm_size: "128mb"
volumes:
- /etc/localtime:/etc/localtime:ro
- /home/user/frigate/config:/config
- /home/user/frigate/storage:/media/frigate
- /home/user/frigate/storage/cache:/tmp/cache
ports:
- "5000:5000"
- "8554:8554"
- "8555:8555/tcp"
- "8555:8555/udp"
environment:
FRIGATE_RTSP_PASSWORD: "password"
5. 启动Frigate
运行以下命令启动Frigate:
sudo docker-compose up -d
5. 访问Frigate界面
在浏览器中输入树莓派的IP地址加端口号(如http://192.168.1.166:5000)来访问Frigate的用户界面。