presencejs icon indicating copy to clipboard operation
presencejs copied to clipboard

A JavaScript library that uses HTML5 controllers to detect whether someone is in front of the computer.

PresenceJS

A JavaScript library that uses HTML5 controllers to detect whether someone is in front of the computer.

AMD, Node and browser ready

Dependencies:

Requires Resemble.js image analysis library

Development

Issue npm install && bower install to resolve dependencies.

Use grunt build to build minified version.

Demo

You can find a demo here

Installation

Install Presence using Bower

$ bower install presencejs --save

or manually include dependencies and source:

<script src="../bower_components/resemblejs/resemble.js"></script>
<script src="presence.js"></script>

and then configure Presence:

<script>
    Presence.showSnapshots = true; //show frames elaboration snapshots
    Presence.dropElement = document.getElementById("dropper"); //set snapshots container
    Presence.canvas = document.getElementById("canvas"); //set canvas
    Presence.video = document.getElementById("video"); //set video
    
    /* override default event handlers */
    Presence.onEnter = function(data) {
        console.log("Welocome!")
    }
    Presence.onLeave = function(data) {
        console.log("Goodbye")
    }
    Presence.isPresent = function(data) {
        document.getElementById("present").style.display = "block";
        document.getElementById("notPresent").style.display = "none";
        document.getElementById("stats").innerHTML = "Difference: " + data.mismatch + "% Red: " + data.red + "% Blue:" + data.blue + "% Green:" + data.green + " Brightness: " + data.brightness + "%";

    }
    Presence.isNotPresent = function(data) {
        document.getElementById("notPresent").style.display = "block";
        document.getElementById("present").style.display = "none";
        document.getElementById("stats").innerHTML = "";
    }
</script>

Coding guidelines

Follow github guidelines

Authors

Project created and released by

  • Marco Gagliardi
  • Massimiliano Sartoretto (Twitter)
Feedback

Use the issue tracker for bugs. Mail or Tweet us for any idea that can improve the project.

License

Released under The MIT License.