diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 912d6abff..f9df0f51f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -703,7 +703,7 @@ bool Monitor::Analyse() } if ( score ) { - if ( state == IDLE ) + if ( state == IDLE || state == TAPE ) { Info(( "%s: %03d - Gone into alarm state", name, image_count )); if ( function != MOCORD ) @@ -757,19 +757,31 @@ bool Monitor::Analyse() { if ( create_analysis_images ) { + bool got_anal_image = false; Image alarm_image( *snap_image ); for( int i = 0; i < n_zones; i++ ) { if ( zones[i]->Alarmed() ) { - alarm_image.Overlay( zones[i]->AlarmImage() ); + if ( zones[i]->AlarmImage() ) + { + alarm_image.Overlay( *(zones[i]->AlarmImage()) ); + got_anal_image = true; + } if ( record_event_stats ) { zones[i]->RecordStats( event ); } } } - event->AddFrame( snap_image, *timestamp, score, &alarm_image ); + if ( got_anal_image ) + { + event->AddFrame( snap_image, *timestamp, score, &alarm_image ); + } + else + { + event->AddFrame( snap_image, *timestamp, score ); + } } else { diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 159b99e42..8f7c783c8 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -25,6 +25,7 @@ bool Zone::initialised = false; bool Zone::record_diag_images; +bool Zone::create_analysis_images; void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Box &p_limits, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs ) { @@ -335,7 +336,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } } - if ( (bool)config.Item( ZM_RECORD_DIAG_IMAGES ) ) + if ( record_diag_images ) { static char diag_path[PATH_MAX] = ""; if ( !diag_path[0] ) @@ -434,12 +435,17 @@ bool Zone::CheckAlarms( const Image *delta_image ) alarm_box = Box( Coord( alarm_lo_x, alarm_lo_y ), Coord( alarm_hi_x, alarm_hi_y ) ); - if ( (type < PRECLUSIVE) && check_method >= BLOBS && (bool)config.Item( ZM_CREATE_ANALYSIS_IMAGES ) ) + if ( (type < PRECLUSIVE) && check_method >= BLOBS && create_analysis_images ) { image = diff_image->HighlightEdges( alarm_rgb, &limits ); // Only need to delete this when 'image' becomes detached and points somewhere else delete diff_image; } + else + { + delete image; + image = 0; + } Debug( 1, ( "%s: Alarm Pixels: %d, Filter Pixels: %d, Blob Pixels: %d, Blobs: %d, Score: %d", Label(), alarm_pixels, alarm_filter_pixels, alarm_blob_pixels, alarm_blobs, score )); } diff --git a/src/zm_zone.h b/src/zm_zone.h index 4d3338152..fe88de034 100644 --- a/src/zm_zone.h +++ b/src/zm_zone.h @@ -41,6 +41,7 @@ public: protected: static bool initialised; static bool record_diag_images; + static bool create_analysis_images; protected: // Inputs @@ -85,6 +86,7 @@ protected: { initialised = true; record_diag_images = (bool)config.Item( ZM_RECORD_DIAG_IMAGES ); + create_analysis_images = (bool)config.Item( ZM_CREATE_ANALYSIS_IMAGES ); } void Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Box &p_limits, const Rgb p_alarm_rgb, CheckMethod p_check_method, int p_min_pixel_threshold, int p_max_pixel_threshold, int p_min_alarm_pixels, int p_max_alarm_pixels, const Coord &p_filter_box, int p_min_filter_pixels, int p_max_filter_pixels, int p_min_blob_pixels, int p_max_blob_pixels, int p_min_blobs, int p_max_blobs ); @@ -113,7 +115,7 @@ public: inline bool IsExclusive() const { return( type == EXCLUSIVE ); } inline bool IsPreclusive() const { return( type == PRECLUSIVE ); } inline bool IsInactive() const { return( type == INACTIVE ); } - inline Image &AlarmImage() const { return( *image ); } + inline const Image *AlarmImage() const { return( image ); } inline const Box &Limits() const { return( limits ); } inline bool Alarmed() const { return( alarmed ); } inline void SetAlarm() { alarmed = true; }