DailyJS

DailyJS

The JavaScript blog.


Tagwebcam
Featured

graphics webcam

Face Tracking, tcomb

Posted on .

JavaScript Face Tracking

Konrad Dzwinel sent in a JavaScript Face Tracking Demo that demonstrates how to use getUserMedia with tracking.js to track your face and add an image based on the position. It also uses gif.js to generate GIFs, and Imgur's API to upload the images.

Konrad made a video about the project with more details about each of the libraries and how you can use them.

tcomb

tcomb (GitHub: gcanti / tcomb, License: MIT, npm: tcomb) by Giulio Canti is a library for making types and combinators. You can use it for validating input or perhaps even lightweight models.

It supports JavaScript primitive type checking, structs, unions, tuples, and subtypes. This is an example of a struct:

var Product = struct({  
  name: Str,                  // a REQUIRED string
  description: maybe(Str),    // an OPTIONAL string (can be `null`)
  homepage: Url,              // a SUBTYPE of string representing an URL
  shippings: list(Shipping),  // a LIST of shipping methods
  category: Category,         // a string in [Audio, Video] (ENUM)
  price: union(Num, Price),   // price expressed in dollars OR in another currency (UNION)
  dim: tuple([Num, Num])      // width x height (TUPLE)
});

The project is tested with Mocha, and the readme and homepage have lots of examples.