Skip to content

NVR with realtime local object detection for IP cameras

Normalize motion data in chunks (#10497)

Nicolas Mowen4e7808ac0cd3
diff --git a/frigate/api/review.py b/frigate/api/review.py
index 008bcdb0b2..21eed52977 100644
--- a/frigate/api/review.py
+++ b/frigate/api/review.py
@@ -390,11 +390,17 @@ def motion_activity():
.apply(lambda x: max(x, key=abs, default=0.0))
.fillna(0.0)
)
- df["motion"] = (
- (df["motion"] - df["motion"].min())
- / (df["motion"].max() - df["motion"].min())
- * 100
- )
+
+ length = df.shape[0]
+ chunk = int(60 * (60 / scale))
+
+ for i in range(0, length, chunk):
+ part = df.iloc[i : i + chunk]
+ df.iloc[i : i + chunk, 0] = (
+ (part["motion"] - part["motion"].min())
+ / (part["motion"].max() - part["motion"].min())
+ * 100
+ )
# change types for output
df.index = df.index.astype(int) // (10**9)