adds motion path config

This commit is contained in:
Gabriel Grant 2025-02-15 15:24:23 -05:00
parent bb4fd9531a
commit f387ab2bf2
7 changed files with 70 additions and 0 deletions

View File

@ -17,6 +17,7 @@ class MediaLatestFrameQueryParams(BaseModel):
zones: Optional[int] = None
mask: Optional[int] = None
motion: Optional[int] = None
motion_paths: Optional[int] = None
regions: Optional[int] = None
quality: Optional[int] = 70
height: Optional[int] = None
@ -40,6 +41,7 @@ class MediaMjpegFeedQueryParams(BaseModel):
zones: Optional[int] = None
mask: Optional[int] = None
motion: Optional[int] = None
motion_paths: Optional[int] = None
regions: Optional[int] = None

View File

@ -55,6 +55,7 @@ def mjpeg_feed(
):
draw_options = {
"bounding_boxes": params.bbox,
"motion_paths": params.motion_paths,
"timestamp": params.timestamp,
"zones": params.zones,
"mask": params.mask,
@ -127,6 +128,7 @@ def latest_frame(
frame_processor: TrackedObjectProcessor = request.app.detected_frames_processor
draw_options = {
"bounding_boxes": params.bbox,
"motion_paths": params.motion_paths,
"timestamp": params.timestamp,
"zones": params.zones,
"mask": params.mask,

View File

@ -0,0 +1,44 @@
from typing import Any, Optional, Union
from pydantic import Field, field_serializer
from ..base import FrigateBaseModel
__all__ = ["MotionPathConfig"]
class MotionPathConfig(FrigateBaseModel):
enabled: bool = Field(default=True, title="Enable motion path tracking on all cameras.")
threshold: int = Field(
default=30,
title="Motion detection threshold (1-255).",
ge=1,
le=255,
)
lightning_threshold: float = Field(
default=0.8, title="Lightning detection threshold (0.3-1.0).", ge=0.3, le=1.0
)
improve_contrast: bool = Field(default=True, title="Improve Contrast")
contour_area: Optional[int] = Field(default=10, title="Contour Area")
delta_alpha: float = Field(default=0.2, title="Delta Alpha")
frame_alpha: float = Field(default=0.01, title="Frame Alpha")
frame_height: Optional[int] = Field(default=100, title="Frame Height")
mask: Union[str, list[str]] = Field(
default="", title="Coordinates polygon for the motion mask."
)
mqtt_off_delay: int = Field(
default=30,
title="Delay for updating MQTT with no motion detected.",
)
enabled_in_config: Optional[bool] = Field(
default=None, title="Keep track of original state of motion detection."
)
raw_mask: Union[str, list[str]] = ""
@field_serializer("mask", when_used="json")
def serialize_mask(self, value: Any, info):
return self.raw_mask
@field_serializer("raw_mask", when_used="json")
def serialize_raw_mask(self, value: Any, info):
return None

View File

@ -27,6 +27,9 @@ class SnapshotsConfig(FrigateBaseModel):
bounding_box: bool = Field(
default=True, title="Add a bounding box overlay on the snapshot."
)
motion_paths: bool = Field(
default=True, title="Add a motion path overlay on the snapshot."
)
crop: bool = Field(default=False, title="Crop the snapshot to the detected object.")
required_zones: list[str] = Field(
default_factory=list,

View File

@ -46,6 +46,7 @@ from .camera.detect import DetectConfig
from .camera.ffmpeg import FfmpegConfig
from .camera.genai import GenAIConfig
from .camera.motion import MotionConfig
from .camera.motion_path import MotionPathConfig
from .camera.notification import NotificationConfig
from .camera.objects import FilterConfig, ObjectConfig
from .camera.record import RecordConfig, RetainModeEnum
@ -388,6 +389,9 @@ class FrigateConfig(FrigateBaseModel):
motion: Optional[MotionConfig] = Field(
default=None, title="Global motion detection configuration."
)
motion_paths: Optional[MotionPathConfig] = Field(
default=None, title="Global motion path tracking configuration."
)
objects: ObjectConfig = Field(
default_factory=ObjectConfig, title="Global object configuration."
)

View File

@ -101,6 +101,16 @@ function DebugSettings({ handleSetOption, options }: DebugSettingsProps) {
/>
<Label htmlFor="bbox">Bounding Box</Label>
</div>
<div className="flex items-center space-x-2">
<Switch
id="motion_paths"
checked={options["motion_paths"]}
onCheckedChange={(isChecked) => {
handleSetOption("motion_paths", isChecked);
}}
/>
<Label htmlFor="motion_paths">Motion Paths</Label>
</div>
<div className="flex items-center space-x-2">
<Switch
id="timestamp"

View File

@ -72,6 +72,11 @@ export default function ObjectSettingsView({
</>
),
},
{
param: "motion_paths",
title: "Motion Paths",
description: "Show motion paths of tracked objects",
},
{
param: "timestamp",
title: "Timestamp",