接続するカメラは RTSP 配信機能があるものがよい。USB 接続の Web カメラも使えるようだが Frigate では試してはいない。 Shinobi の環境を作って v4l2loopback を使って Web カメラを使ったときは CPU 負荷が常時 20% 超えるようになってしまった。 RTSP 対応カメラは TP-Link 社の Tapo シリーズ や ATOM 社の ATOM シリーズ がおすすめ。今回は Tapo C120 を使った。
# version: "3.9"services:frigate:container_name:frigate-ipcam-station# privileged: true # this may not be necessary for all setupsrestart:unless-stoppedstop_grace_period:30s# allow enough time to shut down the various servicesimage:ghcr.io/blakeblackshear/frigate:stableshm_size:"512mb"# update for your cameras based on calculation abovedevices:# - /dev/bus/usb:/dev/bus/usb # Passes the USB Coral, needs to be modified for other versions# - /dev/apex_0:/dev/apex_0 # Passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux# - /dev/video11:/dev/video11 # For Raspberry Pi 4B-/dev/dri/renderD128:/dev/dri/renderD128# For intel hwaccel, needs to be updated for your hardwarevolumes:-/etc/localtime:/etc/localtime:ro-./config:/config-./media:/media/frigate-type:tmpfs# Optional: 1GB of memory, reduces SSD/SD Card weartarget:/tmp/cachetmpfs:size:1000000000ports:-"8971:8971"-"5000:5000"# Internal unauthenticated access. Expose carefully.# - "8554:8554" # RTSP feeds-"8555:8555/tcp"# WebRTC over tcp-"8555:8555/udp"# WebRTC over udpenvironment:FRIGATE_RTSP_PASSWORD:"password"
Compose 設定は公式の記述を元にした。 以下、Compose 設定についての説明。
# privileged: true # this may not be necessary for all setups
privileged フラグは有効にせず動いたので無効にしておく。
shm_size:"512mb"# update for your cameras based on calculation above
devices:# - /dev/bus/usb:/dev/bus/usb # Passes the USB Coral, needs to be modified for other versions# - /dev/apex_0:/dev/apex_0 # Passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux# - /dev/video11:/dev/video11 # For Raspberry Pi 4B-/dev/dri/renderD128:/dev/dri/renderD128# For intel hwaccel, needs to be updated for your hardware
ハードウェアアクセラレータの設定。 USB Coral, PCIe Coral は Google Edge TPU(Tensor Processing Unit) を載せたデバイスで、TensorFlow という機械学習用の演算デバイスのこと。 Frigate は機械学習で物体検出を行っていて、Google Edge TPU での演算に対応している。 NASync であれば USB タイプか M.2 タイプのデバイスを繋げば有効にできるが、持っていないので無効にする。 NASync は、Google Edge TPU のドライバーがインストールされておらずデバイスが読み込まれないので無効にする。 renderD128 はおそらく Intel 内蔵 GPU のこと。コメントアウトしたら CPU 使用率が数パーセント上がってしまったので有効にしておく。
-type:tmpfs# Optional: 1GB of memory, reduces SSD/SD Card weartarget:/tmp/cachetmpfs:size:1000000000
映像処理用のキャッシュ領域。メモリに余裕があれば有効にしておく。
ports:-"8971:8971"-"5000:5000"# Internal unauthenticated access. Expose carefully.# - "8554:8554" # RTSP feeds-"8555:8555/tcp"# WebRTC over tcp-"8555:8555/udp"# WebRTC over udp
mqtt:enabled:Falsecameras:home_cam:# <------ Name the cameraenabled:Trueffmpeg:inputs:-path:rtsp://frigate:passwrd/stream1# <----- The stream you want to use for detectionroles:-detectdetect:enabled:False# <---- disable detection until you have a working camera feedwidth:1280height:720
mqtt:enabled:Falsecameras:home_cam:# <------ Name the cameraenabled:trueffmpeg:inputs:-path:rtsp://frigate:passwrd@192.168.56.120/stream1# <----- The stream you want to use for detectionroles:-record# <-- record に変更# record セクションを追加# 設定内容: https://docs.frigate.video/configuration/record/record:enabled:Trueretain:days:14# <-- 録画データ保持日数を指定#detect:# enabled: false # <---- disable detection until you have a working camera feed# width: 1280# height: 720
// TestScript.csusingSystem.Windows.Forms;using LibCli;namespace Test{ public classTestScript: IScript{ public boolExecute(){MessageBox.Show("プロ生ちゃんマジ天使!");returntrue;}}}