From d12c4d706c68b8b433712bd44f62aeb8f1213387 Mon Sep 17 00:00:00 2001 From: Brandon Castellano Date: Sun, 21 Feb 2021 01:00:06 -0500 Subject: [PATCH] Change adaptive_ratio to 255.0 instead of threshold+1 when handling division by zero (#153). --- scenedetect/detectors/adaptive_content_detector.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scenedetect/detectors/adaptive_content_detector.py b/scenedetect/detectors/adaptive_content_detector.py index 5e9ea4e6..66cd7302 100644 --- a/scenedetect/detectors/adaptive_content_detector.py +++ b/scenedetect/detectors/adaptive_content_detector.py @@ -135,12 +135,12 @@ def post_process(self, _): if not denominator_is_zero: adaptive_ratio = self.get_content_val(frame_num) / denominator elif denominator_is_zero and self.get_content_val(frame_num) >= self.min_delta_hsv: - # if we would have divided by zero, set adaptive_ratio above the threshold - adaptive_ratio = adaptive_threshold + 1 + # if we would have divided by zero, set adaptive_ratio to the max (255.0) + adaptive_ratio = 255.0 else: # avoid dividing by zero by setting con_val_ratio to zero if content_val # is still very low - adaptive_ratio = 0 + adaptive_ratio = 0.0 self.stats_manager.set_metrics( frame_num, {self._adaptive_ratio_key: adaptive_ratio})