Added Preventive zone type.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@473 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2003-04-13 12:20:00 +00:00
parent a0e29e0401
commit aa1164a0e3
6 changed files with 93 additions and 32 deletions

View File

@ -4,6 +4,7 @@
alter table Monitors change column Colours Palette tinyint(3) unsigned NOT NULL default '1';
update Monitors set Palette = 1 where Palette = 8;
update Monitors set Palette = 4 where Palette = 24;
alter table Zones modify column Type enum('Active','Inclusive','Exclusive','Inactive','Preventive') not null default 'Active';
-- These are optional, it just seemed a good time...
optimize table Frames;
optimize table Events;

View File

@ -618,14 +618,14 @@ int LocalCamera::PostCapture( Image &image )
}
case VIDEO_PALETTE_GREY :
{
int size = width*height;
for ( int i = 0; i < size; i++ )
{
if ( buffer[i] < 16 )
Info(( "Lo grey %d", buffer[i] ));
if ( buffer[i] > 235 )
Info(( "Hi grey %d", buffer[i] ));
}
//int size = width*height;
//for ( int i = 0; i < size; i++ )
//{
//if ( buffer[i] < 16 )
//Info(( "Lo grey %d", buffer[i] ));
//if ( buffer[i] > 235 )
//Info(( "Hi grey %d", buffer[i] ));
//}
}
default : // Everything else is straightforward, for now.
{

View File

@ -786,6 +786,31 @@ unsigned int Monitor::Compare( const Image &image )
delta_image->Fill( RGB_BLACK, &(zone->Limits()) );
}
// Check preventive zones first
for ( int n_zone = 0; n_zone < n_zones; n_zone++ )
{
Zone *zone = zones[n_zone];
if ( !zone->IsPreventive() )
{
continue;
}
Debug( 3, ( "Checking preventive zone %s", zone->Label() ));
if ( zone->CheckAlarms( delta_image ) )
{
alarm = true;
score += zone->Score();
Debug( 3, ( "Zone is alarmed, zone score = %d", zone->Score() ));
zone->ResetStats();
}
}
if ( alarm )
{
alarm = false;
score = 0;
}
else
{
// Find all alarm pixels in active zones
for ( int n_zone = 0; n_zone < n_zones; n_zone++ )
{
@ -843,6 +868,7 @@ unsigned int Monitor::Compare( const Image &image )
}
}
}
}
delete delta_image;
// This is a small and innocent hack to prevent scores of 0 being returned in alarm state

View File

@ -478,8 +478,9 @@ bool Zone::DumpSettings( char *output, bool verbose )
type==ACTIVE?"Active":(
type==INCLUSIVE?"Inclusive":(
type==EXCLUSIVE?"Exclusive":(
type==INACTIVE?"Inactive":"Unknown"
))));
type==INACTIVE?"Inactive":(
type==PREVENTIVE?"Preventive":"Unknown"
)))));
sprintf( output+strlen(output), " Limits : %d,%d - %d,%d\n", limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() );
sprintf( output+strlen(output), " Alarm RGB : %06x\n", alarm_rgb );
sprintf( output+strlen(output), " Alarm Threshold : %d\n", alarm_threshold );

View File

@ -35,7 +35,7 @@ class Monitor;
class Zone
{
public:
typedef enum { ACTIVE=1, INCLUSIVE, EXCLUSIVE, INACTIVE } ZoneType;
typedef enum { ACTIVE=1, INCLUSIVE, EXCLUSIVE, INACTIVE, PREVENTIVE } ZoneType;
protected:
// Inputs
@ -98,6 +98,7 @@ public:
inline bool IsInclusive() const { return( type == INCLUSIVE ); }
inline bool IsExclusive() const { return( type == EXCLUSIVE ); }
inline bool IsInactive() const { return( type == INACTIVE ); }
inline bool IsPreventive() const { return( type == PREVENTIVE ); }
inline Image &AlarmImage() const { return( *image ); }
inline const Box &Limits() const { return( limits ); }
inline bool Alarmed() const { return( alarmed ); }

View File

@ -77,7 +77,8 @@ switch( $view )
{
$row['zmc'] = zmcCheck( $row );
$row['zma'] = zmaCheck( $row );
$sql = "select count(Id) as ZoneCount, count(if(Type='Active',1,NULL)) as ActZoneCount, count(if(Type='Inclusive',1,NULL)) as IncZoneCount, count(if(Type='Exclusive',1,NULL)) as ExcZoneCount, count(if(Type='Inactive',1,NULL)) as InactZoneCount from Zones where MonitorId = '$row[Id]'";
//$sql = "select count(Id) as ZoneCount, count(if(Type='Active',1,NULL)) as ActZoneCount, count(if(Type='Inclusive',1,NULL)) as IncZoneCount, count(if(Type='Exclusive',1,NULL)) as ExcZoneCount, count(if(Type='Inactive',1,NULL)) as InactZoneCount from Zones where MonitorId = '$row[Id]'";
$sql = "select count(Id) as ZoneCount from Zones where MonitorId = '$row[Id]'";
$result2 = mysql_query( $sql );
if ( !$result2 )
echo mysql_error();
@ -2247,6 +2248,37 @@ function applyZoneType(theForm)
theForm.new_max_blobs.disabled = true;
theForm.new_max_blobs.value = "";
}
else if ( theForm.new_type.value == 'Preventive' )
{
theForm.new_alarm_rgb_r.disabled = true;
theForm.new_alarm_rgb_r.value = "";
theForm.new_alarm_rgb_g.disabled = true;
theForm.new_alarm_rgb_g.value = "";
theForm.new_alarm_rgb_b.disabled = true;
theForm.new_alarm_rgb_b.value = "";
theForm.new_alarm_threshold.disabled = false;
theForm.new_alarm_threshold.value = "<?= $zone[AlarmThreshold] ?>";
theForm.new_min_alarm_pixels.disabled = false;
theForm.new_min_alarm_pixels.value = "<?= $zone[MinAlarmPixels] ?>";
theForm.new_max_alarm_pixels.disabled = false;
theForm.new_max_alarm_pixels.value = "<?= $zone[MaxAlarmPixels] ?>";
theForm.new_filter_x.disabled = false;
theForm.new_filter_x.value = "<?= $zone[FilterX] ?>";
theForm.new_filter_y.disabled = false;
theForm.new_filter_y.value = "<?= $zone[FilterY] ?>";
theForm.new_min_filter_pixels.disabled = false;
theForm.new_min_filter_pixels.value = "<?= $zone[MinFilterPixels] ?>";
theForm.new_max_filter_pixels.disabled = false;
theForm.new_max_filter_pixels.value = "<?= $zone[MaxFilterPixels] ?>";
theForm.new_min_blob_pixels.disabled = false;
theForm.new_min_blob_pixels.value = "<?= $zone[MinBlobPixels] ?>";
theForm.new_max_blob_pixels.disabled = false;
theForm.new_max_blob_pixels.value = "<?= $zone[MaxBlobPixels] ?>";
theForm.new_min_blobs.disabled = false;
theForm.new_min_blobs.value = "<?= $zone[MinBlobs] ?>";
theForm.new_max_blobs.disabled = false;
theForm.new_max_blobs.value = "<?= $zone[MaxBlobs] ?>";
}
else
{
theForm.new_alarm_rgb_r.disabled = false;