Blurfaces¶
scaling_mask ¶
scaling_mask(x1, y1, x2, y2, mask_scale=1.0)
Scale factor for face masks, to make sure that the masks cover the complete face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
int
|
X start coordinate value |
required |
y1
|
int
|
Y start coordinate value |
required |
x2
|
int
|
X end coordinate value |
required |
y2
|
int
|
Y end coordinate value |
required |
mask_scale
|
float
|
Scale factor for adjusting the size of the face masks. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
|
[x1, y1, x2, y2]: A list of intergers corresponding to the scaled coordinates of the face masks. |
Source code in musicalgestures/_blurfaces.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
mg_blurfaces ¶
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), use_gpu=False, target_name=None, overwrite=True)
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
str
|
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'. |
'blur'
|
mask_image
|
str
|
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. |
None
|
mask_scale
|
float
|
Scale factor for face masks, to make sure that the masks cover the complete face. Defaults to 1.0. |
1.0
|
ellipse
|
bool
|
Mask faces with blurred ellipses. Defaults to True. |
True
|
draw_heatmap
|
bool
|
Draw heatmap of the detected faces using the centroid of the face mask. Defaults to False. |
False
|
neighbours
|
int
|
Number of neighbours for smoothing the heatmap image. Defaults to 32. |
32
|
resolution
|
int
|
Number of pixel resolution for the heatmap visualization. Defaults to 250. |
250
|
draw_scores
|
bool
|
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. |
False
|
save_data
|
bool
|
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. |
True
|
data_format
|
str
|
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'. |
'csv'
|
color
|
tuple
|
Customized color of the rectangle boxes. Defaults to black (0, 0, 0). |
(0, 0, 0)
|
use_gpu
|
bool
|
Whether to attempt GPU (CUDA) acceleration for face detection. Falls back to CPU automatically if CUDA is unavailable. Defaults to False. |
False
|
target_name
|
str
|
Target output name. Defaults to None (which assumes that the input filename with the suffix "_blurred" should be used). |
None
|
overwrite
|
bool
|
Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
MgVideo |
A MgVideo as blur_faces for parent MgVideo |
Source code in musicalgestures/_blurfaces.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |