Step 1 - Load JSHG files.
- Download and unzip the latest version of JSHG.
- Look inside the
jshg
folder to find jquery-1.11.0.min.js
, compatibility.js
, jshg.js
and load all of them. You can replace jquery-1.11.0.min.js
by your own jQuery library (but it must be jQuery v1.6 or later). All the files must be loaded in the following order:
<script src="jshg/jquery-1.11.0.min.js"></script>
<script src="jshg/compatibility.js"></script>
<script src="jshg/jshg.js"></script>
Step 2 - Initialize JSHG
- Define a function to map the gesture returning from JSHG with your expected actions
var actionMapper = function(gesture) {
if (gesture.isLeft)
console.log("Hey, your hand is on the left side");
...
}
More details about the gesture
object can be found at the reference page.
- Optional: add a
div
to display the gesture images.
<div id="gestureShownHere"></div>
- Init JSHG
JSHG.init({
"actionCallback": actionMapper,
"learnDivId": "gestureShownHere",
"gestureDivId": "gestureShownHere",
"settings": {
"cameraWidth": 500,
"cameraHeight": 400,
"gestureDisplayWidth": 100,
"gestureDisplayHeight": 80
},
});
More details about the settings
options can be found at the reference page.
Step 3 - Turn it on
At this time, JSHG is ready to use.
JSHG.run()
// JSHG.stop(); -- for stopping
To improve the accuracy of hand gesture recognition, you may want JSHG to learn the skin color before running. You can easily do that by using the following function instead of
JSHG.run()
JSHG.learnSkinColor()
More details about the API are available at reference page.