Use max so cameras without motion don't invlidate good data:

This commit is contained in:
Nicolas Mowen 2024-03-14 10:30:47 -06:00
parent bf92ccb25d
commit 989edd40dd
2 changed files with 16 additions and 14 deletions

View File

@ -5,12 +5,7 @@ from datetime import datetime, timedelta
from functools import reduce
import pandas as pd
from flask import (
Blueprint,
jsonify,
make_response,
request,
)
from flask import Blueprint, jsonify, make_response, request
from peewee import Case, DoesNotExist, fn, operator
from frigate.models import Recordings, ReviewSegment
@ -391,7 +386,11 @@ def motion_activity():
df.set_index(["start_time"], inplace=True)
# normalize data
df = df.resample(f"{scale}S").mean().fillna(0.0)
df = (
df.resample(f"{scale}S")
.apply(lambda x: max(x, key=abs, default=0.0))
.fillna(0.0)
)
# change types for output
df.index = df.index.astype(int) // (10**9)

View File

@ -75,7 +75,7 @@ class RecordingMaintainer(threading.Thread):
for camera in self.config.cameras.values():
self.camera_frame_area[camera.name] = (
camera.detect.width * camera.detect.height
camera.detect.width * camera.detect.height * 0.1
)
async def move_files(self) -> None:
@ -319,12 +319,15 @@ class RecordingMaintainer(threading.Thread):
total_motion_area += sum([area(box) for box in frame[2]])
if video_frame_count > 0:
normalized_motion_area = int(
(
total_motion_area
/ (self.camera_frame_area[camera] * video_frame_count)
)
* 100
normalized_motion_area = min(
int(
(
total_motion_area
/ (self.camera_frame_area[camera] * video_frame_count)
)
* 100
),
100,
)
else:
normalized_motion_area = 0