Usage

Please complete steps in the Setup section before building your application.

Start the detection

Call GestureInterface.Start function to start gesture detection. This function is non-blocking, detection will be started in a background thread.

The function accepts a GestureOption parameter, which can be used to change GestureBackend and GestureMode. Since modes are not supported on all devices, the option is modified to return what mode is selected in current detection.

The return value of the function indicates if any error occured during the start.

Calling this function when detection is already started is an no-op. The return value is always GestureFailure.None, option is modified to return current running mode.

Note

Make sure to accquire camera permission before staring detection.

Polling Detection Result

Since detection is running in a background thread, the caller need to poll detection result periodically. We suggest to poll results in higher frequency than detection speed based on platform and modes.

Polling detection can be done with the GestureInterface.UpdateResult function. The function is blocking until latest results is copied to GestureInterface class. The results can be read using the functions described in the next section.

GestureInterface.GetFrameIndex function can be used to check gesture detection status or as a hint on polling the results:

  • If the index value is 0, this means detection is starting, no results are ready yet.
  • If the index value has increased, new gesture results are updated.
  • If the index value does not change, this means new gesture results are not ready yet, results remains same as the ones before you poll.
  • If the index is negative, this means detection has stopped due to error occurs. You should stop polling and restart detection.

Note

Detection results do not change until you poll latest detection result again.

Using Detection Result

Use GestureInterface.GetLeft and GestureInterface.GetRight function for left/right hand detection result. The returned hand results are GestureResult class which contains gesture type and position information.

Before using gesture type and position, you should first check if left/right hand is visible in the camera. This can be doen use GestureResult.valid field. Gesture type and position are only meaningful when the hand is valid.

Note

The points are returned in Unity3D coordinate system, i.e. +x is right, +y is up, +z is forward, unit is meter. You may need to convert your coordinate system before use.

Stop the detection

Call GestureInterface.Stop function to stop gesture detection. This function is blocking, it returns after the detection is stopped. Calling this function when detection is not started is an no-op.