diff --git a/src/faceblur/app.py b/src/faceblur/app.py index 2c130ed..e6371cf 100644 --- a/src/faceblur/app.py +++ b/src/faceblur/app.py @@ -201,8 +201,16 @@ def run() -> None: blur_method = questionary.select( "Select blur method:", - choices=["gaussian", "pixelate", "blackout", "elliptical", "median"], - default="gaussian", + choices=[ + questionary.Choice( + "Pixelate (Blazingly Fast - Recommended)", value="pixelate" + ), + questionary.Choice("Blackout (Blazingly Fast)", value="blackout"), + questionary.Choice("Gaussian (Moderate CPU)", value="gaussian"), + questionary.Choice("Elliptical (Heavy CPU)", value="elliptical"), + questionary.Choice("Median (Heavy CPU)", value="median"), + ], + default="pixelate", ).ask() if not blur_method: diff --git a/src/faceblur/blur.py b/src/faceblur/blur.py index e1b5557..5a3dc49 100644 --- a/src/faceblur/blur.py +++ b/src/faceblur/blur.py @@ -13,6 +13,7 @@ def apply_blur( bbox: Tuple[int, int, int, int], method: BlurMethod = "gaussian", strength: float = 5.0, + padding: float = 0.25, ) -> np.ndarray: """Apply blur to a face region in an image. @@ -21,11 +22,22 @@ def apply_blur( bbox: Face bounding box (x1, y1, x2, y2) method: Blur method name strength: Blur strength multiplier + padding: Percentage to expand the bounding box to prevent tracking lag exposure Returns: The modified image """ x1, y1, x2, y2 = bbox + + # Expand bounding box to account for interpolation lag + w_pad = int((x2 - x1) * padding) + h_pad = int((y2 - y1) * padding) + + x1 -= w_pad + y1 -= h_pad + x2 += w_pad + y2 += h_pad + h, w = image.shape[:2] # Clamp to image bounds @@ -91,7 +103,8 @@ def interpolate_bboxes( Returns: Interpolated bounding box """ - return tuple(int(a + t * (b - a)) for a, b in zip(bbox_a, bbox_b)) + res = tuple(int(a + t * (b - a)) for a, b in zip(bbox_a, bbox_b)) + return (res[0], res[1], res[2], res[3]) def get_bboxes_for_frame(