Skip to content

Commit 989edd4

Browse files
committed
Use max so cameras without motion don't invlidate good data:
1 parent bf92ccb commit 989edd4

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

frigate/api/review.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
from functools import reduce
66

77
import pandas as pd
8-
from flask import (
9-
Blueprint,
10-
jsonify,
11-
make_response,
12-
request,
13-
)
8+
from flask import Blueprint, jsonify, make_response, request
149
from peewee import Case, DoesNotExist, fn, operator
1510

1611
from frigate.models import Recordings, ReviewSegment
@@ -391,7 +386,11 @@ def motion_activity():
391386
df.set_index(["start_time"], inplace=True)
392387

393388
# normalize data
394-
df = df.resample(f"{scale}S").mean().fillna(0.0)
389+
df = (
390+
df.resample(f"{scale}S")
391+
.apply(lambda x: max(x, key=abs, default=0.0))
392+
.fillna(0.0)
393+
)
395394

396395
# change types for output
397396
df.index = df.index.astype(int) // (10**9)

frigate/record/maintainer.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(self, config: FrigateConfig, stop_event: MpEvent):
7575

7676
for camera in self.config.cameras.values():
7777
self.camera_frame_area[camera.name] = (
78-
camera.detect.width * camera.detect.height
78+
camera.detect.width * camera.detect.height * 0.1
7979
)
8080

8181
async def move_files(self) -> None:
@@ -319,12 +319,15 @@ def segment_stats(
319319
total_motion_area += sum([area(box) for box in frame[2]])
320320

321321
if video_frame_count > 0:
322-
normalized_motion_area = int(
323-
(
324-
total_motion_area
325-
/ (self.camera_frame_area[camera] * video_frame_count)
326-
)
327-
* 100
322+
normalized_motion_area = min(
323+
int(
324+
(
325+
total_motion_area
326+
/ (self.camera_frame_area[camera] * video_frame_count)
327+
)
328+
* 100
329+
),
330+
100,
328331
)
329332
else:
330333
normalized_motion_area = 0

0 commit comments

Comments
 (0)