From 35fd1ccbc0d4ac0dd1610083c6c1133ed0d8461f Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 15 Jan 2026 11:42:55 -0600 Subject: [PATCH] component changes to use rasterized_mask --- frigate/camera/state.py | 2 +- frigate/data_processing/common/license_plate/mixin.py | 4 ++-- frigate/motion/frigate_motion.py | 2 +- frigate/motion/improved_motion.py | 2 +- frigate/ptz/autotrack.py | 4 +++- frigate/util/object.py | 8 ++++---- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/frigate/camera/state.py b/frigate/camera/state.py index 97c715388..181532fa8 100644 --- a/frigate/camera/state.py +++ b/frigate/camera/state.py @@ -65,7 +65,7 @@ class CameraState: frame_copy = cv2.cvtColor(frame_copy, cv2.COLOR_YUV2BGR_I420) # draw on the frame if draw_options.get("mask"): - mask_overlay = np.where(self.camera_config.motion.mask == [0]) + mask_overlay = np.where(self.camera_config.motion.rasterized_mask == [0]) frame_copy[mask_overlay] = [0, 0, 0] if draw_options.get("bounding_boxes"): diff --git a/frigate/data_processing/common/license_plate/mixin.py b/frigate/data_processing/common/license_plate/mixin.py index b56c66a19..ae06c0d0a 100644 --- a/frigate/data_processing/common/license_plate/mixin.py +++ b/frigate/data_processing/common/license_plate/mixin.py @@ -1220,7 +1220,7 @@ class LicensePlateProcessingMixin: rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420) # apply motion mask - rgb[self.config.cameras[obj_data].motion.mask == 0] = [0, 0, 0] + rgb[self.config.cameras[obj_data].motion.rasterized_mask == 0] = [0, 0, 0] if WRITE_DEBUG_IMAGES: cv2.imwrite( @@ -1324,7 +1324,7 @@ class LicensePlateProcessingMixin: rgb = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420) # apply motion mask - rgb[self.config.cameras[camera].motion.mask == 0] = [0, 0, 0] + rgb[self.config.cameras[camera].motion.rasterized_mask == 0] = [0, 0, 0] left, top, right, bottom = car_box car = rgb[top:bottom, left:right] diff --git a/frigate/motion/frigate_motion.py b/frigate/motion/frigate_motion.py index fd362de34..d49b0e861 100644 --- a/frigate/motion/frigate_motion.py +++ b/frigate/motion/frigate_motion.py @@ -28,7 +28,7 @@ class FrigateMotionDetector(MotionDetector): self.motion_frame_count = 0 self.frame_counter = 0 resized_mask = cv2.resize( - config.mask, + config.rasterized_mask, dsize=(self.motion_frame_size[1], self.motion_frame_size[0]), interpolation=cv2.INTER_LINEAR, ) diff --git a/frigate/motion/improved_motion.py b/frigate/motion/improved_motion.py index b081d3791..a8f2ab12c 100644 --- a/frigate/motion/improved_motion.py +++ b/frigate/motion/improved_motion.py @@ -233,7 +233,7 @@ class ImprovedMotionDetector(MotionDetector): def update_mask(self) -> None: resized_mask = cv2.resize( - self.config.mask, + self.config.rasterized_mask, dsize=(self.motion_frame_size[1], self.motion_frame_size[0]), interpolation=cv2.INTER_AREA, ) diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.py index 6e86ecbf2..eb2d16940 100644 --- a/frigate/ptz/autotrack.py +++ b/frigate/ptz/autotrack.py @@ -116,7 +116,9 @@ class PtzMotionEstimator: mask[y1:y2, x1:x2] = 0 # merge camera config motion mask with detections. Norfair function needs 0,1 mask - mask = np.bitwise_and(mask, self.camera_config.motion.mask).clip(max=1) + mask = np.bitwise_and(mask, self.camera_config.motion.rasterized_mask).clip( + max=1 + ) # Norfair estimator function needs color so it can convert it right back to gray frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGRA) diff --git a/frigate/util/object.py b/frigate/util/object.py index 905745da6..021150132 100644 --- a/frigate/util/object.py +++ b/frigate/util/object.py @@ -248,20 +248,20 @@ def is_object_filtered(obj, objects_to_track, object_filters): if obj_settings.max_ratio < object_ratio: return True - if obj_settings.mask is not None: + if obj_settings.rasterized_mask is not None: # compute the coordinates of the object and make sure # the location isn't outside the bounds of the image (can happen from rounding) object_xmin = object_box[0] object_xmax = object_box[2] object_ymax = object_box[3] - y_location = min(int(object_ymax), len(obj_settings.mask) - 1) + y_location = min(int(object_ymax), len(obj_settings.rasterized_mask) - 1) x_location = min( int((object_xmax + object_xmin) / 2.0), - len(obj_settings.mask[0]) - 1, + len(obj_settings.rasterized_mask[0]) - 1, ) # if the object is in a masked location, don't add it to detected objects - if obj_settings.mask[y_location][x_location] == 0: + if obj_settings.rasterized_mask[y_location][x_location] == 0: return True return False