use faster interpolation for motion

This commit is contained in:
Blake Blackshear 2023-06-29 07:02:09 -05:00
parent eac3df98b2
commit bf7b53968d

View File

@ -18,6 +18,7 @@ class ImprovedMotionDetector(MotionDetector):
contour_area, contour_area,
name="improved", name="improved",
blur_radius=1, blur_radius=1,
interpolation=cv2.INTER_NEAREST,
): ):
self.name = name self.name = name
self.config = config self.config = config
@ -33,7 +34,7 @@ class ImprovedMotionDetector(MotionDetector):
resized_mask = cv2.resize( resized_mask = cv2.resize(
config.mask, config.mask,
dsize=(self.motion_frame_size[1], self.motion_frame_size[0]), dsize=(self.motion_frame_size[1], self.motion_frame_size[0]),
interpolation=cv2.INTER_LINEAR, interpolation=cv2.INTER_AREA,
) )
self.mask = np.where(resized_mask == [0]) self.mask = np.where(resized_mask == [0])
self.save_images = False self.save_images = False
@ -42,6 +43,7 @@ class ImprovedMotionDetector(MotionDetector):
self.threshold = threshold self.threshold = threshold
self.contour_area = contour_area self.contour_area = contour_area
self.blur_radius = blur_radius self.blur_radius = blur_radius
self.interpolation = interpolation
def detect(self, frame): def detect(self, frame):
motion_boxes = [] motion_boxes = []
@ -52,7 +54,7 @@ class ImprovedMotionDetector(MotionDetector):
resized_frame = cv2.resize( resized_frame = cv2.resize(
gray, gray,
dsize=(self.motion_frame_size[1], self.motion_frame_size[0]), dsize=(self.motion_frame_size[1], self.motion_frame_size[0]),
interpolation=cv2.INTER_LINEAR, interpolation=self.interpolation,
) )
# mask frame # mask frame