Skip to content

Commit f31c537

Browse files
committed
[app] Fix overlays stuck on #218
The logic to check bounding box is a bit complicated in the shared module as it's different for the CLI vs. config file. This changes it to make the differences more clear, and also updates the flag value from False to True. This simplifies checks, and also allows us to fallback so that if the value is not a boolean, we can assume the user specified smoothing time via the `-bb` CLI flag (in which case the config option is overriden). When the `-bb` flag is set alone, or from the UI, the bounding-box-smooth-time setting is used as expected.
1 parent b15d77a commit f31c537

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

docs/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ This version of DVR-Scan includes a new, faster background subtraction algorithm
346346

347347
### In Development
348348

349+
* [bugfix] Fix bounding box overlay stuck on when using the OpenCV output mode [#213](https://github.com/Breakthrough/DVR-Scan/issues/209)
349350
* [feature] various UI enhancements:
350351
* input videos can now be sorted
351352
* add button to open log folder

dvr_scan/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def get_cli_parser(user_config: ConfigRegistry):
370370
metavar="smooth_time",
371371
type=timecode_type_check("smooth_time"),
372372
nargs="?",
373-
const=False,
373+
const=True,
374374
help=(
375375
"If set, draws a bounding box around the area where motion was detected. The amount"
376376
" of temporal smoothing can be specified in either frames (12345) or seconds (number"

dvr_scan/shared/__init__.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,21 +138,23 @@ def init_scanner(
138138
)
139139

140140
bounding_box = None
141-
# bounding_box_arg will be None if -bb was not set, False if -bb was set without any args,
142-
# otherwise it represents the desired smooth time.
143-
bounding_box_arg = settings.get_arg("bounding-box")
144-
if bounding_box_arg is not None or settings.get("bounding-box"):
145-
if bounding_box_arg is not None and bounding_box_arg is not False:
146-
smoothing_time = FrameTimecode(bounding_box_arg, scanner.framerate)
147-
else:
148-
smoothing_time = FrameTimecode(
149-
settings.get("bounding-box-smooth-time"), scanner.framerate
150-
)
141+
142+
# NOTE: The CLI overloads the type of the bounding-box setting by allowing an optional smooth
143+
# time. When set, this means the flag is no longer boolean, and represents desired smoothing.
144+
bounding_box_option_is_smoothing = not isinstance(settings.get("bounding-box"), bool)
145+
bounding_box_enabled = bool(settings.get("bounding-box")) or bounding_box_option_is_smoothing
146+
if bounding_box_enabled:
147+
smoothing_time = (
148+
settings.get("bounding-box")
149+
if bounding_box_option_is_smoothing
150+
else settings.get("bounding-box-smooth-time")
151+
)
152+
smoothing = FrameTimecode(smoothing_time, scanner.framerate).frame_num
151153
bounding_box = BoundingBoxOverlay(
152154
min_size_ratio=settings.get("bounding-box-min-size"),
153155
thickness_ratio=settings.get("bounding-box-thickness"),
154156
color=settings.get("bounding-box-color"),
155-
smoothing=smoothing_time.frame_num,
157+
smoothing=smoothing,
156158
)
157159

158160
scanner.set_overlays(

0 commit comments

Comments
 (0)