Skip to content

Using OpenCV and dlib to swap the faces of two people

Notifications You must be signed in to change notification settings

guipleite/CV2-Face-Swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Single image face swap using dlib and OpenCV

Writen by:

  • Eli Ghosn
  • Guilherme Leite
  • Rafael Rosenzvaig

Professor Luciano Silva

Insper - Computer Vision - 2020.2


The code presents an implementation for face swapping, between two different images, using two well-known computer vision python libraries: dlib and OpenCV.

Implementation summary:

  1. Load 2 images that contain a human face on it
  2. Load pre-trained feature detection model
  3. Apply model on images to retrieve features coordinates
  4. Define facial area of interest using previously retrieved coordinates
  5. Split facial area of interest into tringles
  6. Cut facial region from both images and apply mask to remove the body from one image and the face from the other
  7. Warp masked face image to allign with masked body image
  8. Smooth edges to blend face into new body
  9. Retrieve final image

About

Using OpenCV and dlib to swap the faces of two people

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published