Snapchat -like replace face in the video by a face mask
To play with the script you should have a still image with sample face and video file with someone's else face in it (or you can use your web camera with your own face;) ).
You can find sample still image and video in the "demo" directory.
Final result could be saved to the video file or just shown on the screen.
Original video, no face replaced:
Final video, Arni's face is in place of mine:
This script was tested in the following environment:
Before you begin, download and extract Dlib face shape predictor ('shapepredictor68facelandmarks.dat'). Put it to ./models/shapepredictor68facelandmarks.dat
python ./change-face-in-video.py [-h] STILLFACE VIDEOIN VIDEOOUT
where arguments are:
STILLFACE the full path to jpg file with face VIDEOIN the full path to input video file where face will be changed. If "0" is provided then the web cam will be used VIDEOOUT the full path to output video file with the new face. If "0" is provided then process video will be shown on the screen, but not saved.
For example this command will created a new video
demo_arni.movwith face replacement from image
python ./change-face-in-video.py ./demo/arni.jpg ./demo/demo_orig.mov ./demo/demo_arni.mov
This command will use image
arni.jpgagain, but for the video stream from web camera:
python ./change-face-in-video.py ./demo/arni.jpg 0 ./demo/demo_arni.mov
Alexander Usoltsev, 2016