From 28e06e935b2d056f8d483d6ac1eedbf2031f8f19 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 7 Sep 2011 19:07:23 +0300 Subject: [PATCH] 1) Fixed blob motion detection issues. 2) Some more progress towards getting analysis images working. 3) Fixed possible log corruption because of ssedetect(). --- src/zm_image.cpp | 274 ++++++++++++++++++++++++++++------------------- src/zm_zone.cpp | 141 +++++++++++++----------- src/zma.cpp | 4 +- src/zmc.cpp | 4 +- src/zmf.cpp | 4 +- src/zms.cpp | 4 +- 6 files changed, 251 insertions(+), 180 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 1d8c0fd69..60b60a57f 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -475,7 +475,7 @@ Image *Image::HighlightEdges( Rgb colour, const Box *limits ) for ( int y = lo_y; y <= hi_y; y++ ) { uint8_t *p = &buffer[(y*width)+lo_x]; - uint8_t *phigh = high_buff + ( lo_x * y ); + uint8_t *phigh = high_buff + (((y * width) + lo_x) * 3); for ( int x = lo_x; x <= hi_x; x++, p++, phigh += 3 ) { bool edge = false; @@ -1117,134 +1117,184 @@ bool Image::Crop( const Box &limits ) return( Crop( limits.LoX(), limits.LoY(), limits.HiX(), limits.HiY() ) ); } - -/* At the moment only supports 8bit overlay for 24bit and 32bit images. */ +/* Not fully complete */ void Image::Overlay( const Image &image ) { if ( !(width == image.width && height == image.height) ) - { - Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); - } - - unsigned char *pdest = buffer; - unsigned char *psrc = image.buffer; - - if ( colours == ZM_COLOUR_GRAY8 ) { - if ( image.colours == ZM_COLOUR_GRAY8 ) + Panic( "Attempt to overlay different sized images, expected %dx%d, got %dx%d", width, height, image.width, image.height ); + } + + if( colours == image.colours && subpixelorder != image.subpixelorder ) { + Warning("Attempt to overlay images of same format but with different subpixel order."); + } + + /* Grayscale ontop of grayscale */ + if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_GRAY8 ) { + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) { - while( pdest < (buffer+size) ) + if ( *psrc ) { + *pdest = *psrc; + } + pdest++; + psrc++; + } + + /* RGB24 ontop of grayscale - convert to same format first */ + } else if ( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_RGB24 ) { + Colourise(image.colours, image.subpixelorder); + + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) + { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) + { + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); + } + pdest += 3; + psrc += 3; + } + + /* RGB32 ontop of grayscale - convert to same format first */ + } else if( colours == ZM_COLOUR_GRAY8 && image.colours == ZM_COLOUR_RGB32 ) { + Colourise(image.colours, image.subpixelorder); + + const Rgb* const max_ptr = (Rgb*)(buffer+size); + const Rgb* prsrc = (Rgb*)image.buffer; + Rgb* prdest = (Rgb*)buffer; + + if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; + } + } + + /* Grayscale ontop of RGB24 */ + } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_GRAY8 ) { + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) + { + if ( *psrc ) + { + RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc; + } + pdest += 3; + psrc++; + } + + /* RGB24 ontop of RGB24 */ + } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_RGB24 ) { + const uint8_t* const max_ptr = buffer+size; + const uint8_t* psrc = image.buffer; + uint8_t* pdest = buffer; + + while( pdest < max_ptr ) + { + if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) + { + RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); + GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); + BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); + } + pdest += 3; + psrc += 3; + } + + /* RGB32 ontop of RGB24 - TO BE DONE */ + } else if ( colours == ZM_COLOUR_RGB24 && image.colours == ZM_COLOUR_RGB32 ) { + Error("Overlay of RGB32 ontop of RGB24 is not supported."); + + /* Grayscale ontop of RGB32 */ + } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_GRAY8 ) { + const Rgb* const max_ptr = (Rgb*)(buffer+size); + Rgb* prdest = (Rgb*)buffer; + const uint8_t* psrc = image.buffer; + + if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { if ( *psrc ) { - *pdest = *psrc; + RED_PTR_RGBA(prdest) = GREEN_PTR_RGBA(prdest) = BLUE_PTR_RGBA(prdest) = *psrc; } - pdest++; + prdest++; + psrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( *psrc ) + { + RED_PTR_ABGR(prdest) = GREEN_PTR_ABGR(prdest) = BLUE_PTR_ABGR(prdest) = *psrc; + } + prdest++; psrc++; } } - else - { - Colourise(image.colours, image.subpixelorder); - - if(image.colours == ZM_COLOUR_RGB32) { - Rgb* prdest = (Rgb*)buffer; - const Rgb* prsrc = (Rgb*)image.buffer; - const Rgb* const max_ptr = (Rgb*)(buffer+size); - if(image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA) { - /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ - while (prdest < max_ptr) { - if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) - { - *prdest = *prsrc; - } - prdest++; - prsrc++; - } - } else { - /* ABGR\ARGB subpixel order - Alpha byte is first */ - while (prdest < max_ptr) { - if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) - { - *prdest = *prsrc; - } - prdest++; - prsrc++; - } - } - } else { - /* Assume RGB24\BGR24 */ - while( pdest < (buffer+size) ) + + /* RGB24 ontop of RGB32 - TO BE DONE */ + } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_RGB24 ) { + Error("Overlay of RGB24 ontop of RGB32 is not supported."); + + /* RGB32 ontop of RGB32 */ + } else if ( colours == ZM_COLOUR_RGB32 && image.colours == ZM_COLOUR_RGB32 ) { + const Rgb* const max_ptr = (Rgb*)(buffer+size); + Rgb* prdest = (Rgb*)buffer; + const Rgb* prsrc = (Rgb*)image.buffer; + + if(image.subpixelorder == ZM_SUBPIX_ORDER_RGBA || image.subpixelorder == ZM_SUBPIX_ORDER_BGRA) { + /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ + while (prdest < max_ptr) { + if ( RED_PTR_RGBA(prsrc) || GREEN_PTR_RGBA(prsrc) || BLUE_PTR_RGBA(prsrc) ) { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { - RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); - GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); - BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); - } - psrc += 3; - pdest += 3; + *prdest = *prsrc; } + prdest++; + prsrc++; + } + } else { + /* ABGR\ARGB subpixel order - Alpha byte is first */ + while (prdest < max_ptr) { + if ( RED_PTR_ABGR(prsrc) || GREEN_PTR_ABGR(prsrc) || BLUE_PTR_ABGR(prsrc) ) + { + *prdest = *prsrc; + } + prdest++; + prsrc++; } } + } - else - { - if ( image.colours == ZM_COLOUR_GRAY8 ) - { - if(colours == ZM_COLOUR_RGB32) { - Rgb* prdest = (Rgb*)buffer; - const Rgb* const max_ptr = (Rgb*)(buffer+size); - if(subpixelorder == ZM_SUBPIX_ORDER_RGBA || subpixelorder == ZM_SUBPIX_ORDER_BGRA) { - /* RGB\BGR\RGBA\BGRA subpixel order - Alpha byte is last */ - while (prdest < max_ptr) { - if ( *psrc ) - { - RED_PTR_RGBA(prdest) = GREEN_PTR_RGBA(prdest) = BLUE_PTR_RGBA(prdest) = *psrc++; - } - prdest++; - } - } else { - /* ABGR\ARGB subpixel order - Alpha byte is first */ - while (prdest < max_ptr) { - if ( *psrc ) - { - RED_PTR_ABGR(prdest) = GREEN_PTR_ABGR(prdest) = BLUE_PTR_ABGR(prdest) = *psrc++; - } - prdest++; - } - } - } else { - /* Assume RGB24\BGR24 */ - while( pdest < (buffer+size) ) - { - if ( *psrc ) - { - RED_PTR_RGBA(pdest) = GREEN_PTR_RGBA(pdest) = BLUE_PTR_RGBA(pdest) = *psrc++; - } - pdest += 3; - } - } - } - else - { - - /* At the moment this function only supports 8bit overlay for 24bit and 32bit images. - ** The code below is old and was not updated yet to support the new formats. this code assumes RGB24 - */ - while( pdest < (buffer+size) ) - { - if ( RED_PTR_RGBA(psrc) || GREEN_PTR_RGBA(psrc) || BLUE_PTR_RGBA(psrc) ) - { - RED_PTR_RGBA(pdest) = RED_PTR_RGBA(psrc); - GREEN_PTR_RGBA(pdest) = GREEN_PTR_RGBA(psrc); - BLUE_PTR_RGBA(pdest) = BLUE_PTR_RGBA(psrc); - } - psrc += colours; - pdest += colours; - } - } - } + } /* RGB32 compatible: complete */ diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index bf294aa4a..0bb4c1b94 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -68,13 +68,13 @@ void Zone::Setup( Monitor *p_monitor, int p_id, const char *p_label, ZoneType p_ pg_image->Outline( 0xff, polygon ); ranges = new Range[monitor->Height()]; - for ( int y = polygon.LoY(); y <= polygon.HiY(); y++) + for ( int y = 0; y < monitor->Height(); y++) { ranges[y].lo_x = -1; ranges[y].hi_x = -1; ranges[y].off_x = 0; - const uint8_t *ppoly = pg_image->Buffer( polygon.LoX(), y ); - for ( int x = polygon.LoX(); x <= polygon.HiX(); x++, ppoly++ ) + const uint8_t *ppoly = pg_image->Buffer( 0, y ); + for ( int x = 0; x < monitor->Width(); x++, ppoly++ ) { if ( *ppoly ) { @@ -154,8 +154,8 @@ bool Zone::CheckAlarms( const Image *delta_image ) unsigned int lo_y = polygon.LoY(); unsigned int lo_x = polygon.LoX(); - unsigned int hi_x = polygon.HiX()+1; - unsigned int hi_y = polygon.HiY()+1; + unsigned int hi_x = polygon.HiX(); + unsigned int hi_y = polygon.HiY(); Debug( 4, "Checking alarms for zone %d/%s in lines %d -> %d", id, label, lo_y, hi_y ); @@ -168,10 +168,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) } */ std_alarmedpixels(diff_image, pg_image, &alarm_pixels, &pixel_diff_count); - 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 ) { static char diag_path[PATH_MAX] = ""; @@ -181,6 +177,10 @@ bool Zone::CheckAlarms( const Image *delta_image ) } diff_image->WriteJpeg( diag_path ); } + + 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( alarm_pixels ) { if( min_alarm_pixels && (alarm_pixels < min_alarm_pixels) ) { @@ -196,7 +196,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) return (false); } - score = (100*alarm_pixels)/polygon.Area(); if(score < 1) score = 1; /* Fix for score of 0 when frame meets thresholds but alarmed area is not big enough */ @@ -265,6 +264,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { alarm_filter_pixels = alarm_pixels; } + if ( config.record_diag_images ) { static char diag_path[PATH_MAX] = ""; @@ -274,23 +274,26 @@ bool Zone::CheckAlarms( const Image *delta_image ) } diff_image->WriteJpeg( diag_path ); } + Debug( 5, "Got %d filtered pixels, need %d -> %d", alarm_filter_pixels, min_filter_pixels, max_filter_pixels ); - - if ( !alarm_filter_pixels ) - { - return( false ); - } - if ( min_filter_pixels && (alarm_filter_pixels < min_filter_pixels) ) - { - return( false ); - } - if ( max_filter_pixels && (alarm_filter_pixels > max_filter_pixels) ) - { - overload_count = overload_frames; - return( false ); - } - + + 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); + } + score = (100*alarm_filter_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 ); if ( check_method >= BLOBS ) @@ -300,7 +303,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) BlobStats blob_stats[256]; memset( blob_stats, 0, sizeof(BlobStats)*256 ); uint8_t *spdiff; - int last_x, last_y; + uint8_t last_x, last_y; BlobStats *bsx, *bsy; BlobStats *bsm, *bss; for ( int y = lo_y; y <= hi_y; y++ ) @@ -316,8 +319,20 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Got white pixel at %d,%d (%p)", x, y, pdiff ); //last_x = (x>lo_x)?*(pdiff-1):0; //last_y = (y>lo_y&&x>=last_lo_x&&x<=last_hi_x)?*(pdiff-diff_width):0; - last_x = x>0?*(pdiff-1):0; - last_y = y>0?*(pdiff-diff_width):0; + + last_x = 0; + if(x > 0) { + if((x-1) >= lo_x) { + last_x = *(pdiff-1); + } + } + + last_y = 0; + if(y > 0) { + if((y-1) >= lo_y && ranges[(y-1)].lo_x <= x && ranges[(y-1)].hi_x >= x) { + last_y = *(pdiff-diff_width); + } + } if ( last_x ) { @@ -332,6 +347,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Matching neighbours, setting to %d", last_x ); // Add to the blob from the x side (either side really) *pdiff = last_x; + alarm_blob_pixels++; bsx->count++; if ( x > bsx->hi_x ) bsx->hi_x = x; if ( y > bsx->hi_y ) bsx->hi_y = y; @@ -347,13 +363,13 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Slave blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bss->tag, bss->count, bss->lo_x, bss->hi_x, bss->lo_y, bss->hi_y ); // Now change all those pixels to the other setting int changed = 0; - for ( int sy = bss->lo_y, psy = bss->lo_y-lo_y; sy <= bss->hi_y; sy++, psy++ ) + for ( int sy = bss->lo_y; sy <= bss->hi_y; sy++) { - int lo_sx = bss->lo_x>=ranges[psy].lo_x?bss->lo_x:ranges[psy].lo_x; - int hi_sx = bss->hi_x<=ranges[psy].hi_x?bss->hi_x:ranges[psy].hi_x; + int lo_sx = bss->lo_x>=ranges[sy].lo_x?bss->lo_x:ranges[sy].lo_x; + int hi_sx = bss->hi_x<=ranges[sy].hi_x?bss->hi_x:ranges[sy].hi_x; - Debug( 9, "Changing %d(%d), %d->%d", sy, psy, lo_sx, hi_sx ); - Debug( 9, "Range %d(%d), %d->%d", sy, psy, ranges[psy].lo_x, ranges[psy].hi_x ); + Debug( 9, "Changing %d, %d->%d", sy, lo_sx, hi_sx ); + Debug( 9, "Range %d, %d->%d", sy, ranges[sy].lo_x, ranges[sy].hi_x ); spdiff = diff_buff + ((diff_width * sy) + lo_sx); for ( int sx = lo_sx; sx <= hi_sx; sx++, spdiff++ ) { @@ -367,6 +383,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } *pdiff = bsm->tag; + alarm_blob_pixels++; if ( !changed ) { Info( "Master blob t:%d, c:%d, lx:%d, hx:%d, ly:%d, hy:%d", bsm->tag, bsm->count, bsm->lo_x, bsm->hi_x, bsm->lo_y, bsm->hi_y ); @@ -402,6 +419,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) Debug( 9, "Setting to left neighbour %d", last_x ); // Add to the blob from the x side *pdiff = last_x; + alarm_blob_pixels++; bsx->count++; if ( x > bsx->hi_x ) bsx->hi_x = x; if ( y > bsx->hi_y ) bsx->hi_y = y; @@ -411,12 +429,14 @@ bool Zone::CheckAlarms( const Image *delta_image ) { if ( last_y ) { + Debug( 9, "Top neighbour is %d", last_y ); Debug( 9, "Setting to top neighbour %d", last_y ); - + // Add to the blob from the y side BlobStats *bsy = &blob_stats[last_y]; *pdiff = last_y; + alarm_blob_pixels++; bsy->count++; if ( x > bsy->hi_x ) bsy->hi_x = x; if ( y > bsy->hi_y ) bsy->hi_y = y; @@ -464,6 +484,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) { Debug( 9, "Creating new blob %d", i ); *pdiff = i; + alarm_blob_pixels++; bs->tag = i; bs->count++; bs->lo_x = bs->hi_x = x; @@ -496,10 +517,10 @@ bool Zone::CheckAlarms( const Image *delta_image ) } if ( !alarm_blobs ) - { - return( false ); - } - alarm_blob_pixels = alarm_filter_pixels; + { + return( false ); + } + 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 ); // Now eliminate blobs under the threshold @@ -553,21 +574,26 @@ bool Zone::CheckAlarms( const Image *delta_image ) } diff_image->WriteJpeg( diag_path ); } - 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 ) - { - return( false ); - } - if ( min_blobs && (alarm_blobs < min_blobs) ) - { - return( false ); - } - if ( max_blobs && (alarm_blobs > max_blobs) ) - { - 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( 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 ); alarm_lo_x = polygon.HiX()+1; alarm_hi_x = polygon.LoX()-1; @@ -613,8 +639,6 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( alarm_hi_y < bs->hi_y ) alarm_hi_y = bs->hi_y; } } - score = ((100*alarm_blob_pixels)/int(sqrt((double)alarm_blobs)))/(polygon.Area()); - Debug( 5, "Current score is %d", score ); } else { @@ -656,10 +680,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) if ( (type < PRECLUSIVE) && check_method >= BLOBS && config.create_analysis_images ) { - int lo_x = polygon.LoX(); - int hi_x = polygon.HiX(); - int lo_y = polygon.LoY(); - int hi_y = polygon.HiY(); + // First mask out anything we don't want for ( int y = lo_y; y <= hi_y; y++ ) { @@ -682,7 +703,7 @@ bool Zone::CheckAlarms( const Image *delta_image ) } } - ppoly = pg_image->Buffer( lo_gap, y ); + ppoly = pg_image->Buffer( lo_x2, y ); for ( int x = lo_x2; x <= hi_x2; x++, pdiff++, ppoly++ ) { if ( !*ppoly ) diff --git a/src/zma.cpp b/src/zma.cpp index 7c54d0c05..3de25bf12 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -91,10 +91,10 @@ int main( int argc, char *argv[] ) snprintf( log_id_string, sizeof(log_id_string), "zma_m%d", id ); zmLoadConfig(); - - ssedetect(); logInit( log_id_string ); + + ssedetect(); Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS ); diff --git a/src/zmc.cpp b/src/zmc.cpp index 734e4606b..692c0b59e 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -149,10 +149,10 @@ int main( int argc, char *argv[] ) } zmLoadConfig(); - - ssedetect(); logInit( log_id_string ); + + ssedetect(); Monitor **monitors = 0; int n_monitors = 0; diff --git a/src/zmf.cpp b/src/zmf.cpp index 998f7a0ec..bc7a54ee0 100644 --- a/src/zmf.cpp +++ b/src/zmf.cpp @@ -159,10 +159,10 @@ int main( int argc, char *argv[] ) snprintf( log_id_string, sizeof(log_id_string), "m%d", id ); zmLoadConfig(); - - ssedetect(); logInit( "zmf" ); + + ssedetect(); Monitor *monitor = Monitor::Load( id, false, Monitor::QUERY ); diff --git a/src/zms.cpp b/src/zms.cpp index db7902303..af294cb71 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -86,10 +86,10 @@ int main( int argc, const char *argv[] ) } zmLoadConfig(); - - ssedetect(); logInit( "zms" ); + + ssedetect(); zmSetDefaultTermHandler(); zmSetDefaultDieHandler();