From 23ed39c38b339d9f5492859016d4ea6461a45ea8 Mon Sep 17 00:00:00 2001 From: Frederik Juutilainen Date: Mon, 26 Apr 2021 10:44:23 +0200 Subject: [PATCH] added function to get anonymized image --- deface/deface.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/deface/deface.py b/deface/deface.py index ad53724..4feccbf 100755 --- a/deface/deface.py +++ b/deface/deface.py @@ -199,6 +199,29 @@ def get_file_type(path): return mime +def get_anonymized_image(frame, + threshold: float, + replacewith: str, + mask_scale: float, + ellipse: bool, + draw_scores: bool, + ): + """ + Method for getting an anonymized image without CLI + returns frame + """ + + centerface = CenterFace(in_shape=None, backend='auto') + dets, _ = centerface(frame, threshold=threshold) + + anonymize_frame( + dets, frame, mask_scale=mask_scale, + replacewith=replacewith, ellipse=ellipse, draw_scores=draw_scores + ) + + return frame + + def parse_cli_args(): parser = argparse.ArgumentParser(description='Video anonymization by face detection', add_help=False) parser.add_argument(