Coder Social home page Coder Social logo

kinect-demos's Introduction

A JavaScript library to detect gestures via Kinect (1.8.0) SDK


HOW TO USE


  1. Install the Kinect SDK 1.8.0 drivers and toolkit from Microsoft.

  2. Run the WebServer supplied within the toolkit.

  3. Create a new HTML file in the Content folder of the WebServer folder in the TootlKit folder, E.g. "gestures.html": it will be available at: http://localhost:8181/files/gestures.html according to the WebServer settings.

  4. Add the Kinect SDK 1.8.0 to your HTML

  5. Add the kinect-gestures.js (or the minified version ) to your HTML

  6. Start the sensor:

var sensor = Kinect.sensor(Kinect.DEFAULT_SENSOR_NAME, function(sensorToConfig, isConnected) {
    // pass here your configuration 
    // Notice that the skeleton stream must be enabled
    //sensorToConfig.postConfig(configuration);
});
  1. Initialize the KinectGestures library
KinectGestures.init(sensor,{
	// enable debugging (it will draw the skeleton on a canvas element, see below)
    debug:true, 
    // the ID of the canvas element where the debugger will draw the skeletons'data
    canvasElementID:'canvasElement', 
    // enable registration for players, so you can detect which skeleton belongs to player 1 or 2 (see below)
    registerPlayer:true, 
    // wait n players before enable registering
    numPlayersToRegister:1,
    // enable logging
    log:true, 
    // the ID of the HTML element where the log message will write
    logElementID:'logElement', 
    });
  1. Listen for gestures and players'status events
// weva the right hand
KinectGestures.on(KinectGestures.GestureType.Wave, function(event){
	console.log(event.data);
    // you can use this gesture to register player e.g:
    KinectGestures.PlayerRegister.registerPlayerPosition(event.data.skeleton);
});

// swipe the hand left or right
KinectGestures.on(KinectGestures.GestureType.Swipe, function(event){
	console.log(event.data);
    // event.data.direction = KinectGestures.Direction.Left | KinectGestures.Direction.Right
});

KinectGestures.on(KinectGestures.GestureType.Squat, function(event){
	console.log(event.data);
});

KinectGestures.on(KinectGestures.GestureType.Jump, function(event){
	console.log(event.data);
});

// this needs a player to be registered
KinectGestures.on(KinectGestures.GestureType.SquatPosition, function(event){
	console.log(event.data);
});

// this needs a player to be registered
KinectGestures.on(KinectGestures.GestureType.JumpPosition, function(event){
	console.log(event.data);
});

// this needs a player to be registered
KinectGestures.on(KinectGestures.GestureType.PlayerPosition, function(event){
	console.log(event.data);
});

//////////////////////////
// Player status handlers
//////////////////////////


// a previously tracked skeleton is no more tracked
KinectGestures.on(KinectGestures.EventType.PlayerLost, function(event){
	KinectGestures.log('playerLost!' + JSON.stringify(event.data));
});

// a previously tracked player that was lost, it's engaged again
KinectGestures.on(KinectGestures.EventType.PlayerEngagedAgain, function(event){
	KinectGestures.log('playerEngagedAgain!' + JSON.stringify(event.data));
});

// according to 'numPlayersToRegister' params you passed in the initialization
// this will fire when all the players are being tracked
KinectGestures.on(KinectGestures.EventType.PlayersTracked, function(event){
});

// when you call the KinectGestures.PlayerRegister.registerPlayerPosition(skeletonData), an event of type KinectGestures.EventType.PlayerRegister is dispatched meaning you have registered / engaged your user
// N.B. KinecteGesture consider the player on the left of the Kinect sensor ad player 1, viceversa player 2
KinectGestures.on(KinectGestures.EventType.PlayerRegister, function(event){
	console.log(event.data);
});

DEMO


For a woking example, please see test/app.js demo. You can simpy clone this repo, add the whole folder inside the Content folder of the SDK toolkit. You will access it as [address to Kinect WebServer]/[repo folder]/test/index.html

VERSION


The library is currently in alpha version and it should be considered "experimental", not for using in production environments.

LICENSE


Unlicensed: see more on LICENSE file

CREDITS


Parts of the mathematical methods are ported from a C# version available at https://gesturedetector.codeplex.com/SourceControl/latest#GestureDetector/

Thanks to ThinkingAbout to have supported this project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.