private void Update() { MLHand hand = (handType == MLHandType.Left) ? MLHands.Left : MLHands.Right; // Hand Wrist if (hand.IsVisible && hand.Wrist.KeyPoints.Count > 0) { // To get the direction of the hand, get multiple keypoints and calculate the direction var handPos = hand.Wrist.KeyPoints[0].Position; transform.position = handPos; } else if (hand.IsVisible) { Debug.Log("KeyPoints: " + hand.Wrist.KeyPoints.Count); } // Gesture Detection if (GetGesture(hand, handPoses[0])) { renderer.material.color = Color.red; } else { renderer.material.color = Color.white; } }
private void OnGestureStay(MLHand hand) { if (GestureManager.Matches(hand, _leftTypes, _rightTypes)) { DrawKeypoints(hand); } }
//----------- Private Methods ----------- private void HandleOnGestureBegin(MLHand hand) { if (GestureManager.Matches(hand, _placementRequestHandPoses)) { RequestPlacement(); } }
public void StartInflatingBubble(MLHand hand) { Debug.Log("Started inflating with hand: " + (hand.Equals(MLHands.Left) ? "left" : "right")); Inflating = true; Holding = true; _inflatingHand = hand; }
//----------- Event Handlers ----------- private void OnGestureBegin(MLHand hand) { if (GestureManager.Matches(hand, _leftTypes, _rightTypes)) { EnableContent(hand, true); } }
/// <summary> /// Update the positions of the keypoints to the latest data from the /// ML device. /// </summary> /// <param name="keypoints">The array of transforms to set.</param> /// <param name="hand">The hand to poll for the keypoint information.</param> private void UpdateKeypointObjects(Transform[] keypoints, MLHand hand) { keypoints[0].position = hand.KeyPoints[0]; keypoints[1].position = hand.KeyPoints[1]; keypoints[2].position = hand.Center; keypoints[0].gameObject.SetActive(true); if (Vector3.Distance(keypoints[0].position, keypoints[1].position) < KEYPOINT_PROXIMITY_DISTANCE_THRESHOLD) { keypoints[1].gameObject.SetActive(false); } else { keypoints[1].gameObject.SetActive(true); } if (Vector3.Distance(keypoints[0].position, keypoints[2].position) < KEYPOINT_PROXIMITY_DISTANCE_THRESHOLD || Vector3.Distance(keypoints[1].position, keypoints[2].position) < KEYPOINT_PROXIMITY_DISTANCE_THRESHOLD) { keypoints[2].gameObject.SetActive(false); } else { keypoints[2].gameObject.SetActive(true); } }
/// <summary> /// Get the confidence value for the hand being tracked. /// </summary> /// <param name="hand">Hand to check the confidence value on. </param> /// <param name="handKeyPose">Which hand pose to check against. </param> /// <returns></returns> private bool GetKeyPoseConfidence(MLHand leftHand, MLHand rightHand, MLHandKeyPose handKeyPose) { float confidenceLeft = _trackLeftHand ? GetKeyPoseConfidence(leftHand, handKeyPose) : 0.0f; float confidenceRight = _trackRightHand ? GetKeyPoseConfidence(rightHand, handKeyPose) : 0.0f; float confidenceValue = Mathf.Max(confidenceLeft, confidenceRight); return(confidenceValue > 0.0f); }
public HandData(MLHand hand, GameObject parent, string name, Color color) { this.hand = hand; this.handGO = new GameObject(name); this.handGO.transform.SetParent(parent.transform); this.color = color; keyPoints = new List <GameObject>(); }
//Constructors: public ManagedHand(MLHand hand, HandInput handInput) { _handInput = handInput; Hand = hand; Skeleton = new ManagedHandSkeleton(this); Gesture = new ManagedHandGesture(this); Collider = new ManagedHandCollider(this); }
//position the game object to the tracked finger void positionHand(MLHand hand) { //in Lumin SDK 0.13 only the center hand position //updates so we need to use that until it's fixed finger.position = hand.Center; //set the finger position to the tip of the finger //finger.position = hand[1].position; }
//----------- Private Methods ----------- private void EnableContent(MLHand hand, bool enabled) { List <GameObject> indicators = GetIndicators(hand); foreach (GameObject indicator in indicators) { indicator.SetActive(enabled); } }
public static bool GetGesture(MLHand _hand, MLHandKeyPose _type) { if (_hand != null && _hand.KeyPose == _type) { return(true); } return(false); }
/// <summary> /// Get the device confidence value for the passed in gesture and hand. /// </summary> /// <param name="type">The specific gesture to check.</param> public float GetGestureConfidence(MLHand hand, MLStaticGestureType type) { if (hand != null) { if (hand.StaticGesture == type) { return(hand.GestureConfidence); } } return(0.0f); }
public void PopInflatingBubble(MLHand hand) { Debug.Log("Popping inflating bubble with hand: " + (hand.Equals(MLHands.Left) ? "left" : "right")); Inflating = false; if (hand == _inflatingHand && _inflatingBubble != null) { _inflatingBubble.Pop(); _inflatingBubble = null; _inflatingHand = null; } }
/// <summary> /// Get the confidence value for the hand being tracked. /// </summary> /// <param name="hand">Hand to check the confidence value on. </param> /// <param name="handKeyPose">Which hand pose to check against. </param> /// <returns></returns> private float GetKeyPoseConfidence(MLHand hand, MLHandKeyPose handKeyPose) { if (hand != null) { if (hand.KeyPose == handKeyPose) { return(hand.KeyPoseConfidence); } } return(0.0f); }
private MLHandKeyPose KeyPose(MLHand hand) { if (hand != null) { if (hand.KeyPoseConfidence > 0.75) { return(hand.KeyPose); } } return(MLHandKeyPose.NoPose); }
/// <summary> /// Get the confidence value for the gesture being tracked on the input hand. /// </summary> /// <param name="hand"> Hand to check the confidence value on. </param> /// <returns></returns> private float GetGestureConfidence(MLHand hand) { if (hand != null) { if (hand.StaticGesture == _gestureToTrack) { return(hand.GestureConfidence); } } return(0.0f); }
/// <summary> /// Get the confidence value for the hand being tracked. /// </summary> /// <remarks> /// Copied from Key Pose Visualiser class /// </remarks> /// <param name="hand">Hand to check the confidence value on. </param> /// <returns></returns> private float GetKeyPoseConfidenceFist(MLHand hand) { if (hand != null) { if (hand.KeyPose == MLHandKeyPose.Fist) { return(hand.KeyPoseConfidence); } } return(0.0f); }
/// <summary> /// Get the confidence value for the hand being tracked. /// </summary> /// <param name="hand">Hand to check the confidence value on. </param> /// <returns></returns> private float GetKeyPoseConfidence(MLHand hand) { if (hand != null) { if (hand.KeyPose == _keyPoseToTrack) { return(hand.KeyPoseConfidence); } } return(0.0f); }
public static bool Matches(MLHand hand, KeyPoseTypes _leftTypes, KeyPoseTypes _rightTypes) { if (hand.HandType == MLHandType.Left) { return(Matches(hand, _leftTypes)); } else { return(Matches(hand, _rightTypes)); } }
private List <MLKeyPoint> GetKeypoints(MLHand hand) { List <MLKeyPoint> keypoints = new List <MLKeyPoint>(); keypoints.AddRange(hand.Wrist.KeyPoints); keypoints.AddRange(hand.Thumb.KeyPoints); keypoints.AddRange(hand.Index.KeyPoints); keypoints.AddRange(hand.Middle.KeyPoints); keypoints.AddRange(hand.Ring.KeyPoints); keypoints.AddRange(hand.Pinky.KeyPoints); return(keypoints); }
protected void UpdateHand(MLHand mlHand, Handedness handedness) { if (mlHand.IsVisible) { var hand = GetOrAddHand(handedness); hand.UpdateController(mlHand); } else { RemoveHandDevice(handedness); } }
protected void UpdateHandData(MLHand hand) { // Update joint positions var pinky = hand.Pinky; ConvertMagicLeapKeyPoint(pinky.Tip, TrackedHandJoint.PinkyTip); ConvertMagicLeapKeyPoint(pinky.MCP, TrackedHandJoint.PinkyKnuckle); var ring = hand.Ring; ConvertMagicLeapKeyPoint(ring.Tip, TrackedHandJoint.RingTip); ConvertMagicLeapKeyPoint(ring.MCP, TrackedHandJoint.RingKnuckle); var middle = hand.Middle; ConvertMagicLeapKeyPoint(middle.Tip, TrackedHandJoint.MiddleTip); ConvertMagicLeapKeyPoint(middle.PIP, TrackedHandJoint.MiddleMiddleJoint); ConvertMagicLeapKeyPoint(middle.MCP, TrackedHandJoint.MiddleKnuckle); var index = hand.Index; ConvertMagicLeapKeyPoint(index.Tip, TrackedHandJoint.IndexTip); ConvertMagicLeapKeyPoint(index.PIP, TrackedHandJoint.IndexMiddleJoint); ConvertMagicLeapKeyPoint(index.MCP, TrackedHandJoint.IndexKnuckle); var thumb = hand.Thumb; ConvertMagicLeapKeyPoint(thumb.Tip, TrackedHandJoint.ThumbTip); ConvertMagicLeapKeyPoint(thumb.IP, TrackedHandJoint.ThumbDistalJoint); ConvertMagicLeapKeyPoint(thumb.MCP, TrackedHandJoint.ThumbProximalJoint); var wrist = hand.Wrist; ConvertMagicLeapKeyPoint(wrist.Center, TrackedHandJoint.Wrist); UpdateJointPose(TrackedHandJoint.Palm, hand.Center, Quaternion.identity); CoreServices.InputSystem?.RaiseHandJointsUpdated(InputSource, ControllerHandedness, jointPoses); // Check pinching action var keyPose = hand.KeyPose; var confidence = hand.KeyPoseConfidence; if (confidence > KeyPoseConfidenceThreshold && (keyPose == MLHandKeyPose.Pinch || keyPose == MLHandKeyPose.Fist)) { IsPinching = true; } else { IsPinching = false; } }
private bool GetGesture(MLHand hand, MLHandKeyPose type) { if (hand != null) { if (hand.KeyPose == type) { if (hand.KeyPoseConfidence > 0.6f) { return(true); } } } return(false); }
void Start() { MLHands.Start(); if (handType == MLHandType.Right) { hand = MLHands.Right; } else { hand = MLHands.Left; } system.Stop(); curPose = hand.KeyPose; }
private void ShowPoints(MLHand hand, GameObject sphere, bool _starting) { Vector3 _pos = hand.Thumb.KeyPoints[0].Position; if (_starting) { sphere.transform.position = _pos; } else { if (Vector3.Distance(sphere.transform.position, _pos) < 0.5f) { sphere.transform.position = Vector3.Lerp(sphere.transform.position, _pos, Time.deltaTime / 0.0625f); } } }
public static float GetThumbIndexDistance(MLHand hand) { if (hand == null) { return(NullHand); } if (hand.HandConfidence < ConfidenceThreshold) { return(NotConfident); } var thumb = hand.Thumb.Tip.Position; var index = hand.Index.Tip.Position; return(Mathf.Abs(Vector3.Distance(thumb, index))); }
private void UpdateIndexFingerData(MLHand hand, MixedRealityInteractionMapping interactionMapping) { if (jointPoses.TryGetValue(TrackedHandJoint.IndexTip, out var pose)) { currentIndexPose.Rotation = pose.Rotation; currentIndexPose.Position = pose.Position; } interactionMapping.PoseData = currentIndexPose; // If our value changed raise it. if (interactionMapping.Changed) { // Raise input system Event if it enabled CoreServices.InputSystem?.RaisePoseInputChanged(InputSource, ControllerHandedness, interactionMapping.MixedRealityInputAction, currentIndexPose); } }
private void UpdateHand(MLHand mlHand, Hand hand) { // Index hand.index.transform.position = mlHand.Index.Tip.Position; hand.index.gameObject.SetActive(mlHand.IsVisible && _indexEnabled); // Thumb hand.thumb.transform.position = mlHand.Thumb.Tip.Position; hand.thumb.gameObject.SetActive(mlHand.IsVisible && _thumbEnabled); // Middle hand.middle.transform.position = mlHand.Middle.Tip.Position; hand.middle.gameObject.SetActive(mlHand.IsVisible && _middleEnabled); // Ring hand.ring.transform.position = mlHand.Ring.Tip.Position; hand.ring.gameObject.SetActive(mlHand.IsVisible && _ringEnabled); // Pinky hand.pinky.transform.position = mlHand.Pinky.Tip.Position; hand.pinky.gameObject.SetActive(mlHand.IsVisible && _pinkyEnabled); }
//Constructors: public ManagedFinger(MLHand hand, params ManagedKeypoint[] points) { //sets: _hand = hand; this.points = points; _lastReliableEnd = points[0]; //hooks: foreach (var item in points) { item.OnFound += HandlePointVisibilityChanged; item.OnLost += HandlePointVisibilityChanged; } //initial events: OnVisibilityChanged?.Invoke(false); HandlePointVisibilityChanged(); }