0.14.1 initial dayglo
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
BASEDIR=data
|
||||||
|
STORAGEDIR=data/frigate/storage
|
||||||
|
YOLO_MODELS="yolov7-320"
|
||||||
|
|
||||||
|
FRIGATE_MQTT_USER="frigate"
|
||||||
|
FRIGATE_MQTT_PASSWORD="yoQuegBedIrgOamsalrekFogrocThy"
|
||||||
|
|
||||||
|
FRIGATE_RTSP_PASSWORD='QSNPaStxkfi8a2qe'
|
||||||
|
|
||||||
|
TZ='Australia/Hobart'
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
FROM ghcr.io/blakeblackshear/frigate:stable
|
||||||
|
|
||||||
|
# Install rsync
|
||||||
|
RUN apt-get update && apt-get install -y rsync cron
|
||||||
|
|
||||||
|
# Add your sync script
|
||||||
|
COPY sync_recordings.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/sync_recordings.sh
|
||||||
|
|
||||||
|
# Add crontab file
|
||||||
|
COPY crontab /etc/cron.d/sync-cron
|
||||||
|
RUN chmod 0644 /etc/cron.d/sync-cron
|
||||||
|
RUN crontab /etc/cron.d/sync-cron
|
||||||
|
|
||||||
|
# Run cron in the foreground
|
||||||
|
CMD ["cron", "-f"]
|
||||||
Executable
+6
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sed -i 's/access_log \/dev\/stdout main;/access_log \/dev\/null main;/g' /usr/local/nginx/conf/nginx.conf
|
||||||
|
|
||||||
|
# Delegate to original entrypoint
|
||||||
|
exec /init "$@"
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
FROM python:3.9-slim
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libopencv-dev \
|
||||||
|
python3-opencv \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Python packages
|
||||||
|
RUN pip install --no-cache-dir \
|
||||||
|
paho-mqtt \
|
||||||
|
requests \
|
||||||
|
numpy
|
||||||
|
|
||||||
|
# Copy the dayglo detector script
|
||||||
|
COPY dayglo_detector.py /app/dayglo_detector.py
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
CMD ["python", "dayglo_detector.py"]
|
||||||
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import os
|
||||||
|
import paho.mqtt.client as mqtt
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
import threading
|
||||||
|
|
||||||
|
# Configuration from environment variables
|
||||||
|
MQTT_BROKER = os.environ.get('MQTT_BROKER', 'frigate')
|
||||||
|
MQTT_PORT = int(os.environ.get('MQTT_PORT', '1883'))
|
||||||
|
MQTT_USERNAME = os.environ.get('MQTT_USERNAME')
|
||||||
|
MQTT_PASSWORD = os.environ.get('MQTT_PASSWORD')
|
||||||
|
MQTT_TOPIC_SUBSCRIBE = 'frigate/events'
|
||||||
|
MQTT_TOPIC_PUBLISH = 'homeassistant/sensor/dayglo_rating/state'
|
||||||
|
FRIGATE_URL = os.environ.get('FRIGATE_URL', 'http://frigate:5000')
|
||||||
|
INTERESTED_ZONES = ['Door_Front']
|
||||||
|
|
||||||
|
def calculate_dayglo_rating(image):
|
||||||
|
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
||||||
|
# Define HSV range for "dayglo" colors (adjust as needed)
|
||||||
|
lower_color = np.array([20, 100, 100])
|
||||||
|
upper_color = np.array([40, 255, 255])
|
||||||
|
# Create a mask for the colors
|
||||||
|
mask = cv2.inRange(hsv_image, lower_color, upper_color)
|
||||||
|
# Calculate the percentage of "dayglo" pixels
|
||||||
|
dayglo_pixels = cv2.countNonZero(mask)
|
||||||
|
total_pixels = image.shape[0] * image.shape[1]
|
||||||
|
dayglo_rating = (dayglo_pixels / total_pixels) * 100
|
||||||
|
return dayglo_rating
|
||||||
|
|
||||||
|
def on_connect(client, userdata, flags, rc):
|
||||||
|
print("Connected to MQTT broker")
|
||||||
|
client.subscribe(MQTT_TOPIC_SUBSCRIBE)
|
||||||
|
|
||||||
|
def on_message(client, userdata, msg):
|
||||||
|
payload = json.loads(msg.payload)
|
||||||
|
event_type = payload.get('type')
|
||||||
|
after = payload.get('after', {})
|
||||||
|
label = after.get('label')
|
||||||
|
|
||||||
|
if event_type == 'new' and label == 'person':
|
||||||
|
zones = after.get('entered_zones', [])
|
||||||
|
if any(zone in INTERESTED_ZONES for zone in zones):
|
||||||
|
threading.Thread(target=process_event, args=(after,)).start()
|
||||||
|
|
||||||
|
def process_event(event_data):
|
||||||
|
event_id = event_data.get('id')
|
||||||
|
camera = event_data.get('camera')
|
||||||
|
# Get the snapshot URL for the event
|
||||||
|
snapshot_url = f"{FRIGATE_URL}/api/events/{event_id}/snapshot.jpg"
|
||||||
|
# Retrieve the snapshot
|
||||||
|
response = requests.get(snapshot_url)
|
||||||
|
if response.status_code == 200:
|
||||||
|
np_arr = np.frombuffer(response.content, np.uint8)
|
||||||
|
image = cv2.imdecode(np_arr, cv2.IMREAD_COLOR)
|
||||||
|
if image is not None:
|
||||||
|
dayglo_rating = calculate_dayglo_rating(image)
|
||||||
|
print(f"Dayglo Rating: {dayglo_rating:.2f}%")
|
||||||
|
# Publish the rating to Home Assistant
|
||||||
|
client.publish(MQTT_TOPIC_PUBLISH, f"{dayglo_rating:.2f}")
|
||||||
|
else:
|
||||||
|
print("Failed to decode image")
|
||||||
|
else:
|
||||||
|
print(f"Failed to retrieve snapshot: {response.status_code}")
|
||||||
|
|
||||||
|
client = mqtt.Client()
|
||||||
|
if MQTT_USERNAME and MQTT_PASSWORD:
|
||||||
|
client.username_pw_set(MQTT_USERNAME, MQTT_PASSWORD)
|
||||||
|
client.on_connect = on_connect
|
||||||
|
client.on_message = on_message
|
||||||
|
|
||||||
|
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||||
|
client.loop_forever()
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
dayglo_detector:
|
||||||
|
container_name: dayglo_detector
|
||||||
|
build:
|
||||||
|
context: ./dayglo_detector
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
environment:
|
||||||
|
MQTT_BROKER: 'frigate'
|
||||||
|
MQTT_PORT: '1883'
|
||||||
|
MQTT_USERNAME: 'your_mqtt_username' # Optional
|
||||||
|
MQTT_PASSWORD: 'your_mqtt_password' # Optional
|
||||||
|
FRIGATE_URL: 'http://frigate:5000'
|
||||||
|
INTERESTED_ZONES: 'Door_Front'
|
||||||
|
depends_on:
|
||||||
|
- frigate
|
||||||
|
|
||||||
+52
-13
@@ -1,19 +1,23 @@
|
|||||||
version: "3"
|
|
||||||
services:
|
services:
|
||||||
frigate:
|
frigate:
|
||||||
image: ghcr.io/blakeblackshear/frigate:stable
|
image: ghcr.io/blakeblackshear/frigate:stable
|
||||||
#image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
|
#image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
|
||||||
|
#build:
|
||||||
|
# context: .
|
||||||
|
# dockerfile: Dockerfile.frigate
|
||||||
container_name: frigate
|
container_name: frigate
|
||||||
# restart: unless-stopped
|
# restart: unless-stopped
|
||||||
restart: always
|
restart: always
|
||||||
# user: vscode
|
# user: vscode
|
||||||
privileged: true
|
privileged: true
|
||||||
shm_size: "256mb"
|
#shm_size: "256mb"
|
||||||
|
shm_size: "512mb"
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- frigate-config:/config/
|
- frigate-config:/config/
|
||||||
- frigate-trt-models:/trt-models/
|
- frigate-trt-models:/trt-models/
|
||||||
- frigate-storage:/media/frigate/
|
- frigate-storage:/media/frigate/
|
||||||
|
#- frigate-nfs:/media/frigate-nfs/
|
||||||
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
|
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
|
||||||
target: /tmp/cache
|
target: /tmp/cache
|
||||||
tmpfs:
|
tmpfs:
|
||||||
@@ -21,15 +25,50 @@ services:
|
|||||||
- /dev/bus/usb:/dev/bus/usb
|
- /dev/bus/usb:/dev/bus/usb
|
||||||
- /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware
|
- /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware
|
||||||
- /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/apex_0:/dev/apex_0 # Passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
|
||||||
|
- /dev/dri/renderD128:/dev/dri/renderD128
|
||||||
|
- ./custom-start.sh:/custom-start.sh
|
||||||
|
entrypoint: ["/bin/bash", "/custom-start.sh"]
|
||||||
|
#network: host
|
||||||
ports:
|
ports:
|
||||||
|
- "1883:1883"
|
||||||
- "1935:1935"
|
- "1935:1935"
|
||||||
|
- "1984:1984"
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
- "5001:5001"
|
- "5001:5001"
|
||||||
- "8080:8080"
|
- "8000:8000"
|
||||||
|
- "8088:8080"
|
||||||
|
- "8554:8554"
|
||||||
|
- "8555:8555/tcp"
|
||||||
|
- "8555:8555/udp"
|
||||||
# network_mode: host
|
# network_mode: host
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- YOLO_MODELS=${YOLO_MODELS}
|
- YOLO_MODELS=${YOLO_MODELS}
|
||||||
|
- LIBVA_DRIVER_NAME=radeonsi
|
||||||
|
- TZ=${TZ-UTC}
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '0.9'
|
||||||
|
memory: 5000M
|
||||||
|
|
||||||
|
dayglo_detector:
|
||||||
|
container_name: dayglo_detector
|
||||||
|
build:
|
||||||
|
context: ./dayglo_detector
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
environment:
|
||||||
|
MQTT_BROKER: 'frigate'
|
||||||
|
MQTT_PORT: '1883'
|
||||||
|
MQTT_USERNAME: 'your_mqtt_username' # Optional
|
||||||
|
MQTT_PASSWORD: 'your_mqtt_password' # Optional
|
||||||
|
FRIGATE_URL: 'http://frigate:5000'
|
||||||
|
INTERESTED_ZONES: 'Door_Front'
|
||||||
|
depends_on:
|
||||||
|
- frigate
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
frigate-config:
|
frigate-config:
|
||||||
@@ -44,14 +83,14 @@ volumes:
|
|||||||
type: 'none'
|
type: 'none'
|
||||||
o: 'bind'
|
o: 'bind'
|
||||||
device: '/${BASEDIR}/frigate/trt-models/'
|
device: '/${BASEDIR}/frigate/trt-models/'
|
||||||
# frigate-storage:
|
|
||||||
# driver: local
|
|
||||||
# driver_opts:
|
|
||||||
# type: 'none'
|
|
||||||
# o: 'bind'
|
|
||||||
# device: '/${STORAGEDIR}'
|
|
||||||
frigate-storage:
|
frigate-storage:
|
||||||
|
driver: local
|
||||||
driver_opts:
|
driver_opts:
|
||||||
type: 'nfs'
|
type: 'none'
|
||||||
o: 'addr=nas,nfsvers=4,nolock,soft,rw'
|
o: 'bind,size=50G'
|
||||||
device: ':/Frigate'
|
device: '/${STORAGEDIR}'
|
||||||
|
# frigate-nfs:
|
||||||
|
# driver_opts:
|
||||||
|
# type: 'nfs'
|
||||||
|
# o: 'addr=omv,nfsvers=4,nolock,soft,rw,timeo=600,nofail'
|
||||||
|
# device: ':/Frigate'
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
services:
|
||||||
|
frigate:
|
||||||
|
image: ghcr.io/blakeblackshear/frigate:stable
|
||||||
|
#image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
|
||||||
|
#build:
|
||||||
|
# context: .
|
||||||
|
# dockerfile: Dockerfile.frigate
|
||||||
|
container_name: frigate
|
||||||
|
# restart: unless-stopped
|
||||||
|
restart: always
|
||||||
|
# user: vscode
|
||||||
|
privileged: true
|
||||||
|
#shm_size: "256mb"
|
||||||
|
shm_size: "512mb"
|
||||||
|
volumes:
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
- frigate-config:/config/
|
||||||
|
- frigate-trt-models:/trt-models/
|
||||||
|
- frigate-storage:/media/frigate/
|
||||||
|
#- frigate-nfs:/media/frigate-nfs/
|
||||||
|
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
|
||||||
|
target: /tmp/cache
|
||||||
|
tmpfs:
|
||||||
|
size: 1000000000
|
||||||
|
- /dev/bus/usb:/dev/bus/usb
|
||||||
|
- /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware
|
||||||
|
- /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/dri/renderD128:/dev/dri/renderD128
|
||||||
|
- ./custom-start.sh:/custom-start.sh
|
||||||
|
entrypoint: ["/bin/bash", "/custom-start.sh"]
|
||||||
|
#network: host
|
||||||
|
ports:
|
||||||
|
- "1883:1883"
|
||||||
|
- "1935:1935"
|
||||||
|
- "1984:1984"
|
||||||
|
- "5000:5000"
|
||||||
|
- "5001:5001"
|
||||||
|
- "8000:8000"
|
||||||
|
- "8088:8080"
|
||||||
|
- "8554:8554"
|
||||||
|
- "8555:8555/tcp"
|
||||||
|
- "8555:8555/udp"
|
||||||
|
# network_mode: host
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- YOLO_MODELS=${YOLO_MODELS}
|
||||||
|
- LIBVA_DRIVER_NAME=radeonsi
|
||||||
|
- TZ=${TZ-UTC}
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '0.9'
|
||||||
|
memory: 5000M
|
||||||
|
%%%%%
|
||||||
|
volumes:
|
||||||
|
frigate-config:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: 'none'
|
||||||
|
o: 'bind'
|
||||||
|
device: '/${BASEDIR}/frigate/config/'
|
||||||
|
frigate-trt-models:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: 'none'
|
||||||
|
o: 'bind'
|
||||||
|
device: '/${BASEDIR}/frigate/trt-models/'
|
||||||
|
frigate-storage:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: 'none'
|
||||||
|
o: 'bind,size=50G'
|
||||||
|
device: '/${STORAGEDIR}'
|
||||||
|
# frigate-nfs:
|
||||||
|
# driver_opts:
|
||||||
|
# type: 'nfs'
|
||||||
|
# o: 'addr=omv,nfsvers=4,nolock,soft,rw,timeo=600,nofail'
|
||||||
|
# device: ':/Frigate'
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
services:
|
||||||
|
frigate:
|
||||||
|
image: ghcr.io/blakeblackshear/frigate:stable
|
||||||
|
#image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
|
||||||
|
container_name: frigate
|
||||||
|
# restart: unless-stopped
|
||||||
|
restart: always
|
||||||
|
# user: vscode
|
||||||
|
privileged: true
|
||||||
|
#shm_size: "256mb"
|
||||||
|
shm_size: "512mb"
|
||||||
|
volumes:
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
- frigate-config:/config/
|
||||||
|
- frigate-trt-models:/trt-models/
|
||||||
|
- frigate-storage:/media/frigate/
|
||||||
|
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
|
||||||
|
target: /tmp/cache
|
||||||
|
tmpfs:
|
||||||
|
size: 1000000000
|
||||||
|
- /dev/bus/usb:/dev/bus/usb
|
||||||
|
- /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware
|
||||||
|
- /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/dri/renderD128:/dev/dri/renderD128
|
||||||
|
- ./custom-start.sh:/custom-start.sh
|
||||||
|
entrypoint: ["/bin/bash", "/custom-start.sh"]
|
||||||
|
#network: host
|
||||||
|
ports:
|
||||||
|
- "1883:1883"
|
||||||
|
- "1935:1935"
|
||||||
|
- "1984:1984"
|
||||||
|
- "5000:5000"
|
||||||
|
- "5001:5001"
|
||||||
|
- "8000:8000"
|
||||||
|
- "8088:8080"
|
||||||
|
- "8554:8554"
|
||||||
|
- "8555:8555/tcp"
|
||||||
|
- "8555:8555/udp"
|
||||||
|
# network_mode: host
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- YOLO_MODELS=${YOLO_MODELS}
|
||||||
|
- LIBVA_DRIVER_NAME=radeonsi
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '0.9'
|
||||||
|
memory: 5000M
|
||||||
|
volumes:
|
||||||
|
frigate-config:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: 'none'
|
||||||
|
o: 'bind'
|
||||||
|
device: '/${BASEDIR}/frigate/config/'
|
||||||
|
frigate-trt-models:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: 'none'
|
||||||
|
o: 'bind'
|
||||||
|
device: '/${BASEDIR}/frigate/trt-models/'
|
||||||
|
frigate-storage:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: 'none'
|
||||||
|
o: 'bind'
|
||||||
|
device: '/${STORAGEDIR}'
|
||||||
|
#frigate-storage:
|
||||||
|
# driver_opts:
|
||||||
|
# type: 'nfs'
|
||||||
|
# o: 'addr=omv,nfsvers=4,nolock,soft,rw,timeo=600'
|
||||||
|
# device: ':/Frigate'
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
LOCAL_DIR="/media/frigate"
|
||||||
|
NFS_DIR="/mnt/nfs_frigate"
|
||||||
|
|
||||||
|
# Check if NFS is mounted
|
||||||
|
if mountpoint -q "$NFS_DIR"; then
|
||||||
|
# Move files older than 1 day
|
||||||
|
find "$LOCAL_DIR" -type f -mtime +1 -exec mv {} "$NFS_DIR" \;
|
||||||
|
fi
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
rsync -av /media/frigate/ /media/frigate-nfs/
|
||||||
Reference in New Issue
Block a user