mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Merge branch 'release-0.11.0' of https://github.com/blakeblackshear/frigate into sub_label_filter
This commit is contained in:
commit
533d1ae684
@ -5,22 +5,11 @@ title: Hardware Acceleration
|
|||||||
|
|
||||||
It is recommended to update your configuration to enable hardware accelerated decoding in ffmpeg. Depending on your system, these parameters may not be compatible. More information on hardware accelerated decoding for ffmpeg can be found here: https://trac.ffmpeg.org/wiki/HWAccelIntro
|
It is recommended to update your configuration to enable hardware accelerated decoding in ffmpeg. Depending on your system, these parameters may not be compatible. More information on hardware accelerated decoding for ffmpeg can be found here: https://trac.ffmpeg.org/wiki/HWAccelIntro
|
||||||
|
|
||||||
### Raspberry Pi 3/4 (32-bit OS)
|
### Raspberry Pi 3/4
|
||||||
|
|
||||||
Ensure you increase the allocated RAM for your GPU to at least 128 (raspi-config > Performance Options > GPU Memory).
|
Ensure you increase the allocated RAM for your GPU to at least 128 (raspi-config > Performance Options > GPU Memory).
|
||||||
**NOTICE**: If you are using the addon, you may need to turn off `Protection mode` for hardware acceleration.
|
**NOTICE**: If you are using the addon, you may need to turn off `Protection mode` for hardware acceleration.
|
||||||
|
|
||||||
```yaml
|
|
||||||
ffmpeg:
|
|
||||||
hwaccel_args:
|
|
||||||
- -c:v
|
|
||||||
- h264_mmal
|
|
||||||
```
|
|
||||||
|
|
||||||
### Raspberry Pi 3/4 (64-bit OS)
|
|
||||||
|
|
||||||
**NOTICE**: If you are using the addon, you may need to turn off `Protection mode` for hardware acceleration.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
ffmpeg:
|
ffmpeg:
|
||||||
hwaccel_args:
|
hwaccel_args:
|
||||||
|
|||||||
@ -246,6 +246,8 @@ motion:
|
|||||||
# Enables dynamic contrast improvement. This should help improve night detections at the cost of making motion detection more sensitive
|
# Enables dynamic contrast improvement. This should help improve night detections at the cost of making motion detection more sensitive
|
||||||
# for daytime.
|
# for daytime.
|
||||||
improve_contrast: False
|
improve_contrast: False
|
||||||
|
# Optional: Delay when updating camera motion through MQTT from ON -> OFF (default: shown below).
|
||||||
|
mqtt_off_delay: 30
|
||||||
|
|
||||||
# Optional: Record configuration
|
# Optional: Record configuration
|
||||||
# NOTE: Can be overridden at the camera level
|
# NOTE: Can be overridden at the camera level
|
||||||
|
|||||||
@ -123,6 +123,12 @@ Topic with current state of snapshots for a camera. Published values are `ON` an
|
|||||||
Topic to turn motion detection for a camera on and off. Expected values are `ON` and `OFF`.
|
Topic to turn motion detection for a camera on and off. Expected values are `ON` and `OFF`.
|
||||||
NOTE: Turning off motion detection will fail if detection is not disabled.
|
NOTE: Turning off motion detection will fail if detection is not disabled.
|
||||||
|
|
||||||
|
### `frigate/<camera_name>/motion`
|
||||||
|
|
||||||
|
Whether camera_name is currently detecting motion. Expected values are `ON` and `OFF`.
|
||||||
|
NOTE: After motion is initially detected, `ON` will be set until no motion has
|
||||||
|
been detected for `mqtt_off_delay` seconds (30 by default).
|
||||||
|
|
||||||
### `frigate/<camera_name>/motion/state`
|
### `frigate/<camera_name>/motion/state`
|
||||||
|
|
||||||
Topic with current state of motion detection for a camera. Published values are `ON` and `OFF`.
|
Topic with current state of motion detection for a camera. Published values are `ON` and `OFF`.
|
||||||
|
|||||||
@ -134,6 +134,10 @@ class MotionConfig(FrigateBaseModel):
|
|||||||
mask: Union[str, List[str]] = Field(
|
mask: Union[str, List[str]] = Field(
|
||||||
default="", title="Coordinates polygon for the motion mask."
|
default="", title="Coordinates polygon for the motion mask."
|
||||||
)
|
)
|
||||||
|
mqtt_off_delay: int = Field(
|
||||||
|
default=30,
|
||||||
|
title="Delay for updating MQTT with no motion detected.",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RuntimeMotionConfig(MotionConfig):
|
class RuntimeMotionConfig(MotionConfig):
|
||||||
|
|||||||
@ -1,29 +1,24 @@
|
|||||||
import base64
|
import base64
|
||||||
import copy
|
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
|
||||||
import itertools
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import queue
|
import queue
|
||||||
import threading
|
import threading
|
||||||
import time
|
|
||||||
from collections import Counter, defaultdict
|
from collections import Counter, defaultdict
|
||||||
from statistics import mean, median
|
from statistics import median
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from frigate.config import CameraConfig, SnapshotsConfig, RecordConfig, FrigateConfig
|
from frigate.config import CameraConfig, SnapshotsConfig, RecordConfig, FrigateConfig
|
||||||
from frigate.const import CACHE_DIR, CLIPS_DIR, RECORD_DIR
|
from frigate.const import CLIPS_DIR
|
||||||
from frigate.util import (
|
from frigate.util import (
|
||||||
SharedMemoryFrameManager,
|
SharedMemoryFrameManager,
|
||||||
calculate_region,
|
calculate_region,
|
||||||
draw_box_with_label,
|
draw_box_with_label,
|
||||||
draw_timestamp,
|
draw_timestamp,
|
||||||
load_labels,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -652,6 +647,7 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
self.stop_event = stop_event
|
self.stop_event = stop_event
|
||||||
self.camera_states: dict[str, CameraState] = {}
|
self.camera_states: dict[str, CameraState] = {}
|
||||||
self.frame_manager = SharedMemoryFrameManager()
|
self.frame_manager = SharedMemoryFrameManager()
|
||||||
|
self.last_motion_detected: dict[str, float] = {}
|
||||||
|
|
||||||
def start(camera, obj: TrackedObject, current_frame_time):
|
def start(camera, obj: TrackedObject, current_frame_time):
|
||||||
self.event_queue.put(("start", camera, obj.to_dict()))
|
self.event_queue.put(("start", camera, obj.to_dict()))
|
||||||
@ -844,6 +840,32 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def update_mqtt_motion(self, camera, frame_time, motion_boxes):
|
||||||
|
# publish if motion is currently being detected
|
||||||
|
if motion_boxes:
|
||||||
|
# only send ON if motion isn't already active
|
||||||
|
if self.last_motion_detected.get(camera, 0) == 0:
|
||||||
|
self.client.publish(
|
||||||
|
f"{self.topic_prefix}/{camera}/motion",
|
||||||
|
"ON",
|
||||||
|
retain=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# always updated latest motion
|
||||||
|
self.last_motion_detected[camera] = frame_time
|
||||||
|
elif self.last_motion_detected.get(camera, 0) > 0:
|
||||||
|
mqtt_delay = self.config.cameras[camera].motion.mqtt_off_delay
|
||||||
|
|
||||||
|
# If no motion, make sure the off_delay has passed
|
||||||
|
if frame_time - self.last_motion_detected.get(camera, 0) >= mqtt_delay:
|
||||||
|
self.client.publish(
|
||||||
|
f"{self.topic_prefix}/{camera}/motion",
|
||||||
|
"OFF",
|
||||||
|
retain=False,
|
||||||
|
)
|
||||||
|
# reset the last_motion so redundant `off` commands aren't sent
|
||||||
|
self.last_motion_detected[camera] = 0
|
||||||
|
|
||||||
def get_best(self, camera, label):
|
def get_best(self, camera, label):
|
||||||
# TODO: need a lock here
|
# TODO: need a lock here
|
||||||
camera_state = self.camera_states[camera]
|
camera_state = self.camera_states[camera]
|
||||||
@ -879,6 +901,8 @@ class TrackedObjectProcessor(threading.Thread):
|
|||||||
frame_time, current_tracked_objects, motion_boxes, regions
|
frame_time, current_tracked_objects, motion_boxes, regions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.update_mqtt_motion(camera, frame_time, motion_boxes)
|
||||||
|
|
||||||
tracked_objects = [
|
tracked_objects = [
|
||||||
o.to_dict() for o in camera_state.tracked_objects.values()
|
o.to_dict() for o in camera_state.tracked_objects.values()
|
||||||
]
|
]
|
||||||
|
|||||||
@ -6,24 +6,25 @@ import 'videojs-seek-buttons';
|
|||||||
import 'video.js/dist/video-js.css';
|
import 'video.js/dist/video-js.css';
|
||||||
import 'videojs-seek-buttons/dist/videojs-seek-buttons.css';
|
import 'videojs-seek-buttons/dist/videojs-seek-buttons.css';
|
||||||
|
|
||||||
|
export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) {
|
||||||
|
const playerRef = useRef();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
controls: true,
|
controls: true,
|
||||||
playbackRates: [0.5, 1, 2, 4, 8],
|
playbackRates: [0.5, 1, 2, 4, 8],
|
||||||
fluid: true,
|
fluid: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultSeekOptions = {
|
const defaultSeekOptions = {
|
||||||
forward: 30,
|
forward: 30,
|
||||||
back: 10,
|
back: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function VideoPlayer({ children, options, seekOptions = {}, onReady = () => {}, onDispose = () => {} }) {
|
|
||||||
const playerRef = useRef();
|
|
||||||
|
|
||||||
if (!videojs.browser.IS_FIREFOX) {
|
if (!videojs.browser.IS_FIREFOX) {
|
||||||
defaultOptions.playbackRates.push(16);
|
defaultOptions.playbackRates.push(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => {
|
const player = videojs(playerRef.current, { ...defaultOptions, ...options }, () => {
|
||||||
onReady(player);
|
onReady(player);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user