import React, { useState, useEffect } from "react"; import Admonition from "@theme/Admonition"; import styles from "./styles.module.css"; const ShmCalculator = () => { const [width, setWidth] = useState(1280); const [height, setHeight] = useState(720); const [cameraCount, setCameraCount] = useState(1); const [result, setResult] = useState("26.32MB"); const [singleCameraShm, setSingleCameraShm] = useState("26.32MB"); const [totalShm, setTotalShm] = useState("26.32MB"); const calculate = () => { if (!width || !height || !cameraCount) { setResult("Please enter valid values"); setSingleCameraShm("-"); setTotalShm("-"); return; } // Single camera base SHM calculation (excluding logs) // Formula: (width * height * 1.5 * 20 + 270480) / 1048576 const singleCameraBase = (width * height * 1.5 * 20 + 270480) / 1048576; setSingleCameraShm(`${singleCameraBase.toFixed(2)}mb`); // Total SHM calculation (multiple cameras, including logs) const totalBase = singleCameraBase * cameraCount; const finalResult = totalBase + 40; // Default includes logs +40mb setTotalShm(`${(totalBase + 40).toFixed(2)}mb`); // Format result if (finalResult < 1) { setResult(`${(finalResult * 1024).toFixed(2)}kb`); } else if (finalResult >= 1024) { setResult(`${(finalResult / 1024).toFixed(2)}gb`); } else { setResult(`${finalResult.toFixed(2)}mb`); } }; const formatWithUnit = (value) => { const match = value.match(/^([\d.]+)(mb|kb|gb)$/i); if (match) { return ( <> {match[1]}{match[2]} ); } return value; }; const applyPreset = (w, h, count) => { setWidth(w); setHeight(h); setCameraCount(count); calculate(); }; useEffect(() => { calculate(); }, [width, height, cameraCount]); return (

SHM Calculator

Calculate required shared memory (SHM) based on camera resolution and count

The resolution below is the detect stream resolution, not the record stream resolution. SHM size is determined by the detect resolution used for object detection.{" "} Learn more about choosing a detect resolution. {width * height > 1280 * 720 && ( Using a detect resolution higher than 720p is not recommended. Higher resolutions do not improve object detection accuracy and will consume significantly more resources. )}
setWidth(Number(e.target.value))} />
setHeight(Number(e.target.value))} />
setCameraCount(Number(e.target.value))} />

Calculation Result

{formatWithUnit(result)}

Single Camera: {formatWithUnit(singleCameraShm)}

Formula: (width × height × 1.5 × 20 + 270480) ÷ 1048576

{cameraCount > 1 && (

Total ({cameraCount} cameras): {formatWithUnit(totalShm)}

)}

With Logs: + 40mb

Common Presets

); }; export default ShmCalculator;