mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-06-21 03:41:55 +03:00
rebuild motion and object filter masks on detect resolution change
Apply the detect update first so frame_shape reflects the new resolution before we rebuild dependents. Motion's rasterized_mask is sized to frame_shape at construction. When detect resolution changes we must rebuild RuntimeMotionConfig so the mask matches the new frame size; otherwise consumers like the LPR processor and motion detector hit a shape mismatch when they index frames with the stale mask. Same story for per-object filter masks — rebuild RuntimeFilterConfig at the new frame_shape so the merged global+per-object masks they hold match what they'll be indexed against.
This commit is contained in:
parent
ed08d4152b
commit
5adaebf2cd
@ -788,6 +788,34 @@ def apply_section_update(camera_config, section: str, update: dict) -> Optional[
|
||||
)
|
||||
camera_config.objects = new_objects
|
||||
|
||||
elif section == "detect":
|
||||
# apply detect first so frame_shape reflects the new resolution
|
||||
# before we rebuild mask-dependent runtime configs below
|
||||
merged = deep_merge(current.model_dump(), update, override=True)
|
||||
camera_config.detect = current.__class__.model_validate(merged)
|
||||
|
||||
new_frame_shape = camera_config.frame_shape
|
||||
|
||||
# rebuild motion's rasterized_mask at the new frame_shape
|
||||
if camera_config.motion is not None:
|
||||
camera_config.motion = RuntimeMotionConfig(
|
||||
frame_shape=new_frame_shape,
|
||||
**camera_config.motion.model_dump(exclude_unset=True),
|
||||
)
|
||||
|
||||
# rebuild per-object filter masks at the new frame_shape
|
||||
for obj_name, filt in camera_config.objects.filters.items():
|
||||
merged_mask = dict(filt.mask)
|
||||
if camera_config.objects.mask:
|
||||
for gid, gmask in camera_config.objects.mask.items():
|
||||
merged_mask[f"global_{gid}"] = gmask
|
||||
|
||||
camera_config.objects.filters[obj_name] = RuntimeFilterConfig(
|
||||
frame_shape=new_frame_shape,
|
||||
mask=merged_mask,
|
||||
**filt.model_dump(exclude_unset=True, exclude={"mask", "raw_mask"}),
|
||||
)
|
||||
|
||||
else:
|
||||
merged = deep_merge(current.model_dump(), update, override=True)
|
||||
setattr(camera_config, section, current.__class__.model_validate(merged))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user