All Projects → hrastnik → Faceswap

hrastnik / Faceswap

Licence: mit
Real-time FaceSwap application built with OpenCV and dlib

Projects that are alternatives of or similar to Faceswap

Face Swap Android
Realtime Face Swap Android NDK app full source code. Developed with OpenCV (http://opencv.org) and Dlib C++ (http://dlib.net).
Stars: ✭ 111 (-81.83%)
Mutual labels:  opencv, face, dlib, swap
Android Hpe
Android native application to perform head pose estimation using images coming from the front camera.
Stars: ✭ 46 (-92.47%)
Mutual labels:  opencv, face, dlib
Anonymize Video
Replace faces in a video with imaginary persons generated by a progressive GAN deep neural network
Stars: ✭ 15 (-97.55%)
Mutual labels:  opencv, face, dlib
Openpose
OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation
Stars: ✭ 22,892 (+3646.64%)
Mutual labels:  opencv, face, real-time
Facial-Landmark-Detection
Facial Landmark Detection Framework
Stars: ✭ 33 (-94.6%)
Mutual labels:  face, dlib
AverageFaceDemo
Average face on android
Stars: ✭ 31 (-94.93%)
Mutual labels:  face, dlib
Sorting visualization
The Sound of Sorting: Visualize and Audibilize 12 classic sorting algorithms in real time
Stars: ✭ 260 (-57.45%)
Mutual labels:  opencv, real-time
Autocrop
😌 Automatically detects and crops faces from batches of pictures.
Stars: ✭ 320 (-47.63%)
Mutual labels:  opencv, face
Thug Memes
Command line Thug Meme generator written in Python
Stars: ✭ 224 (-63.34%)
Mutual labels:  opencv, dlib
Face Landmark Android
Android AR Camera
Stars: ✭ 320 (-47.63%)
Mutual labels:  opencv, dlib
Facecapture
an Android app kind like Facerig(but simpler)
Stars: ✭ 325 (-46.81%)
Mutual labels:  face, dlib
jeelizPupillometry
Real-time pupillometry in the web browser using a 4K webcam video feed processed by this WebGL/Javascript library. 2 demo experiments are included.
Stars: ✭ 78 (-87.23%)
Mutual labels:  real-time, face
jeelizGlanceTracker
JavaScript/WebGL lib: detect if the user is looking at the screen or not from the webcam video feed. Lightweight and robust to all lighting conditions. Great for play/pause videos if the user is looking or not, or for person detection. Link to live demo.
Stars: ✭ 68 (-88.87%)
Mutual labels:  real-time, face
Realtime object detection
Plug and Play Real-Time Object Detection App with Tensorflow and OpenCV. No Bugs No Worries. Enjoy!
Stars: ✭ 260 (-57.45%)
Mutual labels:  opencv, real-time
Add Christmas Hat
Add Christmas hat on one's head based on OpneCV and Dlib
Stars: ✭ 251 (-58.92%)
Mutual labels:  opencv, dlib
Facemoji
😆 A voice chatbot that can imitate your expression. OpenCV+Dlib+Live2D+Moments Recorder+Turing Robot+Iflytek IAT+Iflytek TTS
Stars: ✭ 320 (-47.63%)
Mutual labels:  opencv, dlib
Libfaceid
libfaceid is a research framework for prototyping of face recognition solutions. It seamlessly integrates multiple detection, recognition and liveness models w/ speech synthesis and speech recognition.
Stars: ✭ 354 (-42.06%)
Mutual labels:  opencv, dlib
Php Opencv Examples
Tutorial for computer vision and machine learning in PHP 7/8 by opencv (installation + examples + documentation)
Stars: ✭ 333 (-45.5%)
Mutual labels:  opencv, face
Fast Face Android
👦 Fast-Face : Android App for Real-time Face Landmark Detection. You can check your landmarks in 60ms
Stars: ✭ 370 (-39.44%)
Mutual labels:  face, dlib
Face recognition py
基于OpenCV的视频人脸识别
Stars: ✭ 215 (-64.81%)
Mutual labels:  opencv, dlib

Youtube video

How to run?

Download OpenCV and dlib

  • Setup OpenCV

    • Run the downloaded OpenCV executable file and select a directory to extract the OpenCV library (for example D:\opencv)
  • Setup dlib

    • Extract the downloaded zip file to a directory (for example D:\dlib)
  • Download and install Visual Studio 2015 or later versions

  • Run Visual Studio

  • Create new empty project and name it something (for example MyProject)

  • Make sure the "Debug" solution configuration is selected

  • In Visual Studio open the Solution Explorer window

  • Right click MyProject and choose Properties

  • Click the "Configuration Manager..." button in the top left corner

  • Setup the configuration for the debug

    • In the active solution platform select x64
    • Close the Configuration Manager window
    • In the property window make sure the selected Configuration in the top left is "Debug" and Platform is "x64"
    • In the panel on the left choose C/C++
    • In the Additional Include Directories field add two directories:
      • "D:\opencv\opencv\build\include"
      • "D:\dlib\dlib-19.2"
      • Note the path might be different if you have different dlib version
    • In the panel on the left choose Linker>General
    • In the Additional Library Directories add "D:\opencv\opencv\build\x64\vc14\lib"
      • Note the path might be different if you have different architecture or VS version
    • In the panel on the left choose Linker>Input
    • In the Additional Dependencies add "opencv_world320d.lib"
    • Click Apply
  • Change the Configuration in the top left to "Release" and repeat

  • Setup the configuration for the release

    • In the panel on the left choose C/C++
    • In the Additional Include Directories field add two directories:
      • "D:\opencv\opencv\build\include"
      • "D:\dlib\dlib-19.2"
      • Note the path might be different if you have different dlib version
    • In the panel on the left choose Linker>General
    • In the Additional Library Directories add "D:\opencv\opencv\build\x64\vc14\lib"
      • Note the path might be different if you have different architecture or VS version
    • In the panel on the left choose Linker>Input
    • In the Additional Dependencies add "opencv_world320.lib"
  • Close the property window

  • Right click Source Files in the Solution Explorer

  • Select "Add Existing Item..." and add the .cpp files from this project

  • Right click Header Files in the Solution Explorer

  • Select "Add Existing Item..." and add the .h files from this project

  • Copy haarcascade_frontalface_default.xml from OpenCV sources/data/haarcascades directory to project directory

  • 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 project directory

After that FaceSwap should work.

Building on GNU/Linux

If you want to run this on Ubuntu 16.04 run this set of commands:

sudo apt install libopencv-dev liblapack-dev libdlib-dev
wget http://sourceforge.net/projects/dclib/files/dlib/v18.10/shape_predictor_68_face_landmarks.dat.bz2
bunzip2 *.bz2
ln -s /usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml .

g++ -std=c++1y *.cpp $(pkg-config --libs opencv lapack) -ldlib 
./a.out

Special thanks to https://github.com/nqzero for providing the build commands.

Building on MacOS

Special thanks to https://github.com/shaunharker for providing the build commands.

brew install lapack
brew install openblas
brew install opencv
brew install dlib --with-openblas
git clone https://github.com/hrastnik/FaceSwap.git
cd FaceSwap
wget http://sourceforge.net/projects/dclib/files/dlib/v18.10/shape_predictor_68_face_landmarks.dat.bz2
bunzip2 *.bz2
ln -s /usr/local/share/opencv/haarcascades/haarcascade_frontalface_default.xml .
export PKG_CONFIG_PATH=/usr/local/opt/lapack/lib/pkgconfig:/usr/local/opt/openblas/lib/pkgconfig:$PKG_CONFIG_PATH
g++ -std=c++1y *.cpp $(pkg-config --libs opencv lapack openblas) -ldlib
mkdir bin
mv a.out bin
cd bin
./a.out

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].