use clahe for contrast improvement

This commit is contained in:
Blake Blackshear 2023-06-18 08:46:26 -05:00
parent 09cc4251f0
commit 333ee80abf
2 changed files with 5 additions and 4 deletions

View File

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

View File

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