Kinect for Windows SDK v2.0 Development Note (15) Gesture frame

Source: Internet
Author: User

??

(reproduced please specify the source)

Using the SDK: Kinect for Windows SDK v2.0 public preview1409

As before, the function/method/interface hyperlink is not attached because the SDK is not complete.


This is the end of the new thing. Is the "gesture frame", just formerly known as the "visual Gesture Builder" (visual Gesture Builder) frame, is

SDK 2.0 comes with a gesture resolution method. Just, suppose you think Microsoft is not writing reliably. Even rubbish. You can try to write one yourself. Author in

Provided in the example. Write a simple look (dozens of lines, don't expect too much).






All right, this visual gesture builder (for short gestures) needs to include the header file
#include <Kinect.VisualGestureBuilder.h>

Need to link to a static library
#pragma comment (lib, "Kinect20.VisualGestureBuilder.lib")

This is optional, you can explicitly dynamically link DLL files: "Kinect20.VisualGestureBuilder.dll", you can also

This file is implicitly dynamic using this library file and requires 2 DLL files in the original SDK for the following Vgbtechs directory.


Use the VS build event to be aware of x64 or x86.


Also, this gesture database is a *.GBD file generated by SDK2.0 's own tool.

This section however explains how to use this file, as to how to use the tool to create files, it should be the next section. Who knows


Perhaps you have seen the SDK's own "Visual Gesture Builder Viewer":

Since the gesture frame is a little bit simpler, let's make it a fake:


0. Support free Form size

Our previous sample has been fixed form size, this time can change the size of the form, need to respond to Wm_size message

in order to easily change the form, we use the d2d1hwndrendertargetin D2D 1.0, due to the Resize method that comes with it.

1. To join the icon, we use the icon that comes with the Kinect SDK

After copying App.ico to project, add a *.rc file in project, right-click, view the code, do not edit, after all, Express Edition cannot be edited.

Write on

1 ICON "App.ico"

1 for the number icon to represent the type "App.ico" for the file name

This compiles, the program will join the icon on its own initiative.


Next add an icon to the program: when you register the form

Wcex.hicon = Loadiconw (HInstance, Makeintresourcew (1));

that 1 is the number that was filled in before the RC file. 'll be

2. Support for form file drag and drop:

Pre-registration can be dragged into the file: dragacceptfiles (M_hwnd, TRUE);

You can then respond to the wm_dropfiles message

3. New Tricks

We used the polling mode based on waiting for vertical synchronization and also used the message-based event pattern. This time we use a timer-based polling mode.

A SetTimer can, the operating system time slice is usually 20ms, so we on the 20ms timer bar, anyway higher than 30FPS;

4. Rendering Strategies

Renders color , depth , and bone frames on the left. Just copy the code from the first few sections.

Visualize the result of the gesture on the right.


In the SDK's own gesture resolution, gestures are divided into two types:

discrete gestures with continuous gestures .

Enum _gesturetype    {        gesturetype_none= 0,        gesturetype_discrete= 1,        gesturetype_continuous= 2    };


Simple process: (PRO, * may need to change dynamically)


Create a gesture frame source (Createvisualgesturebuilderframesource)

* Join gestures (ivisualgesturebuilderframesource::addgesture (s))

* Delete gesture (ivisualgesturebuilderframesource::removegesture)

* Replacement Tracking ID (ivisualgesturebuilderframesource::p ut_trackingid)

Open Reader (ivisualgesturebuilderframesource::openreader)

Poll get gesture frame: (ivisualgesturebuilderframereader::calculateandacquirelatestframe)

Get the corresponding results
Ivisualgesturebuilderframe::get_continuousgestureresult
Ivisualgesturebuilderframe::get_discretegestureresult

Both of these methods are: the first gesture to get a result, and the second is the corresponding result.

From this can be seen:

storing the two gestures separately can reduce the method invocation , but for convenience. There is no classification here;


The gesture results are:

Continuous type: progress (float)

Discrete: Result (Boolean), confidence (float), whether the first frame (Boolean)


So, here's the problem!

Game programming which strong?

How do you get a gesture?

Createvisualgesturebuilderdatabaseinstancefromfile

Createvisualgesturebuilderdatabaseinstancefrommemory

These two are able to get the gesture database,

    Midl_interface ("7fa8e82e-e43e-4dd6-a481-1e967dc4b7c8")    ivisualgesturebuilderdatabase:public IUnknown    { Public    :        Virtual/* [propget] */HRESULT stdmethodcalltype get_availablegesturescount (/             * [annotation][ Out][retval] */             _out_  UINT *numgestures) = 0;                Virtual/* [propget]/HRESULT stdmethodcalltype get_availablegestures (/             * [annotation][in] */             _in_  UINT32 capacity,            /* [annotation][size_is][out] *             /_out_writes_all_ (capacity)  igesture * * Availablegestures) = 0;            };


I don't have to say anything about it.


As for visualization algorithms, this is not the point. Can look at the code to understand, write a bit more chaotic.

It's just this code that I think is well written. we recommend that you look carefully



All right, here's the result map. The color frame is black, and the light is turned off. After all, roommates have slept, and people like me really have a pain in the egg.


Support file drag and drop. Change the size of the form. It's better than Microsoft's own. The one that temporarily replaces Microsoft's pit Daddy:

Close the form on your own computer. But the process has not yet exited. Microsoft, you just hang in there.


Code: Click here, the name is wrong, hit "Face" , please do not care about these details

Kinect for Windows SDK v2.0 Development Note (15) Gesture frame

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.