Giter Club home page Giter Club logo

facealign's Introduction

FaceAlign

FaceAlign is a tool that can be used to align a set of images containing faces. It is particularly useful for creating "time-lapse" face videos, such as this one : http://youtube.com/watch?v=7SXErQ4eYGU

How it works

FaceAlign is a Python script that uses opencv python bindings, which requires >= Python 2.6. It detects the location of the face in each image (opencv tends to err on the side of over-detection, and this tool will use the largest detected face) and will scale and offset the image so that the centers of the faces in all images will match up. This is based on parameters that can be easily set in config.py.

Usage

Once python and opencv are installed, open config.py and set HCDIR to the folder containing your opencv installation's Haar cascade files.

Run sizeToFace.py. It takes a required input directory parameter, and an optional output directory parameter. The output directory will be created if it does not already exist. By default, images will be output to the current directory. Output file names will be numbered starting with 0001.jpg.

$ python src/sizeToFace.py ../in-images

$ python src/sizeToFace.py ../in-images ../out-images

Eventual plans

  • Brightness/contrast normalization
  • Integration with ffmpeg for automatic video generation
  • A GUI

Common Errors/Solutions

ImportError: No module named cv

Solution: You have not installed OpenCV or the OpenCV Python bindings

Traceback (most recent call last):
 File "<...>/src/facealign/src/FaceImage.py", line 133, in runFaceImage
   fi.cropToFace()
 File "<...>/src/facealign/src/FaceImage.py", line 23, in cropToFace
   face = self._getFaceCoords()
 File "<...>/src/facealign/src/FaceImage.py", line 68, in _getFaceCoords
   cascade = cv.Load(HCPATH)
TypeError: OpenCV returned NULL

Solution: This means you have not set your HCDIR variable correctly. Open src/config.py and set HCDIR to [yourOpenCVDir]/opencv/data/haarcascades/, for example: HCDIR = '/home/doriad/src/OpenCV/opencv/data/haarcascades/'

So what's up?

Feedback, ideas, issue reports, and contributions are invited. Welcomed. Demanded, even. FaceAlign is fairly simple at the moment but I would be interested to hear if you found it useful.

facealign's People

Contributors

roblourens avatar

Watchers

 avatar

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.