clmutils
This is a set of utility functions which can be used to decipher CLM Trackr
Usage
You can consume these utility functions in the following two ways:
var utils = ; utilsfaceOrientationutilsgetFaceSizeutilstextureCaptureutilsforeheadutilshalo
or
var faceOrientation = ;var getFaceSize = ;var textureCapture = ;var forehead = ;var halo = ;
Here are examples as to how to use these utility functions:
var faceOrientation = ;var getFaceSize = ;var textureCapture = ;var forehead = ;var halo = ; // clmPositions would be the positions of vertices from clm // returns aproximated y and z rotations of face in degreesvar rotationDegrees = ; console; // z rotation of faceconsole; // y rotation of face // an object containing 2d width and height of face is returnedvar size = ;console; // width of faceconsole; // height of face // add 10 points to create an approximate forehead (original array is modified) since the CLM positions do not include one; // create a halo (original array is modified) if you want extra padding around the face; // textureCapture returns UV coordinates based on the clmPositions and can optionally extract a texture from the image or video element onto a canvas2d context.var texOptions = outContext: null //an optional canvas2d context if you want a texture rendered from options.image or options.video optionsvideo: null //an optional video element that was used to generate the CLM points optionsimage: null //an optional image element that was used to generate the CLM points optionsforehead: false //include or exclude the points that make up the forehead optionshalo: false //include or exclude the points that make up the halo;var uvs = ;
License
MIT, see LICENSE.md for details.