Exemplo n.º 1
0
        //deleted public float time;

        public SimpleUnimanualGestureTemplate(HandPoseType s, HandPoseType e, UnimanualGestureType type)
        {
            startPose = s;
            endPose   = e;
            //deleted  time = t;
            gestureType = type;
        }
Exemplo n.º 2
0
 public SimpleGestureRecognition(float t)
 {
     lastPose        = HandPoseType.Unknown;
     lastGesture     = UnimanualGestureType.Unknown;
     lastPoseTime    = Time.time;
     gestureTimeRate = t;
 }
Exemplo n.º 3
0
 public void OnHandPoseTypeChange()
 {
     if (grabPoint.handPoseType == HandPoseType.HandPose)
     {
         UpdateHandPosePreview();
     }
     previousType = grabPoint.handPoseType;
 }
 void LeftUntracked()
 {
     isLeftHandPinching = false;
     leftUnimanualData  = null;
     leftHand           = null;
     isLeftHandTracked  = false;
     leftHandPose       = HandPoseType.Unknown;
     leftHandGesture    = UnimanualGestureType.Unknown;
 }
 public void AttachHandPoseManager(IHandPoseManager handPoseManager)
 {
     _handPoseManager = handPoseManager as UnityHandPoseManager;
     if (_handPoseManager != null)
     {
         HandPose = _handPoseManager.Pose;
         _handPoseManager.HandPoseChanged += HandPoseChangedHandler;
     }
 }
 void RightUntracked()
 {
     isRightHandPinching = false;
     rightUnimanualData  = null;
     rightHand           = null;
     isRightHandTracked  = false;
     rightHandPose       = HandPoseType.Unknown;
     rightHandGesture    = UnimanualGestureType.Unknown;
 }
Exemplo n.º 7
0
 public bool IsMatch(SimpleUnimanualGestureTemplate template, HandPoseType s, HandPoseType e, float t)
 {
     if (s == template.startPose && e == template.endPose && t <= gestureTimeRate)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 8
0
        public static AnimationClip GetHandAnimationClip(HandPoseType originHandType)
        {
            if (originHandType == HandPoseType.NoSelection)
            {
                return(null);
            }

            string handPoseAnimPath = "HandPoseAnimation/" + HAND_ORIGIN_ANIM_FILE_NAMES[(int)originHandType - 1];

            return(Resources.Load <AnimationClip>(handPoseAnimPath));
        }
Exemplo n.º 9
0
        private void Init()
        {
            HandPoseTypeToConditionDict = new Dictionary <HandPoseType, HandPoseCondition>();
            int n = _handPoseConditions.Count;

            for (int i = 0; i < n; i++)
            {
                HandPoseCondition condition = _handPoseConditions[i];
                HandPoseType      type      = condition.HandPoseType;
                HandPoseTypeToConditionDict.Add(type, condition);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 特定のAnimationファイルのAnimationキー全てをコピーする
        /// </summary>
        public static void AddHandPoseAnimationKeys(AnimationClip targetClip, HandPoseType originHandType)
        {
            if (originHandType == HandPoseType.None)
            {
                return;
            }

            string        originPath = ORIGIN_ANIM_PATH + HAND_ORIGIN_ANIM_FILE_NAMES[(int)originHandType - 1] + ".anim";
            AnimationClip originClip = (AnimationClip)AssetDatabase.LoadAssetAtPath(originPath, typeof(AnimationClip));         // originPathよりAnimationClipの読み込み

            CopyAnimationKeys(originClip, targetClip);
        }
        void Start()
        {
            handPoseRecognition     = new HandPoseRecognition();
            leapServiceProvider     = FindObjectOfType <LeapServiceProvider>();
            leftGestureRecognition  = new SimpleGestureRecognition(gestureTimeRate);
            rightGestureRecognition = new SimpleGestureRecognition(gestureTimeRate);
            bimanualRecognition     = new SimpleGestureRecognition(gestureTimeRate);
            leftHandPose            = HandPoseType.Unknown;
            rightHandPose           = HandPoseType.Unknown;

            InitUnimanualGestures();
            InitBimanualGestures();
        }
Exemplo n.º 12
0
 public HandPoseTemplate(HandPoseType type, float minNon, float maxNon, float minTI, float maxTI, bool t, bool i, bool m, bool r, bool p)
 {
     minNonThumbFingersDistance = minNon;
     maxNonThumbFingerDistance  = maxNon;
     minThumbIndexDistance      = minTI;
     maxThumbIndexDistance      = maxTI;
     thumbExtended  = t;
     indexExtended  = i;
     middleExtended = m;
     ringExtended   = r;
     pinkyExtended  = p;
     poseType       = type;
 }
Exemplo n.º 13
0
        private void UpdateHandPoseWorker(Hand handData)
        {
            if (_handPoseConditionManager == null)
            {
                return;
            }
            HandPoseType lastPose = Pose;

            switch (lastPose)
            {
            case HandPoseType.Normal:
                if (_handPoseConditionManager.CheckSatisfyCondition(
                        HandPoseType.SpidermanReady, handData))
                {
                    Pose = HandPoseType.SpidermanReady;
                }
                break;

            case HandPoseType.SpidermanReady:
                if (_handPoseConditionManager.CheckSatisfyCondition(
                        HandPoseType.SpidermanShoot, handData))
                {
                    Pose = HandPoseType.SpidermanShoot;
                }
                else if (_handPoseConditionManager.CheckSatisfyCondition(
                             HandPoseType.SpidermanReset, handData))
                {
                    Pose = HandPoseType.SpidermanReset;
                }
                break;

            case HandPoseType.SpidermanShoot:
                Pose = HandPoseType.Normal;
                break;

            case HandPoseType.SpidermanReset:
                Pose = HandPoseType.Normal;
                break;
            }

            if (lastPose != Pose)
            {
                OnPoseChanged();
            }
        }
Exemplo n.º 14
0
        public void AttachFingerRotationManager(bool isRight, IFingerRotationManager[] fingers)
        {
            IsRight = isRight;
            _curHandRotationNormalized = new HandRotationNormalizedInfo();
            int n = fingers.Length;

            if (n != 5)
            {
                Debug.LogError("Finger length is incorrect.");
                return;
            }
            _fingers = new IFingerRotationManager[n];
            for (int i = 0; i < n; i++)
            {
                _fingers[i] = fingers[i];
            }
            _handPoseConditionManager = HandPoseConditionManager.Instance;
            Pose = HandPoseType.Normal;
        }
        void UpdatePoseEvents()
        {
            if (rightHandPose != lastHandPose)
            {
                switch (rightHandPose)
                {
                case HandPoseType.Open:
                    OnROpenBegin.Invoke();
                    break;

                case HandPoseType.Paper:
                    OnRPaperBegin.Invoke();
                    break;
                }
                switch (lastHandPose)
                {
                case HandPoseType.Open:
                    OnROpenEnd.Invoke();
                    break;

                case HandPoseType.Paper:
                    OnRPaperEnd.Invoke();
                    break;
                }
            }
            else
            {
                switch (rightHandPose)
                {
                case HandPoseType.Open:
                    OnROpenStay.Invoke();
                    break;

                case HandPoseType.Paper:
                    OnRPaperStay.Invoke();
                    break;
                }
            }

            lastHandPose = rightHandPose;
        }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        action = false;
        if (!gestureRecognitionController.isLeftHandTracked && !gestureRecognitionController.isRightHandTracked)
        {
            return;
        }
        //Debug.Log("HELLO");
        HandPoseType pose = gestureRecognitionController.GetDominantHandPose(isLeftHanded);

        if (gestureRecognitionController.IsHandPinching(gestureRecognitionController.rightHand))
        {
            //Debug.Log("HELLO");
            action = true;
            GrabAction();
        }
        if (!action)
        {
            startAngle = attachment.transform.eulerAngles.y;
        }
    }
Exemplo n.º 17
0
        public HandPoseType GetHandPose(Hand hand)
        {
            HandPoseType type     = HandPoseType.Unknown;
            float        nonThumb = HandPoseUtility.NonThumbFingersGapAverage(hand);
            float        ti       = HandPoseUtility.FingerDistanceTI(hand);
            bool         t        = HandPoseUtility.GetFinger(hand, Finger.FingerType.TYPE_THUMB).IsExtended;
            bool         i        = HandPoseUtility.GetFinger(hand, Finger.FingerType.TYPE_INDEX).IsExtended;
            bool         m        = HandPoseUtility.GetFinger(hand, Finger.FingerType.TYPE_MIDDLE).IsExtended;
            bool         r        = HandPoseUtility.GetFinger(hand, Finger.FingerType.TYPE_RING).IsExtended;
            bool         p        = HandPoseUtility.GetFinger(hand, Finger.FingerType.TYPE_PINKY).IsExtended;

            foreach (HandPoseTemplate template in handPoses)
            {
                if (template.isMatch(nonThumb, ti, t, i, m, r, p))
                {
                    type = template.poseType;
                }
            }

            return(type);
        }
Exemplo n.º 18
0
        public UnimanualGestureType GetUnimanualGesture(HandPoseType pose)
        {
            if (pose == HandPoseType.Unknown || pose == lastPose)
            {
                return(lastGesture);
            }

            float t = Mathf.Abs(Time.time - lastPoseTime);

            UnimanualGestureType gesture = UnimanualGestureType.Unknown;

            foreach (SimpleUnimanualGestureTemplate template in simpleUnimanualGestures)
            {
                if (IsMatch(template, lastPose, pose, t))
                {
                    gesture = template.gestureType;
                }
            }
            lastPose     = pose;
            lastGesture  = gesture;
            lastPoseTime = Time.time;

            return(gesture);
        }
 protected virtual void HandPoseChangedHandler(object sender, HandPoseChangedEventArgs args)
 {
     HandPose = args.Pose;
 }
Exemplo n.º 20
0
        /// <summary>
        /// 特定のAnimationファイルのAnimationキー全てをコピーする
        /// </summary>
        public static bool AddHandPoseAnimationKeysFromOriginClip(ref AnimationClip targetClip, HandPoseType originHandType)
        {
            if (originHandType == HandPoseType.NoSelection)
            {
                return(false);
            }

            AnimationClip originClip = GetHandAnimationClip(originHandType);

            CopyAnimationKeysFromOriginClip(originClip, targetClip);

            return(true);
        }
Exemplo n.º 21
0
 public bool CheckSatisfyCondition(HandPoseType pose,
                                   IHandRotationNormalized handRotation)
 {
     return(HandPoseTypeToConditionDict[pose].CheckSatisfyCondition(handRotation));
 }
Exemplo n.º 22
0
 public bool CheckSatisfyCondition(HandPoseType pose, Hand handData)
 {
     return(HandPoseTypeToConditionDict[pose].CheckSatisfyCondition(handData));
 }
 public HandPoseChangedEventArgs(HandPoseType pose)
 {
     Pose = pose;
 }
Exemplo n.º 24
0
 public HandPoseCondition(HandPoseType type)
 {
     _handPoseType = type;
     _name         = type.ToString();
 }
        void PoseGestureUpdate()
        {
            Frame       frame = leapServiceProvider.CurrentFrame;
            List <Hand> hands = frame.Hands;

            if (hands.Count > 0)
            {
                switch (hands.Count)
                {
                case 1:
                    if (hands[0].IsLeft)
                    {
                        leftHand  = hands[0];
                        rightHand = null;
                    }
                    else
                    {
                        leftHand  = null;
                        rightHand = hands[0];
                    }
                    break;

                case 2:
                    if (hands[0].IsRight)
                    {
                        leftHand  = hands[1];
                        rightHand = hands[0];
                    }
                    else
                    {
                        leftHand  = hands[0];
                        rightHand = hands[1];
                    }
                    break;
                }

                if (leftHand != null && leftHand.Id != 0)
                {
                    if (leftHand.IsPinching())
                    {
                        if (!isLeftHandPinching)
                        {
                            leftHandPinchStart = leftHand.PalmPosition.ToVector3();
                        }

                        if (overridePinchStatus)
                        {
                            isLeftHandPinching = (leftHand.PinchStrength <= maxPinchStrength && leftHand.PinchStrength >= minPinchStrength) ? true : false;
                        }
                        else
                        {
                            isLeftHandPinching = true;
                        }
                    }
                    else if (!leftHand.IsPinching())
                    {
                        isLeftHandPinching = false;
                        leftHandPinchStart = Vector3.negativeInfinity;
                    }
                    isLeftHandTracked = true;
                    leftHandPose      = handPoseRecognition.GetHandPose(leftHand);
                    leftHandGesture   = leftGestureRecognition.GetUnimanualGesture(leftHandPose);

                    if (!leftHandGesture.Equals(UnimanualGestureType.Unknown.ToString()))
                    {
                        if (leftUnimanualData == null || leftUnimanualData.gesture != leftHandGesture)
                        {
                            Hand h = new Hand();
                            h = h.CopyFrom(leftHand);
                            leftUnimanualData = new UnimanualData(leftHandGesture, h);
                        }
                    }
                    else
                    {
                        leftUnimanualData = null;
                    }
                }
                else
                {
                    LeftUntracked();
                }

                if (rightHand != null && rightHand.Id != 0)
                {
                    if (rightHand.IsPinching())
                    {
                        if (!isRightHandPinching)
                        {
                            righHandPinchStart = rightHand.PalmPosition.ToVector3();
                        }

                        if (overridePinchStatus)
                        {
                            isRightHandPinching = (rightHand.PinchStrength <= maxPinchStrength && rightHand.PinchStrength >= minPinchStrength) ? true : false;
                        }
                        else
                        {
                            isRightHandPinching = true;
                        }
                    }
                    else if (!rightHand.IsPinching())
                    {
                        isRightHandPinching = false;
                        righHandPinchStart  = Vector3.negativeInfinity;
                    }

                    isRightHandTracked = true;
                    rightHandPose      = handPoseRecognition.GetHandPose(rightHand);
                    rightHandGesture   = rightGestureRecognition.GetUnimanualGesture(rightHandPose);
                    if (!rightHandGesture.Equals(UnimanualGestureType.Unknown.ToString()))
                    {
                        if (rightUnimanualData == null || rightUnimanualData.gesture != rightHandGesture)
                        {
                            Hand h = new Hand();
                            h = h.CopyFrom(rightHand);
                            rightUnimanualData = new UnimanualData(rightHandGesture, h);
                        }
                    }
                    else
                    {
                        rightUnimanualData = null;
                    }

                    //EventUpdate
                    UpdatePoseEvents();
                }
                else
                {
                    RightUntracked();
                }

                if (hands.Count == 2 && leftHand != null && rightHand != null)
                {
                    bimanualGesture = bimanualRecognition.GetBimanualGesture(leftHandGesture, rightHandGesture);
                    if (!bimanualGesture.Equals(BimanualGestureType.Unknown.ToString()))
                    {
                        if (bimanualData == null || bimanualGesture != bimanualData.gesture)
                        {
                            Hand l = new Hand();
                            l = l.CopyFrom(leftHand);
                            Hand r = new Hand();
                            r            = r.CopyFrom(rightHand);
                            bimanualData = new BimanualData(l, r, leftHandGesture, rightHandGesture, bimanualGesture);
                        }
                    }
                    else
                    {
                        bimanualData = null;
                    }
                }
                else
                {
                    bimanualGesture = BimanualGestureType.Unknown;
                }
            }
            else
            {
                LeftUntracked();
                RightUntracked();
                BimanualUntracked();
            }
        }