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.unitypackage
and 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?
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.
来源:https://stackoverflow.com/questions/26873523/how-to-use-a-visual-gesture-builder-database-with-unity3d-plugin