From d97eea886a8de84c337387d52415f9e832352934 Mon Sep 17 00:00:00 2001 From: vajonam Date: Wed, 22 Aug 2018 12:58:26 -0400 Subject: [PATCH] fix scoring algorithim, to use max_alarm_size when specified instead of the size of the zone. (#2186) --- src/zm_zone.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index b62ad41fe..ce5ce91c2 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -252,7 +252,11 @@ bool Zone::CheckAlarms(const Image *delta_image) { return false; } - score = (100*alarm_pixels)/polygon.Area(); + if (max_alarm_pixels != 0) + score = (100*alarm_pixels)/max_alarm_pixels; + else + 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 */ Debug(5, "Current score is %d", score); @@ -328,7 +332,11 @@ bool Zone::CheckAlarms(const Image *delta_image) { return false; } - score = (100*alarm_filter_pixels)/(polygon.Area()); + if (max_filter_pixels != 0) + score = (100*alarm_filter_pixels)/(max_filter_pixels); + else + 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); @@ -589,8 +597,12 @@ bool Zone::CheckAlarms(const Image *delta_image) { /* No blobs */ return false; } - - score = (100*alarm_blob_pixels)/(polygon.Area()); + + if (max_blob_pixels != 0) + score = (100*alarm_blob_pixels)/(max_blob_pixels); + else + 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);