mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 13:15:25 +03:00
Use max so cameras without motion don't invlidate good data:
This commit is contained in:
parent
bf92ccb25d
commit
989edd40dd
@ -5,12 +5,7 @@ from datetime import datetime, timedelta
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from flask import (
|
from flask import Blueprint, jsonify, make_response, request
|
||||||
Blueprint,
|
|
||||||
jsonify,
|
|
||||||
make_response,
|
|
||||||
request,
|
|
||||||
)
|
|
||||||
from peewee import Case, DoesNotExist, fn, operator
|
from peewee import Case, DoesNotExist, fn, operator
|
||||||
|
|
||||||
from frigate.models import Recordings, ReviewSegment
|
from frigate.models import Recordings, ReviewSegment
|
||||||
@ -391,7 +386,11 @@ def motion_activity():
|
|||||||
df.set_index(["start_time"], inplace=True)
|
df.set_index(["start_time"], inplace=True)
|
||||||
|
|
||||||
# normalize data
|
# 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
|
# change types for output
|
||||||
df.index = df.index.astype(int) // (10**9)
|
df.index = df.index.astype(int) // (10**9)
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
|
|
||||||
for camera in self.config.cameras.values():
|
for camera in self.config.cameras.values():
|
||||||
self.camera_frame_area[camera.name] = (
|
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:
|
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]])
|
total_motion_area += sum([area(box) for box in frame[2]])
|
||||||
|
|
||||||
if video_frame_count > 0:
|
if video_frame_count > 0:
|
||||||
normalized_motion_area = int(
|
normalized_motion_area = min(
|
||||||
|
int(
|
||||||
(
|
(
|
||||||
total_motion_area
|
total_motion_area
|
||||||
/ (self.camera_frame_area[camera] * video_frame_count)
|
/ (self.camera_frame_area[camera] * video_frame_count)
|
||||||
)
|
)
|
||||||
* 100
|
* 100
|
||||||
|
),
|
||||||
|
100,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
normalized_motion_area = 0
|
normalized_motion_area = 0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user