Introduction to the Kinect for Windows SDK Development (11) Gesture recognition: basic gesture recognition

Source: Internet
Author: User
Tags visual studio

This paper briefly introduces the basic concept of gesture recognition and the basic method of gesture recognition, and uses the wave in eight gestures as an example to explain how to use the algorithm to identify the gesture, and then continue to introduce how to build a hand tracking class library, and on this basis, The common gestures in the remaining 7 are identified.

1. Basic gesture Tracking

Hand tracking is different in technique and gesture recognition, but it is the same as some of the basic methods used in gesture recognition. Before developing a specific gesture control, we first create a reusable class library for tracking hand movements to facilitate our subsequent development. The Hand Tracking class library contains a visual feedback mechanism with a dynamic cursor display. The interaction between hand tracking and gesture control is highly loosely coupled.

First, create a WPF Control class library project in Visual Studio. Then add four classes: Kinectcursoreventargs.cs,kinectinput.cs,cusroradorner.cs and KinectCursorManager.cs These four classes are used to manage the cursor position based on the location of the user's hand. The Kinectinput class contains events that can be shared between Kinectcursormanager and some controls. Kinectcursoreventargs provides a collection of attributes that can be used to pass data between an event trigger and a listener. The Kinectcursormanager is used to manage the skeleton data stream obtained from the Kinect sensor and then converts it to a WPF coordinate system, providing visual feedback on the conversion to the screen location, and looking for controls on the screen to pass events to those controls. The last CursorAdorner.cs class contains a visual element that represents the icon for the hand.

Kinectcursoreventargs inherits from the RoutedEventArgs class, which contains four properties: X, Y, z, and cursor. X, Y, and Z are decimal numbers that represent the width, height, and depth values of the location of the user's hand to be converted. Cursor is used to store instances of the Cursoradorner class, as discussed later, the following code shows the basic structure of the Kinectcursoreventargs class, which contains some overloaded constructors.

public class Kinectcursoreventargs:routedeventargs
{public
    double X {get; set;}
    Public double Y {get; set;}
    Public double Z {get; set;}
    Public Cursoradorner Cursor {get; set;}
     
    Public Kinectcursoreventargs (double x, double y)
    {
        x = x;
        y = y;
    }
     
    Public Kinectcursoreventargs (Point point)
    {
        X = point. X;
        Y = point. Y;
    }
}

The RoutedEventArgs base class has a constructor that can receive routedevent as a parameter. This is a somewhat special signature, and UIElement in WPF uses this special syntax to trigger events. The following code is the implementation of this signature by the Kinectcursoreventargs class, and some other overloaded methods.

Public Kinectcursoreventargs (routedeventroutedevent): Base (RoutedEvent) {} Publickinectcursoreventargs (RoutedEve Ntroutedevent, DoubleX, Doubley, Doublez): Base (routedevent) {x = x; y = y; z = z; Publickinectcursoreventargs (Routedeventroutedevent, Pointpoint): Base (routedevent) {X = point. X Y = point. Y Publickinectcursoreventargs (Routedeventroutedevent, Pointpoint,doublez): Base (routedevent) {X = point. X Y = point. Y z = z; Publickinectcursoreventargs (Routedeventroutedevent, Objectsource): Base (RoutedEvent, source) {} publ Ickinectcursoreventargs (Routedeventroutedevent,objectsource,doublex,doubley,doublez): Base (routedEvent, source) { x = x; y = y; z = z; Publickinectcursoreventargs (Routedeventroutedevent, Objectsource, pointpoint): Base (RoutedEvent, source) { X = point. X Y = point. Y Publickinectcursoreventargs (Routedeventroutedevent, Objectsource, Pointpoint,doublez): Base (RoutedEvenT, source) {X = point. X Y = point. Y z = z; }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.