
YouTube-Style Face Detect – Crop and Blur Using Python and OpenCV - bobmax17x
https://www.nintyzeros.com/2020/04/face-detect-crop-blur-opencv-python.html
======
cbhl
In my personal opinion, a naive gaussian blur could be susceptible to
supersampling attacks, especially in a video where you can take samples over
multiple frames. In a production implementation, I would consider adding some
steps to mitigate this.

~~~
aripickar
Theoretically, augmenting the blurred image with some sort of random, changing
offset for the HSV values on each frame would prevent supersampling attacks,
right?

~~~
contravariant
Adding noise is definitely helps, but removing noise is more or less the main
feature of supersampling.

If you didn't have any noise you could just simply invert the Gaussian blur,
as blurring is a reversible operation (in theory, in practice you have noise,
hence the need for supersampling).

Annoyingly it's hard to come up with a method that doesn't leak _any_
information, although heavily pixelating the image (and optionally blurring
the few leftover pixels) would probably make it infeasible to recover the
original (except maybe with a truly stupendous amount of footage).

------
KaiserPro
nice work.

If you have GPU power, I recommend using tinyfaces
([https://www.cs.cmu.edu/~peiyunh/tiny/](https://www.cs.cmu.edu/~peiyunh/tiny/))
as your face detector. But you won't get realtime performance...

We used a similar model to detect and blur faces from raw user uploaded images
at scale, using a multi-stage pipeline.

~~~
sorenjan
Does it work on GPUs other than Nvidia?

~~~
KaiserPro
depends, the model is agnostic, but I've not looked at backend as everything
we have here is nvidia.

------
snovv_crash
Nice and clean. However, it looks like the blur has some (blue?) banding
artifacts in it. Am I the only one who sees that?

~~~
ihuman
I see it too. I wonder if it's including the blue border you see in one of the
earlier debugging images.

~~~
snovv_crash
Hah, yes, I guess they're doing the blurring on the image with the box
overlaid, instead of the original.

~~~
cbhl
Yes, I would also guess they're blurring the image with the box overlaid.

In a production implementation, you may also want to consider how you do edge
handling here. (For faces in the middle of the frame, you want to use the real
pixels from the underlying source image? Do you want to extend the pixels from
inside the border? What are the aesthetic and information theory implications
of each technique?)

[https://en.wikipedia.org/wiki/Kernel_(image_processing)#Edge...](https://en.wikipedia.org/wiki/Kernel_\(image_processing\)#Edge_Handling)

------
poxrud
They are using the haar cascade face detection, which works well for when the
person is facing the camera straight ahead. Doesn't work great when the face
is at an angle.

------
willem19x
nice work! I liked low on CPU since nowadays its hard to implement things
without a GPU(DL) for things that involve to multiple crops/blur .

