How to use a Visual Gesture Builder database with Unity3D Plugin?

3.9k views Asked by At

I'm trying to use a .gbd file from Visual Gesture Builder in my Unity3D scene. I have imported both plugins to Unity( the Kinect.2.0.1410.19000.unitypackageand Kinect.VisualGestureBuilder.2.0.1410.19000.unitypackage). The included demos and skeleton data work fine.

When tyring to import my gesture database like this:

using Windows.Kinect;
using Microsoft.Kinect.VisualGestureBuilder;

void Start () 
{
    _Sensor = KinectSensor.GetDefault();
    // compilation error for the following line, see below
    _gestureDatabase = new VisualGestureBuilderDatabase(@"gestures.gbd");
    // check if sensor is there....
    _gestureFrameSource = new VisualGestureBuilderFrameSource(_Sensor, 0);
    _gestureFrameSource.AddGestures(_gestureDatabase.AvailableGestures);
}

Compilation fails:

Microsoft.Kinect.VisualGestureBuilder.VisualGestureBuilderDatabase.VisualGestureBuilderDatabase(System.IntPtr)' is inaccessible due to its protection level'

and

The best overloaded method match for `Microsoft.Kinect.VisualGestureBuilder.VisualGestureBuilderDatabase.VisualGestureBuilderDatabase(System.IntPtr)' has some invalid arguments

What am I missing? Is the Kinect API any different in Unity?

1

There are 1 answers

3
Ramvling On BEST ANSWER

I was running into the same problem. As far as I can tell, you cannot call these constructors directly, but you instead need to call on the static method Create. For example, in your case you would say...

        _gestureDatabase = VisualGestureBuilderDatabase.Create(@"gestures.gbd");
        _gestureFrameSource = VisualGestureBuilderFrameSource.Create(_Sensor,0);

This seems to resolve the issue, at least for me. I'm still running into compilation errors later in the code where I try and retrieve the DiscreteGestureResult, but I'll keep going through the source code looking for answers.