Skip to content

Commit c438576

Browse files
SteveGilvarryclaude
andcommitted
Fix default zone creation to account for monitor rotation
When creating a new monitor with Orientation set to ROTATE_90 or ROTATE_270, the default "All" zone dimensions are now correctly swapped to match the rotated image dimensions. This prevents zm_zone.cpp from reporting that zones extend outside of image dimensions and having to fix them at runtime. Fixes issue where monitors created with Rotate Right or Rotate Left would generate warnings like: "Zone 1/All for monitor X extends outside of image dimensions, (0,0), (3839,2159) != (2160,3840), fixing" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent ac7b84c commit c438576

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

web/includes/actions/monitor.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,25 @@
261261

262262
if ( $monitor->insert($changes) ) {
263263
$mid = $monitor->Id();
264-
$zoneArea = $newMonitor['Width'] * $newMonitor['Height'];
264+
// Adjust zone dimensions if monitor has rotation applied
265+
$zoneWidth = $newMonitor['Width'];
266+
$zoneHeight = $newMonitor['Height'];
267+
if (isset($newMonitor['Orientation']) &&
268+
($newMonitor['Orientation'] == 'ROTATE_90' || $newMonitor['Orientation'] == 'ROTATE_270')) {
269+
// Swap dimensions for 90/270 degree rotations
270+
$zoneWidth = $newMonitor['Height'];
271+
$zoneHeight = $newMonitor['Width'];
272+
}
273+
$zoneArea = $zoneWidth * $zoneHeight;
265274
$zone = new ZM\Zone();
266275
if (!$zone->save(['MonitorId'=>$monitor->Id(), 'Name'=>'All', 'Coords'=>
267276
sprintf( '%d,%d %d,%d %d,%d %d,%d', 0, 0,
268-
$newMonitor['Width']-1,
277+
$zoneWidth-1,
269278
0,
270-
$newMonitor['Width']-1,
271-
$newMonitor['Height']-1,
279+
$zoneWidth-1,
280+
$zoneHeight-1,
272281
0,
273-
$newMonitor['Height']-1),
282+
$zoneHeight-1),
274283
'Area'=>$zoneArea,
275284
'MinAlarmPixels'=>intval(($zoneArea*.05)/100),
276285
'MaxAlarmPixels'=>intval(($zoneArea*75)/100),

0 commit comments

Comments
 (0)