A JavaScript library that uses HTML5 controllers to detect whether someone is in front of the computer.
AMD, Node and browser ready
Requires Resemble.js image analysis library
Issue npm install && bower install
to resolve dependencies.
Use grunt build
to build minified version.
You can find a demo here
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>
Follow github guidelines
Project created and released by
Use the issue tracker for bugs. Mail or Tweet us for any idea that can improve the project.
Released under The MIT License.