mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-27 17:17:40 +03:00
Adjust face blur reduction
This commit is contained in:
parent
347a5c62e7
commit
89623d8de1
@ -108,21 +108,22 @@ class FaceRecognizer(ABC):
|
||||
image, M, (output_width, output_height), flags=cv2.INTER_CUBIC
|
||||
)
|
||||
|
||||
def get_blur_confidence_reduction(self, input: np.ndarray) -> tuple[float, float]:
|
||||
def get_blur_confidence_reduction(self, input: np.ndarray) -> float:
|
||||
"""Calculates the reduction in confidence based on the blur of the image."""
|
||||
if not self.config.face_recognition.blur_confidence_filter:
|
||||
return 0, 0.0
|
||||
return 0.0
|
||||
|
||||
variance = cv2.Laplacian(input, cv2.CV_64F).var()
|
||||
logger.debug(f"face detected with blurriness {variance}")
|
||||
|
||||
if variance < 80: # image is very blurry
|
||||
return variance, 0.05
|
||||
elif variance < 100: # image moderately blurry
|
||||
return variance, 0.03
|
||||
elif variance < 150: # image is slightly blurry
|
||||
return variance, 0.01
|
||||
if variance < 120: # image is very blurry
|
||||
return 0.06
|
||||
elif variance < 160: # image moderately blurry
|
||||
return 0.04
|
||||
elif variance < 200: # image is slightly blurry
|
||||
return 0.02
|
||||
else:
|
||||
return variance, 0.0
|
||||
return 0.0
|
||||
|
||||
|
||||
def similarity_to_confidence(
|
||||
@ -234,8 +235,7 @@ class FaceNetRecognizer(FaceRecognizer):
|
||||
# face recognition is best run on grayscale images
|
||||
|
||||
# get blur factor before aligning face
|
||||
variance, blur_reduction = self.get_blur_confidence_reduction(face_image)
|
||||
logger.debug(f"face detected with blurriness {variance}")
|
||||
blur_reduction = self.get_blur_confidence_reduction(face_image)
|
||||
|
||||
# align face and run recognition
|
||||
img = self.align_face(face_image, face_image.shape[1], face_image.shape[0])
|
||||
@ -345,8 +345,7 @@ class ArcFaceRecognizer(FaceRecognizer):
|
||||
# face recognition is best run on grayscale images
|
||||
|
||||
# get blur reduction before aligning face
|
||||
variance, blur_reduction = self.get_blur_confidence_reduction(face_image)
|
||||
logger.debug(f"face detected with blurriness {variance}")
|
||||
blur_reduction = self.get_blur_confidence_reduction(face_image)
|
||||
|
||||
# align face and run recognition
|
||||
img = self.align_face(face_image, face_image.shape[1], face_image.shape[0])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user