diff --git a/docs/changelog.md b/docs/changelog.md
index c5f3209..0920d96 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -35,7 +35,7 @@ There are also several other bugfixes and improvements, such as improved seeking
-detection-parameters)
- [general] Noise reduction kernel can now be disabled by setting `-k`/`--kernel-size` to `0` ([#123](https://github.com/Breakthrough/DVR-Scan/issues/123))
- [general] Include stack traces in logfiles when setting `--verbosity debug`
- - [bugfix] Fix CNT mode always treating first few frame as having motion [#119](https://github.com/Breakthrough/DVR-Scan/issues/119)
+ - [bugfix] Add `max-score` option to config file to fix CNT mode always treating first few frame as motion, default is 255.0 [#119](https://github.com/Breakthrough/DVR-Scan/issues/119)
- [bugfix] Fix timecode format `HH:MM:SS[.nnn]` being rejected for start/end time ([#141](https://github.com/Breakthrough/DVR-Scan/issues/141))
- [bugfix] Fix incorrect RGB mapping for config file (values were treated as BGR instead)
- [other] Config option `timecode` has been renamed to `time-code` to match the command-line option
diff --git a/docs/docs.md b/docs/docs.md
index c02321d..0dfe611 100644
--- a/docs/docs.md
+++ b/docs/docs.md
@@ -358,6 +358,14 @@ The following options control motion detection. A more comprehensive descriptio
```
+ * max-threshold
+ Scores of this amount or higher are ignored. 255.0 is the maximum score, so values greater than 255.0 will disable the filter.
+
+ ```
+ max-threshold = 255.0
+ ```
+
+
* kernel-size
Size (in pixels) of the noise reduction kernel. Size must be an odd number starting from 3, 0 to disable, or -1 to auto-set based on video resolution.
diff --git a/dvr-scan.cfg b/dvr-scan.cfg
index 3be2e36..42a69ec 100644
--- a/dvr-scan.cfg
+++ b/dvr-scan.cfg
@@ -83,6 +83,10 @@
# while too low of a threshold can result in false detection events.
#threshold = 0.15
+# Scores of this amount or higher are ignored. 255.0 is the maximum score,
+# so values greater than 255.0 will disable the filter.
+#max-threshold = 255.0
+
# Size (in pixels) of the noise reduction kernel. Can be odd integer starting
# from 3, 0 to disable, or -1 to auto-set using video resolution.
#kernel-size = -1
diff --git a/dvr_scan/cli/config.py b/dvr_scan/cli/config.py
index 91e7a9b..bae043a 100644
--- a/dvr_scan/cli/config.py
+++ b/dvr_scan/cli/config.py
@@ -319,6 +319,7 @@ def from_config(config_value: str, default: 'RGBValue') -> 'RGBValue':
# Detection Parameters
'bg-subtractor': 'MOG2',
'threshold': 0.15,
+ 'max-threshold': 255.0,
'kernel-size': KernelSizeValue(),
'downscale-factor': 0,
# TODO(v1.7): Remove, replaced with region files.
diff --git a/dvr_scan/cli/controller.py b/dvr_scan/cli/controller.py
index 83c27cd..3459aff 100644
--- a/dvr_scan/cli/controller.py
+++ b/dvr_scan/cli/controller.py
@@ -271,6 +271,7 @@ def run_dvr_scan(settings: ProgramSettings) -> ty.List[ty.Tuple[FrameTimecode, F
scanner.set_detection_params(
detector_type=DetectorType[settings.get('bg-subtractor').upper()],
threshold=settings.get('threshold'),
+ max_threshold=settings.get('max-threshold'),
kernel_size=settings.get('kernel-size'),
downscale_factor=settings.get('downscale-factor'),
)
diff --git a/dvr_scan/scanner.py b/dvr_scan/scanner.py
index 5c57218..d2a4509 100644
--- a/dvr_scan/scanner.py
+++ b/dvr_scan/scanner.py
@@ -236,10 +236,7 @@ def __init__(self,
self._threshold = 0.15 # -t/--threshold
self._kernel_size = None # -k/--kernel-size
self._downscale_factor = 1 # -df/--downscale-factor
-
- # TODO(v1.6): Add ability to configure the rejection filter (_max_score_) by adding a
- # threshold + amount option (e.g. ignore up to 2 frames in a row that are over score 100).
- self._max_score = 255.0
+ self._max_threshold = 255.0 # max-threshold
# Motion Event Parameters (set_event_params)
self._min_event_len = None # -l/--min-event-length
@@ -365,11 +362,13 @@ def set_detection_params(
self,
detector_type: DetectorType = DetectorType.MOG2,
threshold: float = 0.15,
+ max_threshold: float = 255.0,
kernel_size: int = -1,
downscale_factor: int = 1,
):
"""Set detection parameters."""
self._threshold = threshold
+ self._max_threshold = max_threshold
self._subtractor_type = detector_type
if downscale_factor < 0:
raise ValueError("Downscale factor must be positive.")
@@ -638,7 +637,7 @@ def scan(self) -> Optional[DetectionResult]:
frame_score = result.score
# TODO(v1.6): Allow disabling the rejection filter or customizing amount of
# consecutive frames it will ignore.
- if frame_score >= self._max_score:
+ if frame_score >= self._max_threshold:
frame_score = 0
above_threshold = frame_score >= self._threshold
event_window.append(frame_score)