Add camera fps to graphs (#11080)

* Add camera fps to graphs

* Use more generic name
This commit is contained in:
Nicolas Mowen 2024-04-23 08:32:46 -06:00 committed by GitHub
parent 2d71cd7fe2
commit 647bcb2618
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,6 +66,7 @@ export default function CameraMetrics({
[key: string]: { name: string; data: { x: number; y: number }[] }; [key: string]: { name: string; data: { x: number; y: number }[] };
} = {}; } = {};
series["overall_fps"] = { name: "overall frames per second", data: [] };
series["overall_dps"] = { name: "overall detections per second", data: [] }; series["overall_dps"] = { name: "overall detections per second", data: [] };
series["overall_skipped_dps"] = { series["overall_skipped_dps"] = {
name: "overall skipped detections per second", name: "overall skipped detections per second",
@ -77,6 +78,16 @@ export default function CameraMetrics({
return; return;
} }
let frames = 0;
Object.values(stats.cameras).forEach(
(camStat) => (frames += camStat.camera_fps),
);
series["overall_fps"].data.push({
x: statsIdx,
y: Math.round(frames),
});
series["overall_dps"].data.push({ series["overall_dps"].data.push({
x: statsIdx, x: statsIdx,
y: stats.detection_fps, y: stats.detection_fps,
@ -161,6 +172,10 @@ export default function CameraMetrics({
if (!(key in series)) { if (!(key in series)) {
const camName = key.replaceAll("_", " "); const camName = key.replaceAll("_", " ");
series[key] = {}; series[key] = {};
series[key]["fps"] = {
name: `${camName} frames per second`,
data: [],
};
series[key]["det"] = { series[key]["det"] = {
name: `${camName} detections per second`, name: `${camName} detections per second`,
data: [], data: [],
@ -171,6 +186,10 @@ export default function CameraMetrics({
}; };
} }
series[key]["fps"].data.push({
x: statsIdx,
y: camStats.camera_fps,
});
series[key]["det"].data.push({ series[key]["det"].data.push({
x: statsIdx, x: statsIdx,
y: camStats.detection_fps, y: camStats.detection_fps,
@ -190,11 +209,11 @@ export default function CameraMetrics({
<div className="grid grid-cols-1 md:grid-cols-3"> <div className="grid grid-cols-1 md:grid-cols-3">
{statsHistory.length != 0 ? ( {statsHistory.length != 0 ? (
<div className="p-2.5 bg-background_alt rounded-lg md:rounded-2xl"> <div className="p-2.5 bg-background_alt rounded-lg md:rounded-2xl">
<div className="mb-5">DPS</div> <div className="mb-5">Frames / Detections</div>
<CameraLineGraph <CameraLineGraph
graphId="overall-stats" graphId="overall-stats"
unit=" DPS" unit=""
dataLabels={["detect", "skipped"]} dataLabels={["camera", "detect", "skipped"]}
updateTimes={updateTimes} updateTimes={updateTimes}
data={overallFpsSeries} data={overallFpsSeries}
/> />
@ -231,11 +250,11 @@ export default function CameraMetrics({
)} )}
{Object.keys(cameraFpsSeries).includes(camera.name) ? ( {Object.keys(cameraFpsSeries).includes(camera.name) ? (
<div className="p-2.5 bg-background_alt rounded-lg md:rounded-2xl"> <div className="p-2.5 bg-background_alt rounded-lg md:rounded-2xl">
<div className="mb-5">DPS</div> <div className="mb-5">Frames / Detections</div>
<CameraLineGraph <CameraLineGraph
graphId={`${camera.name}-dps`} graphId={`${camera.name}-dps`}
unit=" DPS" unit=""
dataLabels={["detect", "skipped"]} dataLabels={["camera", "detect", "skipped"]}
updateTimes={updateTimes} updateTimes={updateTimes}
data={Object.values( data={Object.values(
cameraFpsSeries[camera.name] || {}, cameraFpsSeries[camera.name] || {},