mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 13:15:25 +03:00
Formatting
This commit is contained in:
parent
3c28f4f598
commit
275dfe017e
@ -271,9 +271,7 @@ def review_activity():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# get scale in seconds
|
# get scale in seconds
|
||||||
scale = request.args.get(
|
scale = request.args.get("scale", type=int, default=30)
|
||||||
"scale", type=int, default=30
|
|
||||||
)
|
|
||||||
|
|
||||||
all_recordings: list[Recordings] = (
|
all_recordings: list[Recordings] = (
|
||||||
Recordings.select(
|
Recordings.select(
|
||||||
@ -293,11 +291,13 @@ def review_activity():
|
|||||||
data: list[dict[str, float]] = []
|
data: list[dict[str, float]] = []
|
||||||
|
|
||||||
for rec in all_recordings:
|
for rec in all_recordings:
|
||||||
data.append({
|
data.append(
|
||||||
|
{
|
||||||
"start_time": rec.start_time,
|
"start_time": rec.start_time,
|
||||||
"motion": rec.motion if rec.objects == 0 else 0,
|
"motion": rec.motion if rec.objects == 0 else 0,
|
||||||
"audio": rec.dBFS if rec.objects == 0 else 0,
|
"audio": rec.dBFS if rec.objects == 0 else 0,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
# resample data using pandas to get activity on scaled basis
|
# resample data using pandas to get activity on scaled basis
|
||||||
df = pd.DataFrame(data, columns=["start_time", "motion", "audio"])
|
df = pd.DataFrame(data, columns=["start_time", "motion", "audio"])
|
||||||
@ -308,8 +308,16 @@ def review_activity():
|
|||||||
|
|
||||||
# normalize data
|
# normalize data
|
||||||
df = df.resample(f"{scale}S").mean().fillna(0.0)
|
df = df.resample(f"{scale}S").mean().fillna(0.0)
|
||||||
df["motion"] = (df["motion"] - df["motion"].min()) / (df["motion"].max() - df["motion"].min()) * 100
|
df["motion"] = (
|
||||||
df["audio"] = (df["audio"] - df["audio"].max()) / (df["audio"].min() - df["audio"].max()) * -100
|
(df["motion"] - df["motion"].min())
|
||||||
|
/ (df["motion"].max() - df["motion"].min())
|
||||||
|
* 100
|
||||||
|
)
|
||||||
|
df["audio"] = (
|
||||||
|
(df["audio"] - df["audio"].max())
|
||||||
|
/ (df["audio"].min() - df["audio"].max())
|
||||||
|
* -100
|
||||||
|
)
|
||||||
|
|
||||||
# change types for output
|
# change types for output
|
||||||
df.index = df.index.astype(int) // (10**9)
|
df.index = df.index.astype(int) // (10**9)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user