mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 19:55:26 +03:00
Reduce grouped up image refreshes
This commit is contained in:
parent
8b95052768
commit
f02ef78d03
@ -784,14 +784,14 @@ def hourly_timeline_activity(camera_name: str):
|
|||||||
df.set_index(["date"], inplace=True)
|
df.set_index(["date"], inplace=True)
|
||||||
|
|
||||||
# normalize data
|
# normalize data
|
||||||
df["count"] = np.log10(df["count"], where=df["count"] > 0)
|
df["count"] = np.clip(np.log10(df["count"], where=df["count"] > 0), None, 10)
|
||||||
df = df.resample("T").mean().fillna(0)
|
df = df.resample("T").mean().fillna(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)
|
||||||
df["count"] = df["count"].astype(int)
|
df["count"] = df["count"].astype(int)
|
||||||
df["hasObjects"] = df["hasObjects"].astype(bool)
|
df["hasObjects"] = df["hasObjects"].astype(bool)
|
||||||
hours[key] = df.reset_index().to_dict('records')
|
hours[key] = df.reset_index().to_dict("records")
|
||||||
|
|
||||||
return jsonify(hours)
|
return jsonify(hours)
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { AspectRatio } from "../ui/aspect-ratio";
|
import { AspectRatio } from "../ui/aspect-ratio";
|
||||||
import CameraImage from "./CameraImage";
|
import CameraImage from "./CameraImage";
|
||||||
import { LuEar } from "react-icons/lu";
|
import { LuEar } from "react-icons/lu";
|
||||||
@ -21,6 +21,10 @@ export default function DynamicCameraImage({
|
|||||||
}: DynamicCameraImageProps) {
|
}: DynamicCameraImageProps) {
|
||||||
const [key, setKey] = useState(Date.now());
|
const [key, setKey] = useState(Date.now());
|
||||||
const [activeObjects, setActiveObjects] = useState<string[]>([]);
|
const [activeObjects, setActiveObjects] = useState<string[]>([]);
|
||||||
|
const hasActiveObjects = useMemo(
|
||||||
|
() => activeObjects.length > 0,
|
||||||
|
[activeObjects]
|
||||||
|
);
|
||||||
|
|
||||||
const { payload: detectingMotion } = useMotionActivity(camera.name);
|
const { payload: detectingMotion } = useMotionActivity(camera.name);
|
||||||
const { payload: event } = useFrigateEvents();
|
const { payload: event } = useFrigateEvents();
|
||||||
@ -58,8 +62,9 @@ export default function DynamicCameraImage({
|
|||||||
|
|
||||||
const handleLoad = useCallback(() => {
|
const handleLoad = useCallback(() => {
|
||||||
const loadTime = Date.now() - key;
|
const loadTime = Date.now() - key;
|
||||||
const loadInterval =
|
const loadInterval = hasActiveObjects
|
||||||
activeObjects.length > 0 ? INTERVAL_ACTIVE_MS : INTERVAL_INACTIVE_MS;
|
? INTERVAL_ACTIVE_MS
|
||||||
|
: INTERVAL_INACTIVE_MS;
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
@ -67,7 +72,7 @@ export default function DynamicCameraImage({
|
|||||||
},
|
},
|
||||||
loadTime > loadInterval ? 1 : loadInterval
|
loadTime > loadInterval ? 1 : loadInterval
|
||||||
);
|
);
|
||||||
}, [activeObjects, key]);
|
}, [hasActiveObjects, key]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AspectRatio
|
<AspectRatio
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user