wavelets / FaceSwap

Real-time FaceSwap application built with OpenCV and dlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to run?

OpenCV and dlib are required. If you're on Linux you should remove the first line from main.cpp

#include <dlib/all/source.cpp>

After that it should compile and run.

Copy haarcascade_frontalface_default.xml from OpenCV sources/data/haarcascades folder. Download shape_predictor_68_face_landmarks.dat from http://sourceforge.net/projects/dclib/files/dlib/v18.10/shape_predictor_68_face_landmarks.dat.bz2 and place in correct folder.

After that FaceSwap should work.

How does it work?

The algorithm searches until it finds two faces in the frame. Then it estimates facial landmarks using dlib face landmarks. Facial landmarks are used to "cut" the faces out of the frame and to estimate the transformation matrix used to move one face over the other.

The faces are then color corrected using histogram matching and in the end the edges of the faces are feathered and blended in the original frame.

Result

Before...

Before

After...

After

About

Real-time FaceSwap application built with OpenCV and dlib

License:MIT License


Languages

Language:C++ 100.0%