Added prealarm state and minimum alarm frames.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1109 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
12e785241a
commit
438a5c2b74
|
@ -4,8 +4,9 @@
|
|||
-- Make changes to Monitors table
|
||||
--
|
||||
alter table Monitors add column EventPrefix varchar(32) not null default 'Event-' after Orientation;
|
||||
alter table Monitors add column AlarmFrameCount smallint(5) unsigned not null default '1' after PostEventCount;
|
||||
--
|
||||
-- These are optional, but we might as well
|
||||
-- These are optional, but we might as well do it now
|
||||
--
|
||||
optimize table Frames;
|
||||
optimize table Events;
|
||||
|
|
|
@ -119,6 +119,7 @@ CREATE TABLE Monitors (
|
|||
WarmupCount smallint(5) unsigned NOT NULL default '25',
|
||||
PreEventCount smallint(5) unsigned NOT NULL default '10',
|
||||
PostEventCount smallint(5) unsigned NOT NULL default '10',
|
||||
AlarmFrameCount smallint(5) unsigned NOT NULL default '1',
|
||||
SectionLength int(10) unsigned NOT NULL default '600',
|
||||
FrameSkip smallint(5) unsigned NOT NULL default '0',
|
||||
MaxFPS decimal(5,2) NOT NULL default '0.00',
|
||||
|
|
|
@ -323,7 +323,7 @@ sub runServer
|
|||
if ( defined( $monitor->{LastState} ) )
|
||||
{
|
||||
my $task_list;
|
||||
if ( $state == 1 && $monitor->{LastState} == 0 ) # Gone into alarm state
|
||||
if ( $state == 2 && $monitor->{LastState} == 0 ) # Gone into alarm state
|
||||
{
|
||||
print( "Applying ON_list for $monitor_id\n" ) if ( main::VERBOSE );
|
||||
$task_list = $monitor->{"ON_list"};
|
||||
|
|
|
@ -39,6 +39,9 @@ char Event::capture_file_format[PATH_MAX];
|
|||
char Event::analyse_file_format[PATH_MAX];
|
||||
char Event::general_file_format[PATH_MAX];
|
||||
|
||||
int Event::pre_alarm_count = 0;
|
||||
Event::PreAlarmData Event::pre_alarm_data[MAX_PRE_ALARM_FRAMES] = { 0 };
|
||||
|
||||
Event::Event( Monitor *p_monitor, struct timeval p_start_time ) : monitor( p_monitor ), start_time( p_start_time )
|
||||
{
|
||||
if ( !initialised )
|
||||
|
@ -85,7 +88,7 @@ Event::~Event()
|
|||
|
||||
Debug( 1, ( "Adding closing frame %d to DB", frames ));
|
||||
static char sql[BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Delta ) values ( %d, %d, %s%ld.%02ld )", id, frames, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ( %d, %d, from_unixtime( %d ), %s%ld.%02ld )", id, frames, end_time.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert frame: %s", mysql_error( &dbconn ) ));
|
||||
|
@ -262,7 +265,7 @@ bool Event::WriteFrameImage( Image *image, struct timeval timestamp, const char
|
|||
void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps )
|
||||
{
|
||||
static char sql[BUFSIZ];
|
||||
strncpy( sql, "insert into Frames ( EventId, FrameId, Delta ) values ", BUFSIZ );
|
||||
strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", BUFSIZ );
|
||||
for ( int i = 0; i < n_frames; i++ )
|
||||
{
|
||||
frames++;
|
||||
|
@ -277,7 +280,7 @@ void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps
|
|||
DELTA_TIMEVAL( delta_time, *(timestamps[i]), start_time, DT_PREC_2 );
|
||||
|
||||
int sql_len = strlen(sql);
|
||||
snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, %s%ld.%02ld ), ", id, frames, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
snprintf( sql+sql_len, sizeof(sql)-sql_len, "( %d, %d, from_unixtime(%d), %s%ld.%02ld ), ", id, frames, timestamps[i]->tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec );
|
||||
}
|
||||
|
||||
Debug( 1, ( "Adding %d frames to DB", n_frames ));
|
||||
|
@ -312,7 +315,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image *
|
|||
|
||||
Debug( 1, ( "Adding frame %d to DB", frames ));
|
||||
static char sql[BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, Delta, Score ) values ( %d, %d, '%s', %s%ld.%02ld, %d )", id, frames, frame_type, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
|
||||
snprintf( sql, sizeof(sql), "insert into Frames ( EventId, FrameId, Type, TimeStamp, Delta, Score ) values ( %d, %d, '%s', from_unixtime( %d ), %s%ld.%02ld, %d )", id, frames, frame_type, timestamp.tv_sec, delta_time.positive?"":"-", delta_time.sec, delta_time.fsec, score );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't insert frame: %s", mysql_error( &dbconn ) ));
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
class Monitor;
|
||||
|
||||
#define MAX_PRE_ALARM_FRAMES 16 // Maximum number of prealarm frames that can be stored
|
||||
|
||||
//
|
||||
// Class describing events, i.e. captured periods of activity.
|
||||
//
|
||||
|
@ -52,6 +54,18 @@ protected:
|
|||
protected:
|
||||
static int sd;
|
||||
|
||||
protected:
|
||||
struct PreAlarmData
|
||||
{
|
||||
Image *image;
|
||||
struct timeval timestamp;
|
||||
unsigned int score;
|
||||
Image *alarm_frame;
|
||||
};
|
||||
|
||||
static int pre_alarm_count;
|
||||
static PreAlarmData pre_alarm_data[MAX_PRE_ALARM_FRAMES];
|
||||
|
||||
protected:
|
||||
int id;
|
||||
Monitor *monitor;
|
||||
|
@ -104,6 +118,45 @@ public:
|
|||
#if HAVE_LIBAVCODEC
|
||||
static void StreamMpeg( int event_id, const char *format, int scale=100, int rate=100, int maxfps=10, int bitrate=100000 );
|
||||
#endif // HAVE_LIBAVCODEC
|
||||
|
||||
public:
|
||||
static int PreAlarmCount()
|
||||
{
|
||||
return( pre_alarm_count );
|
||||
}
|
||||
static void EmptyPreAlarmFrames()
|
||||
{
|
||||
if ( pre_alarm_count > 0 )
|
||||
{
|
||||
for ( int i = 0; i < MAX_PRE_ALARM_FRAMES; i++ )
|
||||
{
|
||||
delete pre_alarm_data[i].image;
|
||||
delete pre_alarm_data[i].alarm_frame;
|
||||
}
|
||||
memset( pre_alarm_data, 0, sizeof(pre_alarm_data) );
|
||||
}
|
||||
pre_alarm_count = 0;
|
||||
}
|
||||
static void AddPreAlarmFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL )
|
||||
{
|
||||
pre_alarm_data[pre_alarm_count].image = new Image( *image );
|
||||
pre_alarm_data[pre_alarm_count].timestamp = timestamp;
|
||||
pre_alarm_data[pre_alarm_count].score = score;
|
||||
if ( alarm_frame )
|
||||
{
|
||||
pre_alarm_data[pre_alarm_count].alarm_frame = new Image( *alarm_frame );
|
||||
}
|
||||
pre_alarm_count++;
|
||||
}
|
||||
void SavePreAlarmFrames()
|
||||
{
|
||||
for ( int i = 0; i < pre_alarm_count; i++ )
|
||||
{
|
||||
AddFrame( pre_alarm_data[i].image, pre_alarm_data[i].timestamp, pre_alarm_data[i].score, pre_alarm_data[i].alarm_frame );
|
||||
}
|
||||
EmptyPreAlarmFrames();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // ZM_EVENT_H
|
||||
|
|
|
@ -54,6 +54,7 @@ Monitor::Monitor(
|
|||
int p_warmup_count,
|
||||
int p_pre_event_count,
|
||||
int p_post_event_count,
|
||||
int p_alarm_frame_count,
|
||||
int p_section_length,
|
||||
int p_frame_skip,
|
||||
int p_capture_delay,
|
||||
|
@ -72,6 +73,7 @@ Monitor::Monitor(
|
|||
warmup_count( p_warmup_count ),
|
||||
pre_event_count( p_pre_event_count ),
|
||||
post_event_count( p_post_event_count ),
|
||||
alarm_frame_count( p_alarm_frame_count ),
|
||||
section_length( p_section_length ),
|
||||
frame_skip( p_frame_skip ),
|
||||
capture_delay( p_capture_delay ),
|
||||
|
@ -112,6 +114,7 @@ Monitor::Monitor(
|
|||
int p_warmup_count,
|
||||
int p_pre_event_count,
|
||||
int p_post_event_count,
|
||||
int p_alarm_frame_count,
|
||||
int p_section_length,
|
||||
int p_frame_skip,
|
||||
int p_capture_delay,
|
||||
|
@ -130,6 +133,7 @@ Monitor::Monitor(
|
|||
warmup_count( p_warmup_count ),
|
||||
pre_event_count( p_pre_event_count ),
|
||||
post_event_count( p_post_event_count ),
|
||||
alarm_frame_count( p_alarm_frame_count ),
|
||||
section_length( p_section_length ),
|
||||
frame_skip( p_frame_skip ),
|
||||
capture_delay( p_capture_delay ),
|
||||
|
@ -199,6 +203,11 @@ void Monitor::Setup()
|
|||
last_alarm_count = 0;
|
||||
state = IDLE;
|
||||
|
||||
if ( alarm_frame_count < 1 )
|
||||
alarm_frame_count = 1;
|
||||
else if ( alarm_frame_count > MAX_PRE_ALARM_FRAMES )
|
||||
alarm_frame_count = MAX_PRE_ALARM_FRAMES;
|
||||
|
||||
Debug( 1, ( "monitor purpose=%d", purpose ));
|
||||
|
||||
int shared_data_size = sizeof(SharedData)+(image_buffer_count*sizeof(time_t))+(image_buffer_count*camera->ImageSize());
|
||||
|
@ -259,7 +268,7 @@ void Monitor::Setup()
|
|||
|
||||
Debug( 1, ( "Monitor %s has function %d", name, function ));
|
||||
Debug( 1, ( "Monitor %s LBF = '%s', LBX = %d, LBY = %d", name, label_format, label_coord.X(), label_coord.Y() ));
|
||||
Debug( 1, ( "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, FRI = %d, RBP = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, fps_report_interval, ref_blend_perc ));
|
||||
Debug( 1, ( "Monitor %s IBC = %d, WUC = %d, pEC = %d, PEC = %d, EAF = %d, FRI = %d, RBP = %d", name, image_buffer_count, warmup_count, pre_event_count, post_event_count, alarm_frame_count, fps_report_interval, ref_blend_perc ));
|
||||
|
||||
if ( purpose == ANALYSIS )
|
||||
{
|
||||
|
@ -712,33 +721,62 @@ bool Monitor::Analyse()
|
|||
}
|
||||
if ( score )
|
||||
{
|
||||
if ( state == IDLE || state == TAPE )
|
||||
if ( (state == IDLE || state == TAPE || state == PREALARM ) )
|
||||
{
|
||||
Info(( "%s: %03d - Gone into alarm state", name, image_count ));
|
||||
if ( function != MOCORD )
|
||||
if ( Event::PreAlarmCount() >= (alarm_frame_count-1) )
|
||||
{
|
||||
event = new Event( this, *timestamp );
|
||||
|
||||
int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count;
|
||||
if ( !timestamps ) timestamps = new struct timeval *[pre_event_count];
|
||||
if ( !images ) images = new Image *[pre_event_count];
|
||||
for ( int i = 0; i < pre_event_count; i++ )
|
||||
Info(( "%s: %03d - Gone into alarm state", name, image_count ));
|
||||
if ( function != MOCORD && state != ALERT )
|
||||
{
|
||||
timestamps[i] = image_buffer[pre_index].timestamp;
|
||||
images[i] = image_buffer[pre_index].image;
|
||||
int pre_index;
|
||||
|
||||
pre_index = (pre_index+1)%image_buffer_count;
|
||||
if ( alarm_frame_count > 1 )
|
||||
{
|
||||
int ts_index = ((index+image_buffer_count)-(alarm_frame_count-1))%image_buffer_count;
|
||||
event = new Event( this, *(image_buffer[ts_index].timestamp) );
|
||||
pre_index = ((index+image_buffer_count)-((alarm_frame_count-1)+pre_event_count))%image_buffer_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
event = new Event( this, *timestamp );
|
||||
pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count;
|
||||
}
|
||||
|
||||
if ( !timestamps ) timestamps = new struct timeval *[pre_event_count];
|
||||
if ( !images ) images = new Image *[pre_event_count];
|
||||
for ( int i = 0; i < pre_event_count; i++ )
|
||||
{
|
||||
timestamps[i] = image_buffer[pre_index].timestamp;
|
||||
images[i] = image_buffer[pre_index].image;
|
||||
|
||||
pre_index = (pre_index+1)%image_buffer_count;
|
||||
}
|
||||
event->AddFrames( pre_event_count, images, timestamps );
|
||||
if ( alarm_frame_count )
|
||||
{
|
||||
event->SavePreAlarmFrames();
|
||||
}
|
||||
}
|
||||
event->AddFrames( pre_event_count, images, timestamps );
|
||||
shared_data->state = state = ALARM;
|
||||
}
|
||||
else if ( state != PREALARM )
|
||||
{
|
||||
Info(( "%s: %03d - Gone into prealarm state", name, image_count ));
|
||||
shared_data->state = state = PREALARM;
|
||||
}
|
||||
}
|
||||
shared_data->state = state = ALARM;
|
||||
else if ( state == ALERT )
|
||||
{
|
||||
Info(( "%s: %03d - Gone back into alarm state", name, image_count ));
|
||||
shared_data->state = state = ALARM;
|
||||
}
|
||||
last_alarm_count = image_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( state == ALARM )
|
||||
{
|
||||
Info(( "%s: %03d - Gone into alert state", name, image_count ));
|
||||
shared_data->state = state = ALERT;
|
||||
}
|
||||
else if ( state == ALERT )
|
||||
|
@ -759,10 +797,23 @@ bool Monitor::Analyse()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ( state == PREALARM )
|
||||
{
|
||||
if ( function != MOCORD )
|
||||
{
|
||||
shared_data->state = state = IDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
shared_data->state = state = TAPE;
|
||||
}
|
||||
}
|
||||
if ( Event::PreAlarmCount() )
|
||||
Event::EmptyPreAlarmFrames();
|
||||
}
|
||||
if ( state != IDLE )
|
||||
{
|
||||
if ( state == ALARM )
|
||||
if ( state == PREALARM || state == ALARM )
|
||||
{
|
||||
if ( create_analysis_images )
|
||||
{
|
||||
|
@ -777,7 +828,7 @@ bool Monitor::Analyse()
|
|||
alarm_image.Overlay( *(zones[i]->AlarmImage()) );
|
||||
got_anal_image = true;
|
||||
}
|
||||
if ( record_event_stats )
|
||||
if ( record_event_stats && state == ALARM )
|
||||
{
|
||||
zones[i]->RecordStats( event );
|
||||
}
|
||||
|
@ -785,16 +836,25 @@ bool Monitor::Analyse()
|
|||
}
|
||||
if ( got_anal_image )
|
||||
{
|
||||
event->AddFrame( snap_image, *timestamp, score, &alarm_image );
|
||||
if ( state == PREALARM )
|
||||
Event::AddPreAlarmFrame( snap_image, *timestamp, score, &alarm_image );
|
||||
else
|
||||
event->AddFrame( snap_image, *timestamp, score, &alarm_image );
|
||||
}
|
||||
else
|
||||
{
|
||||
event->AddFrame( snap_image, *timestamp, score );
|
||||
if ( state == PREALARM )
|
||||
Event::AddPreAlarmFrame( snap_image, *timestamp, score );
|
||||
else
|
||||
event->AddFrame( snap_image, *timestamp, score );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
event->AddFrame( snap_image, *timestamp, score );
|
||||
if ( state == PREALARM )
|
||||
Event::AddPreAlarmFrame( snap_image, *timestamp, score );
|
||||
else
|
||||
event->AddFrame( snap_image, *timestamp, score );
|
||||
}
|
||||
}
|
||||
else if ( state == ALERT )
|
||||
|
@ -865,11 +925,11 @@ int Monitor::Load( int device, Monitor **&monitors, Purpose purpose )
|
|||
static char sql[BUFSIZ];
|
||||
if ( device == -1 )
|
||||
{
|
||||
strncpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local'", sizeof(sql) );
|
||||
strncpy( sql, "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local'", sizeof(sql) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local' and Device = %d", device );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Device, Channel, Format, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Local' and Device = %d", device );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -907,11 +967,12 @@ int Monitor::Load( int device, Monitor **&monitors, Purpose purpose )
|
|||
atoi(dbrow[15]), // WarmupCount
|
||||
atoi(dbrow[16]), // PreEventCount
|
||||
atoi(dbrow[17]), // PostEventCount
|
||||
atoi(dbrow[18]), // SectionLength
|
||||
atoi(dbrow[19]), // FrameSkip
|
||||
atof(dbrow[20])>0.0?int(DT_PREC_3/atof(dbrow[20])):0, // MaxFPS
|
||||
atoi(dbrow[21]), // FPSReportInterval
|
||||
atoi(dbrow[22]), // RefBlendPerc
|
||||
atoi(dbrow[18]), // AlarmFrameCount
|
||||
atoi(dbrow[19]), // SectionLength
|
||||
atoi(dbrow[20]), // FrameSkip
|
||||
atof(dbrow[21])>0.0?int(DT_PREC_3/atof(dbrow[21])):0, // MaxFPS
|
||||
atoi(dbrow[22]), // FPSReportInterval
|
||||
atoi(dbrow[23]), // RefBlendPerc
|
||||
purpose
|
||||
);
|
||||
Zone **zones = 0;
|
||||
|
@ -935,11 +996,11 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor
|
|||
static char sql[BUFSIZ];
|
||||
if ( !host )
|
||||
{
|
||||
strncpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) );
|
||||
strncpy( sql, "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote'", sizeof(sql) );
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote' and Host = '%s' and Port = '%s' and Path = '%s'", host, port, path );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Function+0, Host, Port, Path, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Function != 'None' and Type = 'Remote' and Host = '%s' and Port = '%s' and Path = '%s'", host, port, path );
|
||||
}
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
|
@ -977,11 +1038,12 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor
|
|||
atoi(dbrow[15]), // WarmupCount
|
||||
atoi(dbrow[16]), // PreEventCount
|
||||
atoi(dbrow[17]), // PostEventCount
|
||||
atoi(dbrow[18]), // SectionLength
|
||||
atoi(dbrow[19]), // FrameSkip
|
||||
atof(dbrow[20])>0.0?int(DT_PREC_3/atof(dbrow[20])):0, // MaxFPS
|
||||
atoi(dbrow[21]), // FPSReportInterval
|
||||
atoi(dbrow[22]), // RefBlendPerc
|
||||
atoi(dbrow[18]), // AlarmFrameCount
|
||||
atoi(dbrow[19]), // SectionLength
|
||||
atoi(dbrow[20]), // FrameSkip
|
||||
atof(dbrow[21])>0.0?int(DT_PREC_3/atof(dbrow[21])):0, // MaxFPS
|
||||
atoi(dbrow[22]), // FPSReportInterval
|
||||
atoi(dbrow[23]), // RefBlendPerc
|
||||
purpose
|
||||
);
|
||||
Zone **zones = 0;
|
||||
|
@ -1003,7 +1065,7 @@ int Monitor::Load( const char *host, const char*port, const char *path, Monitor
|
|||
Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
|
||||
{
|
||||
static char sql[BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id );
|
||||
snprintf( sql, sizeof(sql), "select Id, Name, Type, Function+0, Device, Channel, Format, Host, Port, Path, Width, Height, Palette, Orientation+0, EventPrefix, LabelFormat, LabelX, LabelY, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, AlarmFrameCount, SectionLength, FrameSkip, MaxFPS, FPSReportInterval, RefBlendPerc from Monitors where Id = %d", id );
|
||||
if ( mysql_query( &dbconn, sql ) )
|
||||
{
|
||||
Error(( "Can't run query: %s", mysql_error( &dbconn ) ));
|
||||
|
@ -1041,11 +1103,12 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
|
|||
atoi(dbrow[19]), // WarmupCount
|
||||
atoi(dbrow[20]), // PreEventCount
|
||||
atoi(dbrow[21]), // PostEventCount
|
||||
atoi(dbrow[22]), // SectionLength
|
||||
atoi(dbrow[23]), // FrameSkip
|
||||
atof(dbrow[24])>0.0?int(DT_PREC_3/atof(dbrow[24])):0, // MaxFPS
|
||||
atoi(dbrow[25]), // FPSReportInterval
|
||||
atoi(dbrow[26]), // RefBlendPerc
|
||||
atoi(dbrow[22]), // AlarmFrameCount
|
||||
atoi(dbrow[23]), // SectionLength
|
||||
atoi(dbrow[24]), // FrameSkip
|
||||
atof(dbrow[25])>0.0?int(DT_PREC_3/atof(dbrow[25])):0, // MaxFPS
|
||||
atoi(dbrow[26]), // FPSReportInterval
|
||||
atoi(dbrow[27]), // RefBlendPerc
|
||||
purpose
|
||||
);
|
||||
}
|
||||
|
@ -1069,11 +1132,12 @@ Monitor *Monitor::Load( int id, bool load_zones, Purpose purpose )
|
|||
atoi(dbrow[19]), // WarmupCount
|
||||
atoi(dbrow[20]), // PreEventCount
|
||||
atoi(dbrow[21]), // PostEventCount
|
||||
atoi(dbrow[22]), // SectionLength
|
||||
atoi(dbrow[23]), // FrameSkip
|
||||
atof(dbrow[24])>0.0?int(DT_PREC_3/atof(dbrow[24])):0, // MaxFPS
|
||||
atoi(dbrow[25]), // FPSReportInterval
|
||||
atoi(dbrow[26]), // RefBlendPerc
|
||||
atoi(dbrow[22]), // AlarmFrameCount
|
||||
atoi(dbrow[23]), // SectionLength
|
||||
atoi(dbrow[24]), // FrameSkip
|
||||
atof(dbrow[25])>0.0?int(DT_PREC_3/atof(dbrow[25])):0, // MaxFPS
|
||||
atoi(dbrow[26]), // FPSReportInterval
|
||||
atoi(dbrow[27]), // RefBlendPerc
|
||||
purpose
|
||||
);
|
||||
}
|
||||
|
@ -1322,6 +1386,7 @@ bool Monitor::DumpSettings( char *output, bool verbose )
|
|||
sprintf( output+strlen(output), "Warmup Count : %d\n", warmup_count );
|
||||
sprintf( output+strlen(output), "Pre Event Count : %d\n", pre_event_count );
|
||||
sprintf( output+strlen(output), "Post Event Count : %d\n", post_event_count );
|
||||
sprintf( output+strlen(output), "Alarm Frame Count : %d\n", alarm_frame_count );
|
||||
sprintf( output+strlen(output), "Section Length : %d\n", section_length );
|
||||
sprintf( output+strlen(output), "Maximum FPS : %.2f\n", capture_delay?DT_PREC_3/capture_delay:0.0 );
|
||||
sprintf( output+strlen(output), "Reference Blend %%ge : %d\n", ref_blend_perc );
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
typedef enum { ROTATE_0=1, ROTATE_90, ROTATE_180, ROTATE_270 } Orientation;
|
||||
|
||||
typedef enum { IDLE, ALARM, ALERT, TAPE } State;
|
||||
typedef enum { IDLE, PREALARM, ALARM, ALERT, TAPE } State;
|
||||
|
||||
protected:
|
||||
static bool initialised;
|
||||
|
@ -91,6 +91,7 @@ protected:
|
|||
int section_length; // How long events should last in continuous modes
|
||||
int frame_skip; // How many frames to skip in continuous modes
|
||||
int capture_delay; // How long we wait between capture frames
|
||||
int alarm_frame_count; // How many alarm frames are required before an event is triggered
|
||||
int fps_report_interval;// How many images should be captured/processed between reporting the current FPS
|
||||
int ref_blend_perc; // Percentage of new image going into reference image.
|
||||
|
||||
|
@ -104,6 +105,7 @@ protected:
|
|||
int first_alarm_count;
|
||||
int last_alarm_count;
|
||||
int buffer_count;
|
||||
int prealarm_count;
|
||||
State state;
|
||||
int n_zones;
|
||||
Zone **zones;
|
||||
|
@ -158,8 +160,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, char *p_name, int p_function, int p_device, int p_channel, int p_format, int p_width, int p_height, int p_palette, int p_orientation, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
Monitor( int p_id, char *p_name, int p_function, const char *p_host, const char *p_port, const char *p_path, int p_width, int p_height, int p_palette, int p_orientation, char *p_event_prefix, char *p_label_format, const Coord &p_label_coord, int p_image_buffer_count, int p_warmup_count, int p_pre_event_count, int p_post_event_count, int p_alarm_frame_count, int p_section_length, int p_frame_skip, int p_capture_delay, int p_fps_report_interval, int p_ref_blend_perc, Purpose p_purpose=QUERY, int p_n_zones=0, Zone *p_zones[]=0 );
|
||||
~Monitor();
|
||||
|
||||
void Setup();
|
||||
|
|
|
@ -75,6 +75,7 @@ else
|
|||
$monitor['WarmupCount'] = 25;
|
||||
$monitor['PreEventCount'] = 10;
|
||||
$monitor['PostEventCount'] = 10;
|
||||
$monitor['AlarmFrameCount'] = 1;
|
||||
$monitor['SectionLength'] = 600;
|
||||
$monitor['FrameSkip'] = 0;
|
||||
$monitor['EventPrefix'] = 'Event-';
|
||||
|
@ -225,6 +226,7 @@ if ( $tab != 'buffers' )
|
|||
<input type="hidden" name="new_monitor[WarmupCount]" value="<?= $new_monitor['WarmupCount'] ?>">
|
||||
<input type="hidden" name="new_monitor[PreEventCount]" value="<?= $new_monitor['PreEventCount'] ?>">
|
||||
<input type="hidden" name="new_monitor[PostEventCount]" value="<?= $new_monitor['PostEventCount'] ?>">
|
||||
<input type="hidden" name="new_monitor[AlarmFrameCount]" value="<?= $new_monitor['AlarmFrameCount'] ?>">
|
||||
<?php
|
||||
}
|
||||
if ( $tab != 'misc' )
|
||||
|
@ -353,6 +355,7 @@ switch ( $tab )
|
|||
<tr><td align="left" class="text"><?= $zmSlangWarmupFrames ?></td><td align="left" class="text"><input type="text" name="new_monitor[WarmupCount]" value="<?= $new_monitor['WarmupCount'] ?>" size="4" class="form"></td></tr>
|
||||
<tr><td align="left" class="text"><?= $zmSlangPreEventImageBuffer ?></td><td align="left" class="text"><input type="text" name="new_monitor[PreEventCount]" value="<?= $new_monitor['PreEventCount'] ?>" size="4" class="form"></td></tr>
|
||||
<tr><td align="left" class="text"><?= $zmSlangPostEventImageBuffer ?></td><td align="left" class="text"><input type="text" name="new_monitor[PostEventCount]" value="<?= $new_monitor['PostEventCount'] ?>" size="4" class="form"></td></tr>
|
||||
<tr><td align="left" class="text"><?= $zmSlangAlarmFrameCount ?></td><td align="left" class="text"><input type="text" name="new_monitor[AlarmFrameCount]" value="<?= $new_monitor['AlarmFrameCount'] ?>" size="4" class="form"></td></tr>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue