Coder Social home page Coder Social logo

face-morphing's Introduction

Face Morphing

This is a tool which creates a morphing effect. It takes two facial images as input and returns a video morphing from the first image to the second.


Usage

Clone this repository and run setup.py and requirements.txt. Also install below mentioned dependencies. Then pass the following command-line arguments to __init__.py in morphing folder.

python3 __init__.py face/body path_to_first_image path_to_second_image duration_of_video frame_rate path_where_video_is_to_be_saved
  • Note that presently only face is allowed as first argument.
  • Also instead of the path to image file, Python File Object of that image can also be passed in as an argument.

Examples

A photo of Ben Affleck A phtot of Morgan Freeman Using the below command you can generate a video depicting morphing.

python3 __init__.py face ben.jpg morgan.jpg 5 25 morphing-example.mp4

Morphed Video

How It Works

  1. Find point-to-point correspondences between the two images using Dlib's Facial Landmark Detection.
  2. Find the Delaunay Triangulation for the average of these points.
  3. Using these corresponding triangles in both initial and final images, perform Warping and Alpha Blending and obtain intermediate images to be used in creating videos.
  4. Use ffmpeg to return a video from above created frames.

Requirements

These are the requirements apart from what is mentioned in requirements.txt :

  • FFMPEG
  • X11 (Xquartz on macOS)
  • Boost and Boost-Python
  • Dlib

For macOS : https://www.learnopencv.com/install-dlib-on-macos/
For Linux : https://www.learnopencv.com/install-dlib-on-ubuntu/
For Windows : https://www.learnopencv.com/install-opencv-3-and-dlib-on-windows-python-only/

Citations

Most of the help for this project came from this post http://www.learnopencv.com/face-morph-using-opencv-cpp-python/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.