@@ -22,6 +22,7 @@
#include " zm_zone.h"
#include " zm_image.h"
#include " zm_monitor.h"
#include " zm_fifo.h"
void Zone::Setup ( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_type, const Polygon &p_polygon, 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, int p_overload_frames )
{
@@ -217,10 +218,13 @@ bool Zone::CheckAlarms( const Image *delta_image )
static char diag_path[PATH_MAX] = " " ;
if ( !diag_path[0 ] )
{
snprintf ( diag_path, sizeof (diag_path), " %s/%s/diag-%d-%d.jpg" , config.dir_events , monitor->Name (), id, 1 );
snprintf ( diag_path, sizeof (diag_path), config.record_diag_images_fifo ? " %s/%s/diagpipe-%d-%d.jpg" : " %s/%s/diag-%d-%d.jpg" , config.dir_events , monitor->Name (), id, 1 );
if (config.record_diag_images_fifo )
FifoStream::fifo_create_if_missing (diag_path);
}
diff_image->WriteJpeg ( diag_path );
diff_image->WriteJpeg ( diag_path, 0 ,config. record_diag_images_fifo );
}
<<<<<<< HEAD
if ( !alarm_pixels )
{
@@ -235,6 +239,28 @@ bool Zone::CheckAlarms( const Image *delta_image )
overload_count = overload_frames;
return ( false );
}
=======
if ( pixel_diff_count && alarm_pixels )
pixel_diff = pixel_diff_count/alarm_pixels;
Debug ( 5 , " Got %d alarmed pixels, need %d -> %d, avg pixel diff %d" , alarm_pixels, min_alarm_pixels, max_alarm_pixels, pixel_diff );
if (config.record_diag_images_fifo )
FifoDebug ( 5 , " %d#ALRM#%d#%d" , id,alarm_pixels, pixel_diff );
if ( alarm_pixels ) {
if ( min_alarm_pixels && (alarm_pixels < min_alarm_pixels) ) {
/* Not enough pixels alarmed */
return (false );
} else if ( max_alarm_pixels && (alarm_pixels > max_alarm_pixels) ) {
/* Too many pixels alarmed */
overload_count = overload_frames;
return (false );
}
} else {
/* No alarmed pixels */
return (false );
}
>>>>>>> ce45843... fifo diag support
score = (100 *alarm_pixels)/polygon.Area ();
Debug ( 5 , " Current score is %d" , score );
@@ -307,11 +333,14 @@ bool Zone::CheckAlarms( const Image *delta_image )
static char diag_path[PATH_MAX] = " " ;
if ( !diag_path[0 ] )
{
snprintf ( diag_path, sizeof (diag_path), " %s/%d/diag-%d-%d.jpg" , config.dir_events , monitor->Id (), id, 2 );
snprintf ( diag_path, sizeof (diag_path), config.record_diag_images_fifo ? " %s/%d/diagpipe-%d-%d.jpg" : " %s/%d/diag-%d-%d.jpg" , config.dir_events , monitor->Id (), id, 2 );
if (config.record_diag_images_fifo )
FifoStream::fifo_create_if_missing (diag_path);
}
diff_image->WriteJpeg ( diag_path );
diff_image->WriteJpeg ( diag_path, 0 ,config. record_diag_images_fifo );
}
Debug ( 5 , " Got %d filtered pixels, need %d -> %d" , alarm_filter_pixels, min_filter_pixels, max_filter_pixels );
<<<<<<< HEAD
if ( !alarm_filter_pixels )
{
@@ -327,6 +356,24 @@ bool Zone::CheckAlarms( const Image *delta_image )
return ( false );
}
=======
if (config.record_diag_images_fifo )
FifoDebug ( 5 , " %d#FILT#%d" , id,alarm_filter_pixels );
if ( alarm_filter_pixels ) {
if ( min_filter_pixels && (alarm_filter_pixels < min_filter_pixels) ) {
/* Not enough pixels alarmed */
return (false );
} else if ( max_filter_pixels && (alarm_filter_pixels > max_filter_pixels) ) {
/* Too many pixels alarmed */
overload_count = overload_frames;
return (false );
}
} else {
/* No filtered pixels */
return (false );
}
>>>>>>> ce45843... fifo diag support
score = (100 *alarm_filter_pixels)/(polygon.Area ());
Debug ( 5 , " Current score is %d" , score );
@@ -527,9 +574,11 @@ bool Zone::CheckAlarms( const Image *delta_image )
static char diag_path[PATH_MAX] = " " ;
if ( !diag_path[0 ] )
{
snprintf ( diag_path, sizeof (diag_path), " %s/%d/diag-%d-%d.jpg" , config.dir_events , monitor->Id (), id, 3 );
snprintf ( diag_path, sizeof (diag_path), config.record_diag_images_fifo ? " %s/%d/diagpipe-%d-%d.jpg" : " %s/%d/diag-%d-%d.jpg" , config.dir_events , monitor->Id (), id, 3 );
if (config.record_diag_images_fifo )
FifoStream::fifo_create_if_missing (diag_path);
}
diff_image->WriteJpeg ( diag_path );
diff_image->WriteJpeg ( diag_path, 0 ,config. record_diag_images_fifo );
}
if ( !alarm_blobs )
@@ -538,6 +587,8 @@ bool Zone::CheckAlarms( const Image *delta_image )
}
alarm_blob_pixels = alarm_filter_pixels;
Debug ( 5 , " Got %d raw blob pixels, %d raw blobs, need %d -> %d, %d -> %d" , alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs );
if (config.record_diag_images_fifo )
FifoDebug ( 5 , " %d#RBLB#%d#%d" , id, alarm_blob_pixels, alarm_blobs );
// Now eliminate blobs under the threshold
for ( int i = 1 ; i < WHITE; i++ )
@@ -586,10 +637,13 @@ bool Zone::CheckAlarms( const Image *delta_image )
static char diag_path[PATH_MAX] = " " ;
if ( !diag_path[0 ] )
{
snprintf ( diag_path, sizeof (diag_path), " %s/%d/diag-%d-%d.jpg" , config.dir_events , monitor->Id (), id, 4 );
snprintf ( diag_path, sizeof (diag_path), config.record_diag_images_fifo ? " %s/%d/diagpipe-%d-%d.jpg" : " %s/%d/diag-%d-%d.jpg" , config.dir_events , monitor->Id (), id, 4 );
if (config.record_diag_images_fifo )
FifoStream::fifo_create_if_missing (diag_path);
}
diff_image->WriteJpeg ( diag_path );
diff_image->WriteJpeg ( diag_path, 0 ,config. record_diag_images_fifo );
}
<<<<<<< HEAD
Debug ( 5 , " Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d" , alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs );
if ( !alarm_blobs )
@@ -605,6 +659,29 @@ bool Zone::CheckAlarms( const Image *delta_image )
overload_count = overload_frames;
return ( false );
}
=======
Debug ( 5 , " Got %d blob pixels, %d blobs, need %d -> %d, %d -> %d" , alarm_blob_pixels, alarm_blobs, min_blob_pixels, max_blob_pixels, min_blobs, max_blobs );
if (config.record_diag_images_fifo )
FifoDebug ( 5 , " %d#FBLB#%d#%d" , id, alarm_blob_pixels, alarm_blobs );
if ( alarm_blobs ) {
if ( min_blobs && (alarm_blobs < min_blobs) ) {
/* Not enough pixels alarmed */
return (false );
} else if (max_blobs && (alarm_blobs > max_blobs) ) {
/* Too many pixels alarmed */
overload_count = overload_frames;
return (false );
}
} else {
/* No blobs */
return (false );
}
score = (100 *alarm_blob_pixels)/(polygon.Area ());
if (score < 1 )
score = 1 ; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */
Debug ( 5 , " Current score is %d" , score );
>>>>>>> ce45843... fifo diag support
alarm_lo_x = polygon.HiX ()+1 ;
alarm_hi_x = polygon.LoX ()-1 ;