npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

faced

v1.2.2

Published

light-weight library for face recognition including features such as eyes, nose and mouth.

Downloads

20

Readme

faced

Build Status

faced is a light-weight library for face recognition including features such as eyes, nose and mouth. It requires opencv.

Face is outlined in black, the eyes are red & green for left and right respectively, the nose is outlined in white and the mouth in blue.

Dependencies

OpenCV

Make sure you have OpenCV v2.4.x installed on your machine.

For MacOS X you can use Homebrew

brew install pkg-config opencv@2
brew link opencv@2 --force

Installation

As a dependency to your project

$ npm install --save faced

Globally

$ npm install -g faced

Identify your first face

var Faced = require('faced');
var faced = new Faced();

faced.detect('image.jpg', function (faces, image, file) {
  if (!faces) {
    return console.log("No faces found!");
  }

  var face = faces[0];

  console.log(
    "Found a face at %d,%d with dimensions %dx%d",
    face.getX(),
    face.getY(),
    face.getWidth(),
    face.getHeight()
  );

  console.log(
    "What a pretty face, it %s a mouth, it %s a nose, it % a left eye and it %s a right eye!",
    face.getMouth() ? "has" : "does not have",
    face.getNose() ? "has" : "does not have",
    face.getEyeLeft() ? "has" : "does not have",
    face.getEyeRight() ? "has" : "does not have"
  );
});

Its that simple! See the program used to generate the above image

API

Faced.detect(source, function, context)

Loads an image from source which can be a file path or a buffer and executes function upon completion.

The callback function expects a prototype like function (faces, image, file) { }, where the first is an array of Face, the second is a Matrix object from opencv and the third is the path of the image.

In case of error the arguments faces and image will be undefined.

Class Feature

  • Feature.getX() Returns the upper left corner X position of the face
  • Feature.getY() Returns the upper left corner Y position of the face
  • Feature.getX2() Returns the lower right corner X position of the face
  • Feature.getY2() Returns the lower right conrner Y position of the face
  • Feature.getWidth() Returns the width
  • Feature.getHeight() Returns the height
  • Feature.intersect(Feature) Returns the percentage of shared spaced that the current feature has with the given argument Feature. Although this is used internally it might be useful for client usage.

Class Face (extends Feature)

All of the following method1s return an instance of Feture or undefined if it could not detect.

  • Face.getMouth()
  • Face.getNose()
  • Face.getEyeLeft()
  • Face.getEyeRight()

Other significant methods

  • Face.getFeature(name) Returns a feature by name. Possible names are: mouth, nose, eyeLeft and eyeRight.
  • Face.getFeatures() Returns an array of Feature that the instance has detected.
  • Face.getFeatureCount() Returns the number of detected features.

Examples

$ node examples/identify.js images/lenna.png

Then open images/lenna.features.png on your favourite image viewer.

Information

License

faced is licensed under the MIT license

Copyright

Copyright (c) 2013, Samuel Gordalina [email protected]