From 86baac1b85bd47aeb2dbe4c640b161d642d655ec Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 11 Mar 2024 07:31:05 -0600 Subject: [PATCH] refactor motion calculation --- frigate/api/review.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frigate/api/review.py b/frigate/api/review.py index 4170a1a91..7f47480f3 100644 --- a/frigate/api/review.py +++ b/frigate/api/review.py @@ -403,7 +403,10 @@ def motion_activity(): df.set_index(["start_time"], inplace=True) # normalize data - df = df.resample(f"{scale}S").sum().fillna(0.0) + df = df.resample(f"{scale}S").sum().fillna(0) + mean = df["motion"].mean() + std = df["motion"].std() + df["motion"] = (df["motion"] - mean) / std df["motion"] = ( (df["motion"] - df["motion"].min()) / (df["motion"].max() - df["motion"].min())