Skip to content

scoutant/face-blur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Smart face blur using 3D Dense Face Alignment

students blurred

Versus standard face blurring tool rectangular regions :

students blurred

3D Dense Face Alignment project

Realtime face modeling. Computing Basel Face Model, with 38000+ face landmarks!

Emma with 3d output

Paper Towards Fast, Accurate and Stable 3D Dense Face Alignment, 2020/09, https://arxiv.org/abs/2009.09960

Official PyTorch implementation of 3D Dense Face Alignment : https://github.com/cleardusk/3DDFA_V2

git clone https://github.com/cleardusk/3DDFA_V2.git
cd 3DDFA_V2
sh ./build.sh

Running face blur demo

cd ..
git clone https://github.com/scoutant/face-blur.git
cd 3DDFA_V2
python ../face-blur/blur.py -f ../face-blur/data/students2.jpg

How is computed the blur for each face

For each face the 3ddfa runtime provides a list of 38365 landmarks. For the use case it is enough to pick 1 every 36 landmark.

We can use OpenCV to compute the convex hull which will be our region of interest for the face. Which is smarter than a plain rectangle. This will be the mask for the face.

Let's see what are the steps to achieve a smooth transition.

students blurred

The convex hull and corresponding OpenCV polygone are merely a binary image. We can apply a gaussian blur onto the mask itself to compute smooth transition with multiple intermediate shades of grey.

Now we can apply another gaussian blur on the face itself.

We are ready to blend the 2 images accordingly to the mask: hence operating a linear blend with weights provided by the mask.

The kernel size for the gaussian blur does matter. It has to be related to the size of the face region of interest.

OpenCV's findContrours() function will provide the dimension of the bounding box and we can choose the kernel as a proportion of the size.

About

Face blur using 3D Dense Face Alignment so as to achieve a smarter and smoother proposal than a plain rectangle

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages