diff --git a/frigate/config.py b/frigate/config.py index 9b434ca1e..2d9bb102a 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -187,7 +187,7 @@ class RecordConfig(FrigateBaseModel): class MotionConfig(FrigateBaseModel): threshold: int = Field( - default=40, + default=30, title="Motion detection threshold (1-255).", ge=1, le=255, @@ -196,10 +196,10 @@ class MotionConfig(FrigateBaseModel): default=0.8, title="Lightning detection threshold (0.3-1.0).", ge=0.3, le=1.0 ) improve_contrast: bool = Field(default=True, title="Improve Contrast") - contour_area: Optional[int] = Field(default=15, title="Contour Area") + contour_area: Optional[int] = Field(default=10, title="Contour Area") delta_alpha: float = Field(default=0.2, title="Delta Alpha") frame_alpha: float = Field(default=0.02, title="Frame Alpha") - frame_height: Optional[int] = Field(default=50, title="Frame Height") + frame_height: Optional[int] = Field(default=100, title="Frame Height") mask: Union[str, List[str]] = Field( default="", title="Coordinates polygon for the motion mask." ) diff --git a/frigate/motion/improved_motion.py b/frigate/motion/improved_motion.py index 882cd22ee..0aa259940 100644 --- a/frigate/motion/improved_motion.py +++ b/frigate/motion/improved_motion.py @@ -38,6 +38,7 @@ class ImprovedMotionDetector(MotionDetector): self.improve_contrast = improve_contrast self.threshold = threshold self.contour_area = contour_area + self.clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) def detect(self, frame): motion_boxes = [] @@ -55,7 +56,7 @@ class ImprovedMotionDetector(MotionDetector): # Improve contrast if self.improve_contrast.value: - resized_frame = cv2.equalizeHist(resized_frame) + resized_frame = self.clahe.apply(resized_frame) # mask frame resized_frame[self.mask] = [255] diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py index a9e665706..8e767f77f 100644 --- a/frigate/test/test_config.py +++ b/frigate/test/test_config.py @@ -730,7 +730,7 @@ class TestConfig(unittest.TestCase): assert config == frigate_config.dict(exclude_unset=True) runtime_config = frigate_config.runtime_config() - assert runtime_config.cameras["back"].motion.frame_height == 50 + assert runtime_config.cameras["back"].motion.frame_height == 100 def test_motion_contour_area_dynamic(self): config = { @@ -758,7 +758,7 @@ class TestConfig(unittest.TestCase): assert config == frigate_config.dict(exclude_unset=True) runtime_config = frigate_config.runtime_config() - assert round(runtime_config.cameras["back"].motion.contour_area) == 15 + assert round(runtime_config.cameras["back"].motion.contour_area) == 10 def test_merge_labelmap(self): config = {