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; } }
internal static extern GestureFailure StartGestureDetection([In, Out] GestureOption option);
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; }
// start detection with given option, change state for status and error as return value public abstract IEnumerator StartDetection(GestureOption option);