component changes to use rasterized_mask

This commit is contained in:
Josh Hawkins 2026-01-15 11:42:55 -06:00
parent 105e7ca4fd
commit 35fd1ccbc0
6 changed files with 12 additions and 10 deletions

View File

@ -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"):

View File

@ -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]

View File

@ -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,
)

View File

@ -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,
)

View File

@ -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)

View File

@ -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