GithubHelp home page GithubHelp logo

isabella232 / clmutils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 52ai/clmutils

0.0 0.0 0.0 19 KB

This is a set of utility functions which can be used to decipher CLM Trackr (https://github.com/auduno/clmtrackr) data.

License: MIT License

JavaScript 100.00%

clmutils's Introduction

clmutils

experimental

This is a set of utility functions which can be used to decipher CLM Trackr

Usage

NPM

You can consume these utility functions in the following two ways:

var utils = require('clmutils');

utils.faceOrientation
utils.getFaceSize
utils.textureCapture
utils.forehead
utils.halo

or

var faceOrientation = require('clmutils/faceOrientation');
var getFaceSize = require('clmutils/getFaceSize');
var textureCapture = require('clmutils/textureCapture');
var forehead = require('clmutils/forehead');
var halo = require('clmutils/halo');

Here are examples as to how to use these utility functions:

var faceOrientation = require('clmutils/faceOrientation');
var getFaceSize = require('clmutils/getFaceSize');
var textureCapture = require('clmutils/textureCapture');
var forehead = require('clmutils/forehead');
var halo = require('clmutils/halo');

// clmPositions would be the positions of vertices from clm

// returns aproximated y and z rotations of face in degrees
var rotationDegrees = faceOrientation(clmPositions); 
console.log(rotationDegrees.z); // z rotation of face
console.log(rotationDegrees.y); // y rotation of face

// an object containing 2d width and height of face is returned
var size = getFaceSize(clmPositions);
console.log(size.width); // width of face
console.log(size.height); // height of face

// add 10 points to create an approximate forehead (original array is modified) since the CLM positions do not include one
forehead(clmPositions, 10); 
// create a halo (original array is modified) if you want extra padding around the face
halo(clmPositions); 

// 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
	options.video: null, //an optional video element that was used to generate the CLM points
	options.image: null, //an optional image element that was used to generate the CLM points
	options.forehead: false, //include or exclude the points that make up the forehead
	options.halo: false, //include or exclude the points that make up the halo
};
var uvs = textureCapture(clmPositions, texOptions);

License

MIT, see LICENSE.md for details.

clmutils's People

Contributors

mattdesl avatar mikkoh 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.