示例#1
0
        public override IEnumerator StartDetection(GestureOption option)
        {
#if VIVEHANDTRACKING_WITH_WAVEVR && !UNITY_EDITOR
            // retry at most 5 times if camera is not ready
            int count = 5;
#else
            int count = 1;
#endif
            while (count > 0)
            {
                State.Error = GestureInterface.StartGestureDetection(option);
                if (State.Error == GestureFailure.Camera && count > 1)
                {
                    Debug.LogError("Start camera failed, retrying...");
                    yield return(new WaitForSeconds(0.5f));

                    count--;
                    continue;
                }
                else if (State.Error != GestureFailure.None)
                {
                    Debug.LogError("Start gesture detection failed: " + State.Error);
                    State.Status = GestureStatus.Error;
                }
                else
                {
                    State.Mode   = option.mode;
                    State.Status = GestureStatus.Starting;
                }
                break;
            }
        }
示例#2
0
 internal static extern GestureFailure StartGestureDetection([In, Out] GestureOption option);
示例#3
0
        public override IEnumerator StartDetection(GestureOption option)
        {
            if (State.Status == GestureStatus.Starting || State.Status == GestureStatus.Running)
            {
                yield break;
            }

            var gestureStatus = WaveVR_GestureManager.Instance.GetHandGestureStatus();

            if (gestureStatus == WaveVR_Utils.HandGestureStatus.UNSUPPORT)
            {
                Debug.LogError("WaveVR gesture not supported");
                State.Status = GestureStatus.Error;
                yield break;
            }
            var trackingStatus = WaveVR_GestureManager.Instance.GetHandTrackingStatus();

            if (trackingStatus == WaveVR_Utils.HandTrackingStatus.UNSUPPORT)
            {
                Debug.LogError("WaveVR tracking not supported");
                State.Status = GestureStatus.Error;
                yield break;
            }

            WaveVR_GestureManager.Instance.EnableHandGesture  = true;
            WaveVR_GestureManager.Instance.EnableHandTracking = true;
            State.Mode = GestureMode.Skeleton;

            while (true)
            {
                yield return(null);

                gestureStatus = WaveVR_GestureManager.Instance.GetHandGestureStatus();
                if (gestureStatus == WaveVR_Utils.HandGestureStatus.NOT_START ||
                    gestureStatus == WaveVR_Utils.HandGestureStatus.STARTING)
                {
                    continue;
                }
                trackingStatus = WaveVR_GestureManager.Instance.GetHandTrackingStatus();
                if (trackingStatus == WaveVR_Utils.HandTrackingStatus.NOT_START ||
                    trackingStatus == WaveVR_Utils.HandTrackingStatus.STARTING)
                {
                    continue;
                }
                break;
            }

            if (gestureStatus != WaveVR_Utils.HandGestureStatus.AVAILABLE)
            {
                Debug.LogError("WaveVR gesture start failed: " + gestureStatus);
                State.Status = GestureStatus.Error;
                WaveVR_GestureManager.Instance.EnableHandGesture  = false;
                WaveVR_GestureManager.Instance.EnableHandTracking = false;
                yield break;
            }
            if (trackingStatus != WaveVR_Utils.HandTrackingStatus.AVAILABLE)
            {
                Debug.LogError("WaveVR tracking start failed: " + trackingStatus);
                State.Status = GestureStatus.Error;
                WaveVR_GestureManager.Instance.EnableHandGesture  = false;
                WaveVR_GestureManager.Instance.EnableHandTracking = false;
                yield break;
            }
            State.Status = GestureStatus.Running;
        }
示例#4
0
 // start detection with given option, change state for status and error as return value
 public abstract IEnumerator StartDetection(GestureOption option);