From 2874751c72d1fee0623e512842a73892338f9de5 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 11 Mar 2026 16:04:43 -0400 Subject: [PATCH] fix: correct stats percentage calculations for percentage-space zone area The stats display was dividing pixel counts by the zone Area value directly, but Area is stored in percentage coordinate space (0-10000 for full frame). Convert Area to actual pixel area using the monitor dimensions before calculating percentages. Co-Authored-By: Claude Opus 4.6 --- web/skins/classic/includes/functions.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 23c1fb18b..ece7a0a90 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -1619,7 +1619,7 @@ function getStatsTableHTML($eid, $fid, $row='') { if ( !canView('Events') ) return; $result = ''; - $sql = 'SELECT S.*,E.*,Z.Name AS ZoneName,Z.Units,Z.Area,M.Name AS MonitorName FROM Stats AS S LEFT JOIN Events AS E ON S.EventId = E.Id LEFT JOIN Zones AS Z ON S.ZoneId = Z.Id LEFT JOIN Monitors AS M ON E.MonitorId = M.Id WHERE S.EventId = ? AND S.FrameId = ? ORDER BY S.ZoneId'; + $sql = 'SELECT S.*,E.*,Z.Name AS ZoneName,Z.Units,Z.Area,Z.Coords,M.Name AS MonitorName,M.Width,M.Height FROM Stats AS S LEFT JOIN Events AS E ON S.EventId = E.Id LEFT JOIN Zones AS Z ON S.ZoneId = Z.Id LEFT JOIN Monitors AS M ON E.MonitorId = M.Id WHERE S.EventId = ? AND S.FrameId = ? ORDER BY S.ZoneId'; $stats = dbFetchAll( $sql, NULL, array( $eid, $fid ) ); $result .= ''.PHP_EOL; $result .= ''.PHP_EOL; - $result .= ''.PHP_EOL; - $result .= ''.PHP_EOL; - $result .= ''.PHP_EOL; + $result .= ''.PHP_EOL; + $result .= ''.PHP_EOL; + $result .= ''.PHP_EOL; $result .= ''.PHP_EOL; - + if ( $stat['Blobs'] > 1 ) { - $result .= ''.PHP_EOL; + $result .= ''.PHP_EOL; } else { - $result .= ''.PHP_EOL; + $result .= ''.PHP_EOL; } $result .= ''.PHP_EOL;
' .validHtmlStr($stat['PixelDiff']). '' .sprintf( "%d (%d%%)", $stat['AlarmPixels'], (100*$stat['AlarmPixels']/$stat['Area']) ). '' .sprintf( "%d (%d%%)", $stat['FilterPixels'], (100*$stat['FilterPixels']/$stat['Area']) ).'' .sprintf( "%d (%d%%)", $stat['BlobPixels'], (100*$stat['BlobPixels']/$stat['Area']) ). '' .sprintf( "%d (%d%%)", $stat['AlarmPixels'], (100*$stat['AlarmPixels']/$pixelArea) ). '' .sprintf( "%d (%d%%)", $stat['FilterPixels'], (100*$stat['FilterPixels']/$pixelArea) ).'' .sprintf( "%d (%d%%)", $stat['BlobPixels'], (100*$stat['BlobPixels']/$pixelArea) ). '' .validHtmlStr($stat['Blobs']). '' .sprintf( "%d-%d (%d%%-%d%%)", $stat['MinBlobSize'], $stat['MaxBlobSize'], (100*$stat['MinBlobSize']/$stat['Area']), (100*$stat['MaxBlobSize']/$stat['Area']) ). '' .sprintf( "%d-%d (%d%%-%d%%)", $stat['MinBlobSize'], $stat['MaxBlobSize'], (100*$stat['MinBlobSize']/$pixelArea), (100*$stat['MaxBlobSize']/$pixelArea) ). '' .sprintf( "%d (%d%%)", $stat['MinBlobSize'], 100*$stat['MinBlobSize']/$stat['Area'] ). '' .sprintf( "%d (%d%%)", $stat['MinBlobSize'], 100*$stat['MinBlobSize']/$pixelArea ). '' .validHtmlStr($stat['MinX'].",".$stat['MinY']."-".$stat['MaxX'].",".$stat['MaxY']). '