From 4ca61b7bd8b6d807cf39ec38454d078c935603af Mon Sep 17 00:00:00 2001 From: Steve Gilvarry Date: Mon, 25 Apr 2016 22:12:49 +1000 Subject: [PATCH] Removed 180 lines of commented out code that has been hanging around in here for a long time. --- src/zm_monitor.cpp | 185 --------------------------------------------- 1 file changed, 185 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index e96997ebc..b8a77c620 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3213,191 +3213,6 @@ bool Monitor::closeEvent() return( false ); } -//----------------------------------------- - -/* - * NOTE Nextime's comment: - * - * OurCheckAlarms seems to be called only by DetectBlack method, and DetectBlack - * method is only called in a commented line instead of DetectMotion in zm_monitor.cpp. - * - * Probably this is just a dead code used for debugghing purpose, so, instead of fixing it - * it seems to be safe to just comment it out. - * - * Anyway, the issues with this code is that it assumes the image to be an RGB24 image, - * so, as i've discussed on IRC with mastertheknife, changes needed are: - * - * Check if the image is 24 or 32 bits ( pImage->Colours() says 3 for 24 and 4 for 32 bits, - * comparing it with ZM_COLOUR_RGB24 or ZM_COLOUR_RGB32 is the way ), and then - * manage che check using RGB_VAL_RED() and so on macros instead of just RED(). - * - * Be careful that in 32 bit images we need to check also where the alpha channel is, so, - * (RGBA and BGRA) or (ABGR and ARGB) aren't the same! - * - * To check black pixels in 32 bit images i can do a more efficient way using - * RGBA_ZERO_ALPHA(pixel) == RGBA_ZERO_ALPHA(RGB_BLACK), but before of that i need to - * check where the alpha channel is and maybe convert it. - * Maybe this won't work as they assign "23" to black_thr, so, they are not checking - * if the pixel is black, but just "quasi" black is enough. - * - * Anyway, for the moment, comment out whole part. - */ - -/* -bool Monitor::OurCheckAlarms( Zone *zone, const Image *pImage ) -{ - Info("Entering OurCheckAlarms >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - unsigned char black_thr = 23; - int min_alarm_score = 10; - int max_alarm_score = 99; - //bool alarm = false; - unsigned int score; - Polygon zone_polygon = zone->GetPolygon(); - Info("Got polygon of a zone. It has %d vertices.", zone_polygon.getNumCoords()); - - zone->ResetStats(); - Info("ResetStats done."); - - if ( !zone->CheckOverloadCount() ) - { - Info("CheckOverloadCount() return false, we'll return false."); - return( false ); - } - - Image *pMaskImage = new Image(pImage->Width(), pImage->Height(), ZM_COLOUR_GRAY8, pImage->SubpixelOrder()); - Info("Mask image created."); - - pMaskImage->Fill(BLACK); - Info("Mask image filled with BLACK."); - if (pImage->Colours() == ZM_COLOUR_GRAY8) - { - Info("Analysed image is not colored! Set score = 0."); - score = 0; - } - else - { - Info("Start processing image."); - //Process image - unsigned char *buffer = (unsigned char*)pImage->Buffer(); - unsigned char *mask_buffer = (unsigned char*)pMaskImage->Buffer(); - - int black_pixels_count = 0; - Info("Loop for black pixels counting and mask filling."); - while (buffer < (pImage->Buffer() + pImage->Size())) - { - if ( (RED(buffer) < black_thr) && (GREEN(buffer) < black_thr) && (BLUE(buffer) < black_thr) ) - { - *mask_buffer = WHITE; - black_pixels_count++; - } - buffer += pImage->Colours(); - mask_buffer++; - } - - if ( !black_pixels_count ) - { - delete pMaskImage; - return( false ); - } - score = (100*black_pixels_count)/zone_polygon.Area(); - Info("Number of black pixels is %d, zone polygon area is %d, score is %d", black_pixels_count, zone_polygon.Area(), score); - - if ( min_alarm_score && ( score < min_alarm_score) ) - { - delete pMaskImage; - return( false ); - } - if ( max_alarm_score && (score > max_alarm_score) ) - { - zone->SetOverloadCount(zone->GetOverloadFrames()); - delete pMaskImage; - return( false ); - } - } - - zone->SetScore(score); - Info("Score have been set in zone."); - //Get mask - Rgb alarm_colour = RGB_RED; - Image *tempImage = pMaskImage->HighlightEdges(alarm_colour, &zone_polygon.Extent() ); - Info("After HighlightEdges"); - - zone->SetAlarmImage(tempImage); - Info("After SetAlarmImage"); - delete pMaskImage; - Info("After Delete pMaskImage"); - delete tempImage; - - Info("Leaving OurCheckAlarms >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - return true; -} - -unsigned int Monitor::DetectBlack(const Image &comp_image, Event::StringSet &zoneSet ) -{ - Info("Entering DetectBlack >>>>>>>>>>>>>>>>>>>>>>>>>>"); - bool alarm = false; - unsigned int score = 0; - - if ( n_zones <= 0 ) return( alarm ); - -// Coord alarm_centre; -// int top_score = -1; - - // Find all alarm pixels in active zones - Info("Number of zones to process %d", n_zones); - for ( int n_zone = 0; n_zone < n_zones; n_zone++ ) - { - Zone *zone = zones[n_zone]; - if ( !zone->IsActive() ) - { - continue; - } - Debug( 3, "Checking active zone %s", zone->Label() ); - Info( "Checking active zone %s", zone->Label() ); - if ( OurCheckAlarms( zone, &comp_image ) ) - { - Info("OurCheckAlarm is TRUE!!!!!!"); - alarm = true; - score += zone->Score(); - zone->SetAlarm(); - Debug( 3, "Zone is alarmed, zone score = %d", zone->Score() ); - Info( "Zone is alarmed, zone score = %d", zone->Score() ); - zoneSet.insert( zone->Label() ); -// if ( config.opt_control && track_motion ) -// { -// if ( (int)zone->Score() > top_score ) -// { -// top_score = zone->Score(); -// alarm_centre = zone->GetAlarmCentre(); -// } -// } - } - Info( "Finish checking active zone %s", zone->Label() ); - } - - -// if ( top_score > 0 ) -// { -// shared_data->alarm_x = alarm_centre.X(); -// shared_data->alarm_y = alarm_centre.Y(); -// -// Info( "Got alarm centre at %d,%d, at count %d", shared_data->alarm_x, shared_data->alarm_y, image_count ); -// } -// else -// { -// shared_data->alarm_x = shared_data->alarm_y = -1; -// } - - // This is a small and innocent hack to prevent scores of 0 being returned in alarm state - Info("Leaving DetectBlack <<<<<<<<<<<<<<<<<<<<<<<<<<<"); - return( score?score:alarm ); -} - -*/ -//----------------------------------------------------------------------------------------------- - - - unsigned int Monitor::DetectMotion( const Image &comp_image, Event::StringSet &zoneSet ) { bool alarm = false;