Merge pull request #867 from ZoneMinder/analysis_image_optimisation

analysis optimisations
This commit is contained in:
Andrew Bauer 2015-06-23 08:13:34 -05:00
commit c3fa7ea940
2 changed files with 26 additions and 13 deletions

View File

@ -660,7 +660,7 @@ Monitor::State Monitor::GetState() const
return( (State)shared_data->state ); return( (State)shared_data->state );
} }
int Monitor::GetImage( int index, int scale ) const int Monitor::GetImage( int index, int scale )
{ {
if ( index < 0 || index > image_buffer_count ) if ( index < 0 || index > image_buffer_count )
{ {
@ -669,21 +669,32 @@ int Monitor::GetImage( int index, int scale ) const
if ( index != image_buffer_count ) if ( index != image_buffer_count )
{ {
Snapshot *snap = &image_buffer[index]; Image *image;
Image snap_image( *(snap->image) ); // If we are going to be modifying the snapshot before writing, then we need to copy it
if ( ( scale != ZM_SCALE_BASE ) || ( !config.timestamp_on_capture ) ) {
Snapshot *snap = &image_buffer[index];
Image *snap_image = snap->image;
if ( scale != ZM_SCALE_BASE ) alarm_image.Assign( *snap_image );
{
snap_image.Scale( scale );
//write_image.Assign( *snap_image );
if ( scale != ZM_SCALE_BASE ) {
alarm_image.Scale( scale );
}
if ( !config.timestamp_on_capture ) {
TimestampImage( &alarm_image, snap->timestamp );
}
image = &alarm_image;
} else {
image = image_buffer[index].image;
} }
static char filename[PATH_MAX]; static char filename[PATH_MAX];
snprintf( filename, sizeof(filename), "Monitor%d.jpg", id ); snprintf( filename, sizeof(filename), "Monitor%d.jpg", id );
if ( !config.timestamp_on_capture ) image->WriteJpeg( filename );
{
TimestampImage( &snap_image, snap->timestamp );
}
snap_image.WriteJpeg( filename );
} }
else else
{ {
@ -1547,7 +1558,7 @@ bool Monitor::Analyse()
if ( config.create_analysis_images ) if ( config.create_analysis_images )
{ {
bool got_anal_image = false; bool got_anal_image = false;
Image alarm_image( *snap_image ); alarm_image.Assign( *snap_image );
for( int i = 0; i < n_zones; i++ ) for( int i = 0; i < n_zones; i++ )
{ {
if ( zones[i]->Alarmed() ) if ( zones[i]->Alarmed() )

View File

@ -246,6 +246,8 @@ protected:
double fps; double fps;
Image delta_image; Image delta_image;
Image ref_image; Image ref_image;
Image alarm_image; // Used in creating analysis images, will be initialized in Analysis
Image write_image; // Used when creating snapshot images
Purpose purpose; // What this monitor has been created to do Purpose purpose; // What this monitor has been created to do
int event_count; int event_count;
@ -349,7 +351,7 @@ public:
State GetState() const; State GetState() const;
int GetImage( int index=-1, int scale=100 ) const; int GetImage( int index=-1, int scale=100 );
struct timeval GetTimestamp( int index=-1 ) const; struct timeval GetTimestamp( int index=-1 ) const;
int GetCaptureDelay() const { return( capture_delay ); } int GetCaptureDelay() const { return( capture_delay ); }
int GetAlarmCaptureDelay() const { return( alarm_capture_delay ); } int GetAlarmCaptureDelay() const { return( alarm_capture_delay ); }