-1

The swipe gestures Left,Right, Up and Down are not optimized. If a task has to be performed with an upward swipe, it would get confused with a left swipe and still perform it.Please suggest me the parameters to be optimized for differentiating swipes.Or commands for perfect swipe recognition Also it gets confused with a circle and a swipe. I have added my code. In one single frame only one gesture should be detected.How do i limit this here.

public MainWindow()
{
InitializeComponent();

        this.controller = new Controller();

        this.listener = new LeapListener(this);
        controller.AddListener(listener);

        for (int iCount = 1; iCount < 23; iCount++)
        {
            images[iCount] = new BitmapImage();
            images[iCount].BeginInit();
            images[iCount].UriSource = new Uri("Images/" + iCount + ".png", UriKind.Relative);
            images[iCount].EndInit();
        }
        image.Source = images[1];
    }



    delegate void LeapEventDelegate(string EventName);




    public void LeapEventNotification(string EventName)
    {
        if (this.CheckAccess())
        {
            switch (EventName)
            {
                case "onInit":

                    break;
                case "onConnect":

                    this.connectHandler();
                    break;
                case "onFrame":

                    this.checkGestures(this.controller.Frame());

                    break;
            }
        }
        else
        {
            Dispatcher.Invoke(new LeapEventDelegate(LeapEventNotification
                ), new object[] { EventName });
        }
    }

    public void connectHandler()
    {
        controller.EnableGesture(Gesture.GestureType.TYPE_SWIPE);
        this.controller.EnableGesture(Gesture.GestureType.TYPE_CIRCLE);
        this.controller.EnableGesture(Gesture.GestureType.TYPE_KEY_TAP);
        this.controller.EnableGesture(Gesture.GestureType.TYPE_SCREEN_TAP);


        // controller.Config.SetFloat("Gesture.Swipe.Speed", 4000.0f);
        controller.Config.SetFloat("Gesture.Swipe.MinVelocity", 750f);
        controller.Config.SetFloat("Gesture.Swipe.MinLength", 200f);

        controller.Config.SetFloat("Gesture.KeyTap.MinDownVelocity", 40.0f);
        controller.Config.SetFloat("Gesture.KeyTap.HistorySeconds", .2f);
        controller.Config.SetFloat("Gesture.KeyTap.MinDistance", 40.0f);

        controller.Config.SetFloat("Gesture.Circle.MinRadius", 15.0f);
        controller.Config.SetFloat("Gesture.Circle.MinArc", 15f);

        controller.Config.SetFloat("InteractionBox.Width", 1600.0f);
        controller.Config.SetFloat("InteractionBox.Height", 1600.0f);

        controller.Config.Save();
    }


    public void checkGestures(Frame frame)
    {


        GestureList gestures = frame.Gestures();
        foreach (Gesture gesture in gestures)
        {

            // For Image 1
            if (image.Source.Equals(images[1]))
            {



                if (gesture.Type == Gesture.GestureType.TYPE_SWIPE)
                {

                    SwipeGesture swipe = new SwipeGesture(gesture);
                    if (swipe.State == Gesture.GestureState.STATE_START && swipe.Direction.x > 0 && Math.Abs(swipe.Direction.y) < 5)
                    {

                        image.Source = images[2];
                        //   Console.WriteLine("Second");
                    }

                }

            }

            // For Image 2
            else if (image.Source.Equals(images[2]))
            {

                if (gesture.Type == Gesture.GestureType.TYPE_SWIPE)
                {
                    SwipeGesture swipe = new SwipeGesture(gesture);

                    if (swipe.State == Gesture.GestureState.STATE_START && swipe.Direction.y > 0)

                    {
                        image.Source = images[3];
                    }
                   else  if (swipe.State == Gesture.GestureState.STATE_START && swipe.Direction.x > 0 && Math.Abs(swipe.Direction.y) < 5)
                    {
                        image.Source = images[7];
                    }
                }
                 if (gesture.Type == Gesture.GestureType.TYPE_KEY_TAP)
                {
                    KeyTapGesture TapGesture = new KeyTapGesture(gesture);
                    image.Source = images[1];
                    Console.WriteLine("Circle");
                }
            }
            // For Image 3
            else if (image.Source.Equals(images[3]))
            {

                if (gesture.Type == Gesture.GestureType.TYPE_SWIPE)
                {
                    SwipeGesture swipe = new SwipeGesture(gesture);

                    if (swipe.State == Gesture.GestureState.STATE_START && swipe.Direction.y < 0)

                    {
                        image.Source = images[4];
                    }
                 else   if (swipe.State == Gesture.GestureState.STATE_START && swipe.Direction.x < 0 && Math.Abs(swipe.Direction.y) < 5)
                    {
                        image.Source = images[16];
                    }

                }
                if (gesture.Type == Gesture.GestureType.TYPE_KEY_TAP)
                {
                    KeyTapGesture TapGesture = new KeyTapGesture(gesture);
                    image.Source = images[1];

                }
            }

            }//foreach
        }
    }
}

1 Answers1

0

The out of the box Gestures were deprecated in 3.x (Orion) as they weren't to reliable. The best thing to do is to understand the SDK and just create your own gestures, you can go beyond whats already Out of the box and more reliable. Everything its about 3d positioning so pay attention to your Y,X,Z, use the debuger hands or create your own debug system to see how it behaves.

Chop Labalagun
  • 592
  • 1
  • 6
  • 19