GithubHelp home page GithubHelp logo

jonas8 / fizbin.kinect.gestures Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nwpappas/fizbin.kinect.gestures

0.0 1.0 0.0 251 KB

Home Page: http://www.exceptontuesdays.com

License: Microsoft Public License

C# 100.00%

fizbin.kinect.gestures's Introduction

Except on Tuesdays (Fizbin) Kinect Gesture Library

http://www.exceptontuesdays.com/

##Fizbin.Kinect.Gestures.Demo Included in the repository is a simple demo application which shows how to easily set up a Kinect enabled application to recognize gestures.

###Requirements The gesture demo takes advantage of helper classes included in the Developer Toolkit, which can be downloaded from the Microsoft Kinect for Windows homepage.

  • Microsoft.Kinect.Toolkit – Used to reference to KinectSensorChooser component, for automatically finding and handling updates to the Kinect sensor.
  • Microsoft.Samples.Kinect.WpfViewers – Used to reference the KinectSensorManager data model class.

The packages should be placed in the same directory as the Fizbin.Kinect.Gestures solution.

Both packages can be installed to your computer from the "Developer Toolkit Browser" by installing the "Microsoft.Kinect.Toolkit" and "Kinect Explorer".

##Fizbin.Kinect.Gestures

###Executing on Gestures

In order to capture and execute on a gesture we initialize the gesture recognizer’s callback function in InitializeKinectServices():

gestureController = new GestureController();
gestureController.GestureRecognized += OnGestureRecognized;

After the GestureController is initialized you can register new gestures with it. A gesture is made up of one or more IRelativeGestureSegments, which are passed to the AddGesture function of the GestureController along with a string which can be used for identifying the gesture when the GestureRecognized event is fired.

IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3];
swipeleftSegments[0] = new SwipeLeftSegment1();
swipeleftSegments[1] = new SwipeLeftSegment2();
swipeleftSegments[2] = new SwipeLeftSegment3();
gestureController.AddGesture("SwipeLeft", swipeleftSegments);

The gesture recognizer analyzes data from the skeleton. Each time we receive a new skeleton frame we send it off to the gesture recognizer for review:

private void OnSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
        using (SkeletonFrame frame = e.OpenSkeletonFrame())
        {
                if (frame == null)
                        return;

                // resize the skeletons array if needed
                if (skeletons.Length != frame.SkeletonArrayLength)
                        skeletons = new Skeleton[frame.SkeletonArrayLength];

                // get the skeleton data
                frame.CopySkeletonDataTo(skeletons);

                foreach (var skeleton in skeletons)
                {
                        // skip the skeleton if it is not being tracked
                        if (skeleton.TrackingState != SkeletonTrackingState.Tracked)
                                continue;

                        // update the gesture controller
                        gestureController.UpdateAllGestures(skeleton);
                }
        }
}

If a gesture is recognized an event will be fired. We go to our event callback and execute on the type of gesture returned:

private void OnGestureRecognized(object sender, GestureEventArgs e)
{
        switch (e.GestureName)
        {
                case "Menu":
                        Gesture = "Menu";
                        break;
                case "WaveRight":
                        Gesture = "Wave Right";
                        break;
                case "WaveLeft":
                        Gesture = "Wave Left";
                        break;
                case "JoinedHands":
                        Gesture = "Joined Hands";
                        break;
                case "SwipeLeft":
                        Gesture = "Swipe Left";
                        break;
                case "SwipeRight":
                        Gesture = "Swipe Right";
                        break;
                case "ZoomIn":
                        Gesture = "Zoom In";
                        break;
                case "ZoomOut":
                        Gesture = "Zoom Out";
                        break;

                default:
                        break;
        }
}

That is all that is required. Update any Kinect enabled application with the above lines, in addition to including the gesture library project, and you can execute on basic gestures!

fizbin.kinect.gestures's People

Contributors

cehberlin avatar nwpappas avatar

Watchers

 avatar

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.