NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Optionally show tracked object paths in debug view (#19025)
Josh Hawkins22478df4d621
diff --git a/frigate/api/defs/query/media_query_parameters.py b/frigate/api/defs/query/media_query_parameters.pyindex cf06c71e1d..fd53af49a5 100644--- a/frigate/api/defs/query/media_query_parameters.py+++ b/frigate/api/defs/query/media_query_parameters.py@@ -18,6 +18,7 @@ class MediaLatestFrameQueryParams(BaseModel):zones: Optional[int] = Nonemask: Optional[int] = Nonemotion: Optional[int] = None+ paths: Optional[int] = Noneregions: Optional[int] = Nonequality: Optional[int] = 70height: Optional[int] = Nonediff --git a/frigate/api/media.py b/frigate/api/media.pyindex 77de2aefe9..a1ab6648fe 100644--- a/frigate/api/media.py+++ b/frigate/api/media.py@@ -141,6 +141,7 @@ def latest_frame("zones": params.zones,"mask": params.mask,"motion_boxes": params.motion,+ "paths": params.paths,"regions": params.regions,}quality = params.qualitydiff --git a/frigate/camera/state.py b/frigate/camera/state.pyindex 06564bce27..a1041e95b6 100644--- a/frigate/camera/state.py+++ b/frigate/camera/state.py@@ -228,6 +228,45 @@ class CameraState:position=self.camera_config.timestamp_style.position,)+ if draw_options.get("paths"):+ for obj in tracked_objects.values():+ if obj["frame_time"] == frame_time and obj["path_data"]:+ color = self.config.model.colormap.get(+ obj["label"], (255, 255, 255)+ )++ path_points = [+ (+ int(point[0][0] * self.camera_config.detect.width),+ int(point[0][1] * self.camera_config.detect.height),+ )+ for point in obj["path_data"]+ ]++ for point in path_points:+ cv2.circle(frame_copy, point, 5, color, -1)++ for i in range(1, len(path_points)):+ cv2.line(+ frame_copy,+ path_points[i - 1],+ path_points[i],+ color,+ 2,+ )++ bottom_center = (+ int((obj["box"][0] + obj["box"][2]) / 2),+ int(obj["box"][3]),+ )+ cv2.line(+ frame_copy,+ path_points[-1],+ bottom_center,+ color,+ 2,+ )+return frame_copydef finished(self, obj_id):diff --git a/web/public/locales/en/views/settings.json b/web/public/locales/en/views/settings.jsonindex b396babde0..ab5e77ed5f 100644--- a/web/public/locales/en/views/settings.json+++ b/web/public/locales/en/views/settings.json@@ -439,6 +439,11 @@"desc": "Show a box of the region of interest sent to the object detector","tips": "<p><strong>Region Boxes</strong></p><br><p>Bright green boxes will be overlaid on areas of interest in the frame that are being sent to the object detector.</p>"},+ "paths": {+ "title": "Paths",+ "desc": "Show significant points of the tracked object's path",+ "tips": "<p><strong>Paths</strong></p><br><p>Lines and circles will indicate significant points the tracked object has moved during its lifecycle.</p>"+ },"objectShapeFilterDrawing": {"title": "Object Shape Filter Drawing","desc": "Draw a rectangle on the image to view area and ratio details",diff --git a/web/src/components/camera/DebugCameraImage.tsx b/web/src/components/camera/DebugCameraImage.tsxindex 3d840d0d32..bc3b6a8c38 100644--- a/web/src/components/camera/DebugCameraImage.tsx+++ b/web/src/components/camera/DebugCameraImage.tsx@@ -158,6 +158,16 @@ function DebugSettings({ handleSetOption, options }: DebugSettingsProps) {/><Label htmlFor="regions">{t("debug.regions")}</Label></div>+ <div className="flex items-center space-x-2">+ <Switch+ id="paths"+ checked={options["paths"]}+ onCheckedChange={(isChecked) => {+ handleSetOption("paths", isChecked);+ }}+ />+ <Label htmlFor="paths">{t("debug.paths")}</Label>+ </div></div>);}diff --git a/web/src/views/settings/ObjectSettingsView.tsx b/web/src/views/settings/ObjectSettingsView.tsxindex b666789d79..d1f77e3ac0 100644--- a/web/src/views/settings/ObjectSettingsView.tsx+++ b/web/src/views/settings/ObjectSettingsView.tsx@@ -93,6 +93,12 @@ export default function ObjectSettingsView({description: t("debug.regions.desc"),info: <Trans ns="views/settings">debug.regions.tips</Trans>,},+ {+ param: "paths",+ title: t("debug.paths.title"),+ description: t("debug.paths.desc"),+ info: <Trans ns="views/settings">debug.paths.tips</Trans>,+ },];const [options, setOptions, optionsLoaded] = usePersistence<Options>(