Exemple #1
0
        public void GetGesturesFromRandom(int rnd, HandGesture expectedGesture)
        {
            _Random.Set(rnd);
            var g = _Strategy.GetGesture().Result;

            Assert.AreEqual(expectedGesture, g, $@"The random index {rnd} should return the gesture {expectedGesture}.");
        }
 void Start()
 {
     Manus.ManusInit();
     glove    = new Glove(hand);
     testloop = 0;
     hg       = HandGesture.Default;
 }
Exemple #3
0
    protected void UpdateHandGesture(HandList hands, Frame previousFrame)
    {
        List <int> idsToCheck = new List <int> (hand_gestures_.Keys);

        // Go through all the active hands and update them.
        int numHands = hands.Count;

        for (int h = 0; h < numHands; ++h)
        {
            Hand hand = hands [h];

            idsToCheck.Remove(hand.Id);

            // Create the hand and initialized it if it doesn't exist yet.
            if (!hand_gestures_.ContainsKey(hand.Id))
            {
                HandGesture newHand = new HandGesture();
                newHand.AddSign(hand, previousFrame);
                hand_gestures_ [hand.Id] = newHand;
            }
            else
            {
                // Make sure we update the Leap Hand reference.
                HandGesture handGest = hand_gestures_ [hand.Id];
                handGest.AddSign(hand, previousFrame);
            }
        }

        // Destroy all hands with defunct IDs.
        for (int i = 0; i < idsToCheck.Count; ++i)
        {
            hand_gestures_.Remove(idsToCheck [i]);
        }
    }
Exemple #4
0
    private void CheckRemoveSetGesture(HandGesture formerGesture, HandGesture currentGesture)
    {
        if (formerGesture == HandGesture.Set && volleyball != null)
        {
            rightHand.ResetHandCollider();
            leftHand.ResetHandCollider();

            Rigidbody ballRb = volleyball.GetComponent <Rigidbody>();
            ballRb.useGravity = true;

            Vector3 newBallVel = player.transform.rotation * (((leftHand.GetHandVelocity() + rightHand.GetHandVelocity()) / 2f) * setSpeedMultiplier);

            volleyball.SetVelocity(newBallVel);
            volleyball.CalculatePath();

            // Update Game State
            VolleyballGameManager.instance.HandleInteraction(vp);
            VolleyballGameManager.instance.IncrementHitAmount();

            // Call bot listeners to bot set
            OnBallSet(volleyball);

            volleyball = null;
            GetComponent <SphereCollider>().enabled = false;
        }
    }
Exemple #5
0
 public GestureRecognizedEventArgs(HandDetail detail, HandGesture state, double avg, double min, double max)
 {
     this.HandDetail = detail;
     this.Gesture = state;
     this.AverageValue = avg;
     this.MinimumValue = min;
     this.MaximumValue = max;
 }
 void Update()
 {
     if (glove != null)
     {
         glove.UpdateTransform(ref rootTranform);
     }
     hg = GetGesture();
 }
        public void GetGestureFromKeyPress(char key, HandGesture expectedGesture)
        {
            var input         = new MockInput(key);
            var strategy      = new HumanStrategy(input);
            var actualGesture = strategy.GetGesture().Result;

            // Simulate a keypress
            Assert.AreEqual(expectedGesture, actualGesture, $@"The keypress '{key}' should generate the gesture '{expectedGesture.ToString()}'.");
        }
Exemple #8
0
 private void TryUpdateHandGesture(HandGesture gesture)
 {
     if (currentGesture != gesture)
     {
         HandGesture formerGesture = currentGesture;
         currentGesture = gesture;
         Debug.Log("On Gesture Change");
         OnGestureChanged(formerGesture, currentGesture);
     }
 }
Exemple #9
0
        public void PlayerScoresWithTurns(HandGesture g1, HandGesture g2, HandGesture g3, int score1, int score2, int score3)
        {
            var turn1 = new Turn(_Players.ElementAt(0), g1);
            var turn2 = new Turn(_Players.ElementAt(1), g2);
            var turn3 = new Turn(_Players.ElementAt(2), g3);

            _Scorer.Update(new Turn[] { turn1, turn2, turn3 });
            Assert.AreEqual(score1, _Scorer.Scores.ElementAt(0).Score, $@"Player 1 should score {score1} points");
            Assert.AreEqual(score2, _Scorer.Scores.ElementAt(1).Score, $@"Player 2 should score {score2} points");
            Assert.AreEqual(score3, _Scorer.Scores.ElementAt(2).Score, $@"Player 3 should score {score3} points");
        }
Exemple #10
0
    private void OnGestureChanged(HandGesture formerGesture, HandGesture currentGesture)
    {
        if (currentGesture == HandGesture.Pass)
        {
            platform.enabled = true;
            DisableHandColliders();
        }

        else if (formerGesture == HandGesture.Pass)
        {
            platform.enabled = false;
            EnableHandColliders();
        }
    }
Exemple #11
0
        public void FirstRoundReturnsAnyGesture()
        {
            _Random.Set(0);
            var g1 = _Strategy.GetGesture().Result;

            _Random.Set(1);
            var g2 = _Strategy.GetGesture().Result;

            _Random.Set(2);
            var g3 = _Strategy.GetGesture().Result;
            var g  = new HandGesture[] { g1, g2, g3 };

            Assert.That(g.All(k => _Gestures.Contains(k)), @"The first move should generate any gesture with equal probability");
        }
    void UpdateHandInputs()
    {
        CurrentGesture = HandGesture.Open;

        _targetDevice.TryGetFeatureValue(CommonUsages.grip, out GripValue);
        _targetDevice.TryGetFeatureValue(CommonUsages.trigger, out TriggerValue);
        _targetDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out SecondaryButtonPressed);
        _targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out PrimaryButtonPressed);


        if (_targetDevice.TryGetFeatureValue(CommonUsages.deviceVelocity, out Vector3 value))
        {
            //Velocity = Quaternion.Euler(0, -90, 0) * value;
            Velocity = _rootParent.rotation * value;
        }
    }
Exemple #13
0
    private void SetHandGesture(OVRHand.Hand hand, string gesture)
    {
        HandGesture handGesture = HandGesture.None;

        switch (gesture)
        {
        case "thumb":
        case "Thumb":
            handGesture = HandGesture.Thumb;
            break;

        case "ok":
        case "Ok":
            handGesture = HandGesture.Ok;
            break;

        case "flat":
        case "Flat":
            handGesture = HandGesture.Flat;
            break;

        case "fist":
        case "Fist":
            handGesture = HandGesture.Fist;
            break;

        case "menu":
        case "Menu":
            handGesture = HandGesture.Menu;
            break;

        case "handonarm":
        case "HandOnArm":
            handGesture = HandGesture.HandOnArm;
            break;
        }

        if (hand == OVRHand.Hand.HandLeft)
        {
            _leftHandGesture = handGesture;
        }
        else if (hand == OVRHand.Hand.HandRight)
        {
            _rightHandGesture = handGesture;
        }
        //ComputeFinalGesture();
    }
Exemple #14
0
            /// <summary>
            /// 输出指令
            /// </summary>
            /// <param name="isInputting"> 是否正处于按压状态</param>
            /// <param name="gesture"></param>
            protected void OutPutCommand(HandGesture gesture)
            {
                InputInfo OutPut = new InputInfo();

                OutPut.gesture = gesture;
                Vector2 InputVector = m_InputTouch.PushingPs - m_InputTouch.PushStart;

                if (InputVector.sqrMagnitude < Mathf.Pow(m_InputTouch.m_DragJudgeDistance, 2))
                {
                    InputVector = Vector2.zero;
                }
                OutPut.isLegal = true;
                OutPut.vector  = InputVector;
                OutPut.startPS = m_InputTouch.PushStart;
                OutPut.endPS   = m_InputTouch.PushingPs;
                PlayerCtrl.InputHandTouch(OutPut);
            }
Exemple #15
0
            public void SwitchState(HandGesture inputType)
            {
                BaseInputState state = null;

                switch (inputType)
                {
                case HandGesture.Touching:
                    state = new TouchingState(m_InputTouch);
                    break;

                case HandGesture.Click:
                    state = new ClickState(m_InputTouch);
                    break;

                case HandGesture.Holding:
                    state = new HoldingState(m_InputTouch);
                    break;

                case HandGesture.Drag:
                    state = new DragState(m_InputTouch);
                    break;

                case HandGesture.Slip:
                    state = new SlipState(m_InputTouch);
                    break;

                case HandGesture.Realease:
                    state = new ReleaseState(m_InputTouch);
                    break;

                default:
                    state = new NoneInput(m_InputTouch);
                    break;
                }
                if (state != null)
                {
                    Switch(state);
                }
                else
                {
                    Debug.Log("InputStateFSM.SwitchState " + inputType + "is None");
                }
            }
    /// <summary>
    /// Make the spell actions depending on the gesture
    /// </summary>
    /// <param name="gesture"></param>
    void MakeSpellAction(HandGesture gesture)
    {
        if (SpellObject != null)
        {
            SpellObject.transform.position = Palm.transform.position;
            SpellObject.transform.rotation = Palm.transform.rotation;
        }

        if (gesture == HandGesture.Missing)
        {
            ReleaseSpell();
        }
        else if (gesture == HandGesture.Closed)
        {
            CastSpell();
        }
        else if (gesture == HandGesture.Open)
        {
            ReleaseSpell();
        }
    }
        public async Task <ActionResult> Post(IFormFile file)
        {
            var gesture = new HandGesture();

            try
            {
                var prediction = new HandGesturePrediction();
                var localPath  = await WriteFile(file);

                gesture = new HandGesture()
                {
                    ImagePath = localPath
                };

                if (!localPath.StartsWith("Error"))
                {
                    //if (!string.IsNullOrWhiteSpace(localPath))
                    prediction = _predictionEnginePool.Predict(modelName: Constants.ModelName, example: gesture);
                }
                else
                {
                    prediction.PredictedLabel = localPath;
                }
                //prediction.PredictedLabel = "N/A";

                return(Ok(prediction));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));

                /*
                 * var s = JsonConvert.SerializeObject(ex);
                 * gesture.ActualGesture = s;
                 * return Ok(gesture);*/
            }
        }
 public bool proposeHandGesture(HandGesture aGesture)
 {
     gesturesHistory.Add(aGesture);
     return true;
 }
Exemple #19
0
 public void SwitchState(HandGesture inputType)
 {
     m_InputStateFSM.SwitchState(inputType);
 }
Exemple #20
0
 void Start()
 {
     currentGesture = HandGesture.None;
 }
Exemple #21
0
        public HandGestures()
        {
            mindepth = double.PositiveInfinity;
            maxdepth = double.NegativeInfinity;

            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 150);
            dispatcherTimer.Tick += (sender, e) =>
            {
                _averagedepth = (_averagedepth + _depth) / 2D; // TODO: get rid of _averagedepth and use _handdetail.AverageDepth only
                //
                _handdetail.AverageDepth = _averagedepth;
                //
                double gap = maxdepth - mindepth;
                //
                _handdetail.CurrentGap = gap;
                //
                if (gap > engagethreshold / 1.5 && maxdepth <= _depth)
                {
                    dispatcherTimer.Stop();
                    dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 150);
                    dispatcherTimer.Start();
                    currentgesture = HandGesture.Pull;
                    //
                    if (GestureRecognized != null) GestureRecognized(this, new GestureRecognizedEventArgs(_handdetail, currentgesture, _averagedepth, mindepth, maxdepth));
                    //
                    mindepth = maxdepth = _averagedepth;
                }
                else if (gap > engagethreshold && mindepth >= _depth)
                {
                    dispatcherTimer.Stop();
                    dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 75);
                    dispatcherTimer.Start();
                    currentgesture = HandGesture.Push;
                    _handdetail.PushLocation = _handdetail.CurrentLocation;
                    _handdetail.PushDateTime = DateTime.Now;
                    //
                    if (GestureRecognized != null) GestureRecognized(this, new GestureRecognizedEventArgs(_handdetail, currentgesture, _averagedepth, mindepth, maxdepth));
                    //
                    mindepth = maxdepth = _averagedepth;
                }
                else
                {
                    // clear gesture...
                    currentgesture = HandGesture.None;
                }
                //
                if (mindepth > _averagedepth) mindepth = _averagedepth;
                if (maxdepth < _averagedepth) maxdepth = _averagedepth;
            };
            dispatcherTimer.Start();
        }
Exemple #22
0
 public Turn(IPlayer player, HandGesture gesture)
 {
     Player  = player;
     Gesture = gesture;
 }
Exemple #23
0
 public MockStrategy(HandGesture gesture)
 {
     _Gesture = gesture;
 }
 void UpdateHandGesture()
 {
     CurrentGesture = GripValue > .5f ? HandGesture.Grip : TriggerValue > .5f ? HandGesture.Pinch : HandGesture.Open;
 }
Exemple #25
0
 //通过手势获取输入
 public InputInfo GetInputByGesture(HandGesture gesture)
 {
     return(LegalnputDict[gesture]);
 }