From fe3335f4d6fcf18b0a27620da11bcab65de2602a Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Tue, 9 Apr 2024 14:03:40 -0600 Subject: [PATCH] Add overview stats for overall detection and skipped fps --- web/src/views/system/CameraMetrics.tsx | 63 +++++++++++++++++++++++-- web/src/views/system/StorageMetrics.tsx | 4 +- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/web/src/views/system/CameraMetrics.tsx b/web/src/views/system/CameraMetrics.tsx index fa78ec5a9..a1ef2833d 100644 --- a/web/src/views/system/CameraMetrics.tsx +++ b/web/src/views/system/CameraMetrics.tsx @@ -19,7 +19,7 @@ export default function CameraMetrics({ // stats const { data: initialStats } = useSWR( - ["stats/history", { keys: "cpu_usages,cameras,service" }], + ["stats/history", { keys: "cpu_usages,cameras,detection_fps,service" }], { revalidateOnFocus: false, }, @@ -57,6 +57,44 @@ export default function CameraMetrics({ // stats data + const overallFpsSeries = useMemo(() => { + if (!statsHistory) { + return []; + } + + const series: { + [key: string]: { name: string; data: { x: number; y: number }[] }; + } = {}; + + series["overall_dps"] = { name: "overall detections per second", data: [] }; + series["overall_skipped_dps"] = { + name: "overall skipped detections per second", + data: [], + }; + + statsHistory.forEach((stats, statsIdx) => { + if (!stats) { + return; + } + + series["overall_dps"].data.push({ + x: statsIdx, + y: stats.detection_fps, + }); + + let skipped = 0; + Object.values(stats.cameras).forEach( + (camStat) => (skipped += camStat.skipped_fps), + ); + + series["overall_skipped_dps"].data.push({ + x: statsIdx, + y: skipped, + }); + }); + return Object.values(series); + }, [statsHistory]); + const cameraCpuSeries = useMemo(() => { if (!statsHistory || statsHistory.length == 0) { return {}; @@ -147,14 +185,31 @@ export default function CameraMetrics({ }, [statsHistory]); return ( -
+
+
Overview
+
+ {statsHistory.length != 0 ? ( +
+
DPS
+ +
+ ) : ( + + )} +
{config && Object.values(config.cameras).map((camera) => { if (camera.enabled) { return ( -
-
+
+
{camera.name.replaceAll("_", " ")}
diff --git a/web/src/views/system/StorageMetrics.tsx b/web/src/views/system/StorageMetrics.tsx index ca2533b2c..f1a8f8eb4 100644 --- a/web/src/views/system/StorageMetrics.tsx +++ b/web/src/views/system/StorageMetrics.tsx @@ -43,9 +43,7 @@ export default function StorageMetrics({ return (
-
- General Storage -
+
Overview
Recordings