Message Boards Message Boards

Masking faces in a webcam stream

Posted 12 years ago
Christopher question about augmented reality reminded me about a concealed identity trick used in video streams when black strips or blurred areas follow character faces. We can do this with Mathematica FindFaces functionality. There are a few different ways we can overlay transparent or opaque graphic objects and images with a live video stream. One of them is simply using Show. Let us find some simple overlay masks – and what can be better than some glasses, mustaches, goatees, and pipes?
 mask = Import /@ {

Now execute this code and bring a few friends to smile into camera:
  i = CurrentImage[];
  Show[i, Graphics[
     Inset[If[mix == "RANDOM", RandomChoice[mask], mix, mix],
       Offset[{0, -.27 #2}, #1], Center, #2] &,
     {Mean /@ #, -.8 Subtract @@@ #[[All, All, 1]]} &[FindFaces[i]]
    ], ImageSize -> 450]
, {{mix, mask[[7]], ""}, mask~Join~{"RANDOM"}, Setter},
FrameMargins -> 0, SynchronousUpdating -> False]

Thanks to our Wolfram volunteers for avid participation! Let me know if you can think of any improvements for this code.
Have fun!
POSTED BY: Vitaliy Kaurov
Posted 12 years ago
Excellent!  And now we need Mustache curves in Wolfram|Alpha to go with our other fun new curves.  This should be a Movember feature request.   
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract