Message Boards Message Boards

GROUPS:

Masking faces in a webcam stream

Posted 9 years ago
8550 Views
|
1 Reply
|
10 Total Likes
|
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 /@ {
    "http://i.imgur.com/155BjOY.png",
    "http://i.imgur.com/zq3Qsm6.png",
    "http://i.imgur.com/kONG87s.png",
    "http://i.imgur.com/WaQkDsn.png",
    "http://i.imgur.com/JZqCWEN.png",
    "http://i.imgur.com/9Y5CcUQ.png",
    "http://i.imgur.com/5CiN4Af.png"
    }

Now execute this code and bring a few friends to smile into camera:
 Manipulate[
  i = CurrentImage[];
  Show[i, Graphics[
    MapThread[
     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 9 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
Attachments
Remove
or Discard

Group Abstract Group Abstract