Fixed problem with debug images ending up as analysis images.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1003 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2004-03-30 11:05:47 +00:00
parent 2ff1a27ef3
commit 2465a916b2
3 changed files with 26 additions and 6 deletions

View File

@ -703,7 +703,7 @@ bool Monitor::Analyse()
} }
if ( score ) if ( score )
{ {
if ( state == IDLE ) if ( state == IDLE || state == TAPE )
{ {
Info(( "%s: %03d - Gone into alarm state", name, image_count )); Info(( "%s: %03d - Gone into alarm state", name, image_count ));
if ( function != MOCORD ) if ( function != MOCORD )
@ -757,19 +757,31 @@ bool Monitor::Analyse()
{ {
if ( create_analysis_images ) if ( create_analysis_images )
{ {
bool got_anal_image = false;
Image alarm_image( *snap_image ); Image alarm_image( *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() )
{ {
alarm_image.Overlay( zones[i]->AlarmImage() ); if ( zones[i]->AlarmImage() )
{
alarm_image.Overlay( *(zones[i]->AlarmImage()) );
got_anal_image = true;
}
if ( record_event_stats ) if ( record_event_stats )
{ {
zones[i]->RecordStats( event ); 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 else
{ {

View File

@ -25,6 +25,7 @@
bool Zone::initialised = false; bool Zone::initialised = false;
bool Zone::record_diag_images; 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 ) 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] = ""; static char diag_path[PATH_MAX] = "";
if ( !diag_path[0] ) 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 ) ); 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 ); image = diff_image->HighlightEdges( alarm_rgb, &limits );
// Only need to delete this when 'image' becomes detached and points somewhere else // Only need to delete this when 'image' becomes detached and points somewhere else
delete diff_image; 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 )); 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 ));
} }

View File

@ -41,6 +41,7 @@ public:
protected: protected:
static bool initialised; static bool initialised;
static bool record_diag_images; static bool record_diag_images;
static bool create_analysis_images;
protected: protected:
// Inputs // Inputs
@ -85,6 +86,7 @@ protected:
{ {
initialised = true; initialised = true;
record_diag_images = (bool)config.Item( ZM_RECORD_DIAG_IMAGES ); 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 ); 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 IsExclusive() const { return( type == EXCLUSIVE ); }
inline bool IsPreclusive() const { return( type == PRECLUSIVE ); } inline bool IsPreclusive() const { return( type == PRECLUSIVE ); }
inline bool IsInactive() const { return( type == INACTIVE ); } 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 const Box &Limits() const { return( limits ); }
inline bool Alarmed() const { return( alarmed ); } inline bool Alarmed() const { return( alarmed ); }
inline void SetAlarm() { alarmed = true; } inline void SetAlarm() { alarmed = true; }