Ejemplo n.º 1
0
        /// <summary>
        /// Start tracking hands with all key poses disabled.
        /// </summary>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful.
        /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed to initialize the native hand tracker.
        /// </returns>
        protected override MLResult.Code StartAPI()
        {
            this.left  = new Hand(MLHandTracking.HandType.Left);
            this.right = new Hand(MLHandTracking.HandType.Right);

            // Initialize KeyPoseManager, to register the gesture subsystem.
            this.keyposeManager = new KeyposeManager(Left, Right);

            try
            {
                // Attempt to start the tracker & validate.
                NativeBindings.SetHandGesturesEnabled(true);
                if (!NativeBindings.IsHandGesturesEnabled())
                {
                    MLPluginLog.Error("MLHandTracking.StartAPI failed to initialize the native hand tracker.");
                    return(MLResult.Code.UnspecifiedFailure);
                }
            }
            catch (EntryPointNotFoundException)
            {
                MLPluginLog.Error("MLHandTracking.StartAPI failed. Reason: API symbols not found.");
                return(MLResult.Code.UnspecifiedFailure);
            }

            return(MLResult.Code.Ok);
        }