Blurfaces¶
Auto-generated documentation for musicalgestures._blurfaces module.
- Mgt-python / Modules / Musicalgestures / Blurfaces
centroid_mask¶
heatmap_data¶
mg_blurfaces¶
def mg_blurfaces(
self,
mask='blur',
mask_image=None,
mask_scale=1.0,
ellipse=True,
draw_heatmap=False,
neighbours=32,
resolution=250,
draw_scores=False,
save_data=True,
data_format='csv',
color=(0, 0, 0),
target_name=None,
overwrite=False,
):
Automatic anonymization of faces in videos. This function works by first detecting all human faces in each video frame and then applying an anonymization filter (blurring, black rectangles or images) on each detected face region.
Credits: centerface.onnx (original) and centerface.py are based on https://github.com/Star-Clouds/centerface (revision 8c39a49), released under MIT license.
Arguments¶
maskstr, optional - Mask filter mode for face regions. 'blur' applies a strong gaussian blurring, 'rectangle' draws a solid black box, 'image' replaces the face with a custom image and 'none' does leaves the input unchanged. Defaults to 'blur'.mask_imagestr, optional - Anonymization image path which can be used for masking face regions. This can be activated by specifying 'image' in the mask parameter. Defaults to None.mask_scalefloat, optional - Scale factor for face masks, to make sure that the masks cover the complete face. Defaults to 1.0.ellipsebool, optional - Mask faces with blurred ellipses. Defaults to True.draw_heatmapbool, optional - Draw heatmap of the detected faces using the centroid of the face mask. Defaults to False.neighboursint, optional - Number of neighbours for smoothing the heatmap image. Defaults to 32.resolutionint, optional - Number of pixel resolution for the heatmap visualization. Defaults to 250.draw_scoresbool, optional - Draw detection faceness scores onto outputs (a score between 0 and 1 that roughly corresponds to the detector's confidence that something is a face). Defaults to False.save_databool, optional - Whether to save the scaled coordinates of the face mask (time (ms), x1, y1, x2, y2) for each frame to a file. Defaults to True.data_formatstr, optional - Specifies format of blur_faces-data. Accepted values are 'csv', 'tsv' and 'txt'. For multiple output formats, use list, e.g. ['csv', 'txt']. Defaults to 'csv'.colortuple, optional - Customized color of the rectangle boxes. Defaults to black (0, 0, 0).target_namestr, optional - Target output name. Defaults to None (which assumes that the input filename with the suffix "_blurred" should be used).overwritebool, optional - Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False.
Returns¶
MgVideo- A MgVideo as blur_faces for parent MgVideo
nearest_neighbours¶
scaling_mask¶
Scale factor for face masks, to make sure that the masks cover the complete face.
Arguments¶
x1int - X start coordinate valuey1int - Y start coordinate valuex2int - X end coordinate valuey2int - Y end coordinate valuemask_scalefloat, optional - Scale factor for adjusting the size of the face masks. Defaults to 1.0.
Returns¶
[x1, y1, x2, y2]: A list of intergers corresponding to the scaled coordinates of the face masks.