Introduction

Introducing JSHG

Javascript Hand Gesture Plugin (JSHG) is a wonderful plugin that allows you to support the hand gesture recognition of users through web camera in your existing websites or web applications. You do not need to have any background in computer vision to use this plugin. It currently offers the basic set of hand gestures which include the position of hand (left, right, up, down) and counts the number of fingers. We provides a well-designed API for you to integrate JSHG to your application easily. If you have strong background in computer vision, it is very simple for you to customize JSHG according to your preference.

How it works

How it works

  1. JSHG plugin reads the video stream from the webcam.
  2. It uses computer vision to track user's hand.

    Red dot is the position of hand.
    Yellow dots are the positions of fingers.

    The screen is divided into 9 areas.
    On the left picture, the hand is in "DOWN" position.
  3. The main application which integrates JSHG plugin in is provided that hand information to map with their corresponding actions.

How To Integrate

How To Integrate

Step 1 - Load JSHG files.

  1. Download and unzip the latest version of JSHG.
  2. 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

  1. Define a function to map the gesture returning from JSHG with your expected actions
  2. 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.
  3. Optional: add a div to display the gesture images.
  4. <div id="gestureShownHere"></div>
  5. Init JSHG
  6. 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.

Examples

Example 1 - HTML5Slides

In this example, we integrate JSHG with Google HTML5 slide template. This allows you to create a wonderful presentation by controlling the slides by your hand gestures via webcam. Two basic gestures are used: moving hand to the right moves the slide forward and moving hand to the left moves it backward.

The integrated code is simple as the following:
var currentGesture = null;
var finishLearning = function() {
    $("#startInstruction").show();
}
var actionMapper = function(gesture) {
    if (currentGesture != null && currentGesture.isSameRelativePos(gesture)) return;
    if (gesture.isLeft) {
        nextSlide();
    } else if (gesture.isRight) {
        prevSlide();
    };
    currentGesture = gesture;
}
JSHG.init({
    "actionCallback": actionMapper, 
    "learnCallback": finishLearning,
    "learnDivId": "learningShownHere",
    "gestureDivId": "gestureShownHere",
    "settings": {
        "learningCountDown_": 10, 
        "cameraWidth": 500, 
        "cameraHeight": 400, 
        "gestureDisplayWidth": 100, 
        "gestureDisplayHeight": 80
    },
});

Example 2 - Google Earth

Google Earth

Google Earth lets you fly anywhere on Earth and it is more interesting if you can fly by your hand. We integrate JSHG with Google Earth API, so you can do that. Try it now and enjoy your journey :)