diff --git a/README.md b/README.md index 416c71c..f5b5481 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ # `deface`: Video anonymization by face detection `deface` is a simple command-line tool for automatic anonymization of faces in videos or photos. -It works by first detecting all human faces in each video frame and then applying an anonymization filter (blurring or black boxes) on each detected face region. +It works by first detecting all human faces in each video frame and then applying an anonymization filter (black boxes, mosaic or blurring) on each detected face region. By default all audio tracks are discarded as well. @@ -26,6 +26,7 @@ Alternatively, if you want to use the latest (unreleased) revision directly from This will only install the dependencies that are strictly required for running the tool. If you want to speed up processing by enabling hardware acceleration, you will need to manually install additional packages, see [Hardware acceleration](#hardware-acceleration) +`deface` is also available as an AUR package ## Usage @@ -91,10 +92,10 @@ optional arguments: --replacewith {blur,solid,none,img,mosaic} Anonymization filter mode for face regions. "blur" applies a strong gaussian blurring, "solid" draws a - solid black box, "none" does leaves the input + solid black box, "none" leaves the input unchanged, "img" replaces the face with a custom image and "mosaic" replaces the face with mosaic. Default: - "blur". + "solid". --replaceimg REPLACEIMG Anonymization image for face regions. Requires --replacewith img option. @@ -124,13 +125,19 @@ optional arguments: In most use cases the default configuration should be sufficient, but depending on individual requirements and type of media to be processed, some of the options might need to be adjusted. In this section, some common example scenarios that require option changes are presented. All of the examples use the photo [examples/city.jpg](examples/city.jpg), but they work the same on any video or photo file. -### Drawing black boxes +### Blurring faces in blocks -By default, each detected face is anonymized by applying a blur filter to an ellipse region that covers the face. If you prefer to anonymize faces by drawing black boxes on top of them, you can achieve this through the `--boxes` and `--replacewith` options: +By default, each detected face is anonymized by replacing the face with a black box. If you prefer to anonymize faces by applying a blur to an ellipse region that covers them, you can achieve this through the `--blur` and `--replacewith` options: - $ deface examples/city.jpg --boxes --replacewith solid -o examples/city_anonymized_boxes.jpg + $ deface examples/city.jpg --replacewith blur -o examples/city_anonymized_boxes.jpg -$ deface examples/city.jpg --enable-boxes --replacewith solid -o examples/city_anonymized_boxes.jpg +$ deface examples/city.jpg --replacewith blur -o examples/city_anonymized_blur.jpg + +It is also possible to blur the whole box instead of an ellipse: + + $ deface examples/city.jpg --boxes --replacewith blur -o examples/city_anonymized_boxes.jpg + +$ deface examples/city.jpg --boxes --replacewith blur -o examples/city_anonymized_blur_boxes.jpg ### Mosaic anonymization @@ -164,7 +171,7 @@ To demonstrate the effects of a threshold that is set too low or too high, see t If you are interested in seeing the faceness score (a score between 0 and 1 that roughly corresponds to the detector's confidence that something *is* a face) of each detected face in the input, you can enable the `--draw-scores` option to draw the score of each detection directly above its location. - $ deface examples/city.jpg --draw-scores -o examples/city_anonymized_scores.jpg + $ deface examples/city.jpg --draw-scores --replacewith blur -o examples/city_anonymized_scores.jpg $ deface examples/city.jpg --draw-scores -o examples/city_anonymized_scores.jpg diff --git a/deface/deface.py b/deface/deface.py index d6cbb65..69463aa 100644 --- a/deface/deface.py +++ b/deface/deface.py @@ -30,7 +30,7 @@ def scale_bb(x1, y1, x2, y2, mask_scale=1.0): def draw_det( frame, score, det_idx, x1, y1, x2, y2, - replacewith: str = 'blur', + replacewith: str = 'solid', ellipse: bool = True, draw_scores: bool = False, ovcolor: Tuple[int] = (0, 0, 0), @@ -297,7 +297,7 @@ def parse_cli_args(): '--mask-scale', default=1.3, type=float, metavar='M', help='Scale factor for face masks, to make sure that masks cover the complete face. Default: 1.3.') parser.add_argument( - '--replacewith', default='blur', choices=['blur', 'solid', 'none', 'img', 'mosaic'], + '--replacewith', default='solid', choices=['blur', 'solid', 'none', 'img', 'mosaic'], help='Anonymization filter mode for face regions. "blur" applies a strong gaussian blurring, "solid" draws a solid black box, "none" does leaves the input unchanged, "img" replaces the face with a custom image and "mosaic" replaces the face with mosaic. Default: "blur".') parser.add_argument( '--replaceimg', default='replace_img.png', diff --git a/examples/city_anonymized.jpg b/examples/city_anonymized.jpg index 3e71dc5..9c59f0c 100644 Binary files a/examples/city_anonymized.jpg and b/examples/city_anonymized.jpg differ diff --git a/examples/city_anonymized_blur.jpg b/examples/city_anonymized_blur.jpg new file mode 100644 index 0000000..3e71dc5 Binary files /dev/null and b/examples/city_anonymized_blur.jpg differ diff --git a/examples/city_anonymized_blur_boxes.jpg b/examples/city_anonymized_blur_boxes.jpg new file mode 100644 index 0000000..ae1a2ce Binary files /dev/null and b/examples/city_anonymized_blur_boxes.jpg differ diff --git a/examples/city_anonymized_boxes.jpg b/examples/city_anonymized_boxes.jpg deleted file mode 100644 index 9c59f0c..0000000 Binary files a/examples/city_anonymized_boxes.jpg and /dev/null differ diff --git a/examples/city_anonymized_scores.jpg b/examples/city_anonymized_scores.jpg index 449c30a..cf18550 100644 Binary files a/examples/city_anonymized_scores.jpg and b/examples/city_anonymized_scores.jpg differ diff --git a/examples/city_anonymized_thresh0.02.jpg b/examples/city_anonymized_thresh0.02.jpg index ef5be3c..2babea2 100644 Binary files a/examples/city_anonymized_thresh0.02.jpg and b/examples/city_anonymized_thresh0.02.jpg differ diff --git a/examples/city_anonymized_thresh0.7.jpg b/examples/city_anonymized_thresh0.7.jpg index 7ca1928..645fd89 100644 Binary files a/examples/city_anonymized_thresh0.7.jpg and b/examples/city_anonymized_thresh0.7.jpg differ