Esempio n. 1
0
if (!isset($newZone)) {
    if ($zid > 0) {
        $zone = dbFetchOne('SELECT * FROM Zones WHERE MonitorId = ? AND Id=?', NULL, array($monitor['Id'], $zid));
    } else {
        $zone = array('Name' => translate('New'), 'Id' => 0, 'MonitorId' => $monitor['Id'], 'NumCoords' => 4, 'Coords' => sprintf("%d,%d %d,%d, %d,%d %d,%d", $minX, $minY, $maxX, $minY, $maxX, $maxY, $minX, $maxY), 'Area' => $monitor['Width'] * $monitor['Height'], 'AlarmRGB' => 0xff0000, 'CheckMethod' => 'Blobs', 'MinPixelThreshold' => '', 'MaxPixelThreshold' => '', 'MinAlarmPixels' => '', 'MaxAlarmPixels' => '', 'FilterX' => '', 'FilterY' => '', 'MinFilterPixels' => '', 'MaxFilterPixels' => '', 'MinBlobPixels' => '', 'MaxBlobPixels' => '', 'MinBlobs' => '', 'MaxBlobs' => '', 'OverloadFrames' => '', 'ExtendAlarmFrames' => '');
    }
    $zone['Points'] = coordsToPoints($zone['Coords']);
    $newZone = $zone;
}
//if ( !$points )
//{
//$points = $zone['Points'];
//}
ksort($newZone['Points'], SORT_NUMERIC);
$newZone['Coords'] = pointsToCoords($newZone['Points']);
$newZone['Area'] = getPolyArea($newZone['Points']);
$selfIntersecting = isSelfIntersecting($newZone['Points']);
$wd = getcwd();
chdir(ZM_DIR_IMAGES);
$command = getZmuCommand(" -m " . $mid . " -z");
$command .= '"' . $zid . ' ' . $hicolor . ' ' . $newZone['Coords'] . '"';
$status = exec(escapeshellcmd($command));
chdir($wd);
$zoneImage = ZM_DIR_IMAGES . '/Zones' . $monitor['Id'] . '.jpg?' . time();
$focusWindow = true;
xhtmlHeaders(__FILE__, translate('Zone'));
?>
<body>
  <div id="page">
    <div id="header">
      <h2><?php 
Esempio n. 2
0
function getPolyCentre($points, $area = 0)
{
    $cx = 0.0;
    $cy = 0.0;
    if (!$area) {
        $area = getPolyArea($points);
    }
    for ($i = 0, $j = count($points) - 1; $i < count($points); $j = $i++) {
        $ct = $points[$i]['x'] * $points[$j]['y'] - $points[$j]['x'] * $points[$i]['y'];
        $cx += ($points[$i]['x'] + $points[$j]['x']) * ct;
        $cy += ($points[$i]['y'] + $points[$j]['y']) * ct;
    }
    $cx = intval(round(abs($cx / (6.0 * $area))));
    $cy = intval(round(abs($cy / (6.0 * $area))));
    printf("X:%cx, Y:{$cy}<br>");
    return array('x' => $cx, 'y' => $cy);
}
Esempio n. 3
0
<?php

if (empty($_REQUEST['mid'])) {
    ajaxError('No monitor id supplied');
} elseif (!isset($_REQUEST['zid'])) {
    ajaxError('No zone id(s) supplied');
}
if (canView('Monitors')) {
    switch ($_REQUEST['action']) {
        case "zoneImage":
            $wd = getcwd();
            chdir(ZM_DIR_IMAGES);
            $hiColor = '0x00ff00';
            $command = getZmuCommand(" -m " . $_REQUEST['mid'] . " -z");
            if (!isset($_REQUEST['zid'])) {
                $_REQUEST['zid'] = 0;
            }
            $command .= "'" . $_REQUEST['zid'] . ' ' . $hiColor . ' ' . $_REQUEST['coords'] . "'";
            $status = exec(escapeshellcmd($command));
            chdir($wd);
            $monitor = dbFetchOne('SELECT * FROM Monitors WHERE Id = ?', NULL, array($_REQUEST['mid']));
            $points = coordsToPoints($_REQUEST['coords']);
            ajaxResponse(array('zoneImage' => ZM_DIR_IMAGES . '/Zones' . $monitor['Id'] . '.jpg?' . time(), 'selfIntersecting' => isSelfIntersecting($points), 'area' => getPolyArea($points)));
            break;
    }
}
ajaxError('Unrecognised action or insufficient permissions');