An open API service indexing awesome lists of open source software.

https://github.com/lessthanzero/workshop-demo-1

Face tracker for BHSAD workshop
https://github.com/lessthanzero/workshop-demo-1

Last synced: about 1 year ago
JSON representation

Face tracker for BHSAD workshop

Awesome Lists containing this project

README

          

clmtrackr
======

![tracked face](http://auduno.github.com/clmtrackr/media/clmtrackr_03.jpg)

**clmtrackr** is a javascript library for fitting facial models to faces in videos or images. It currently is an implementation of *constrained local models* fitted by *regularized landmark mean-shift*, as described in [Jason M. Saragih's paper](http://dl.acm.org/citation.cfm?id=1938021). **clmtrackr** tracks a face and outputs the coordinate positions of the face model as an array, following the numbering of the model below:

[![facemodel_numbering](http://auduno.github.com/clmtrackr/media/facemodel_numbering_new_small.png)](http://auduno.github.com/clmtrackr/media/facemodel_numbering_new.png)

[Reference](http://auduno.github.io/clmtrackr/docs/reference.html) - [Overview](http://auduno.tumblr.com/post/61888277175/fitting-faces)

The library provides some generic face models that were trained on [the MUCT database](http://www.milbo.org/muct/) and some additional self-annotated images. Check out [clmtools](https://github.com/auduno/clmtools) for building your own models.

The library requires [jsfeat.js](https://github.com/inspirit/jsfeat) (for initial face detection) and [numeric.js](http://numericjs.com) (for matrix math).

For tracking in video, it is recommended to use a browser with WebGL support, though the library should work on any modern browser.

For some more information about Constrained Local Models, take a look at Xiaoguang Yan's [excellent tutorial](https://sites.google.com/site/xgyanhome/home/projects/clm-implementation/ConstrainedLocalModel-tutorial%2Cv0.7.pdf?attredirects=0), which was of great help in implementing this library.

### Examples ###

* [Tracking in image](http://auduno.github.io/clmtrackr/clm_image.html)
* [Tracking in video](http://auduno.github.io/clmtrackr/clm_video.html)
* [Face substitution](http://auduno.github.io/clmtrackr/examples/facesubstitution.html)
* [Face masking](http://auduno.github.io/clmtrackr/face_mask.html)
* [Realtime face deformation](http://auduno.github.io/clmtrackr/examples/facedeform.html)
* [Emotion detection](http://auduno.github.io/clmtrackr/examples/clm_emotiondetection.html)
* [Caricature](http://auduno.github.io/clmtrackr/examples/caricature.html)

### Usage ###

Download the minified library [clmtrackr.js](https://github.com/auduno/clmtrackr/raw/dev/clmtrackr.js) and one of the models, and include them in your webpage. **clmtrackr** depends on [*numeric.js*](https://github.com/sloisel/numeric/) and [*jsfeat.js*](https://github.com/inspirit/jsfeat), but these are included in the minified library.

```html
/* clmtrackr libraries */

```

The following code initiates the clmtrackr with the model we included, and starts the tracker running on a video element.

```html

var videoInput = document.getElementById('inputVideo');

var ctracker = new clm.tracker();
ctracker.init(pModel);
ctracker.start(videoInput);

```

You can now get the positions of the tracked facial features as an array via ```getCurrentPosition()```:

```html

function positionLoop() {
requestAnimationFrame(positionLoop);
var positions = ctracker.getCurrentPosition();
// positions = [[x_0, y_0], [x_1,y_1], ... ]
// do something with the positions ...
}
positionLoop();

```

You can also use the built in function ```draw()``` to draw the tracked facial model on a canvas :

```html

var canvasInput = document.getElementById('canvas');
var cc = canvasInput.getContext('2d');
function drawLoop() {
requestAnimationFrame(drawLoop);
cc.clearRect(0, 0, canvasInput.width, canvasInput.height);
ctracker.draw(canvasInput);
}
drawLoop();

```

See the complete example [here](http://auduno.github.com/clmtrackr/example.html).

### License ###

**clmtrackr** is distributed under the [MIT License](http://www.opensource.org/licenses/MIT)