手势识别后多次点击 - 它应该在第一次点击后停止 [英] multiple hits after gesture recognition - it should stop after the first hit

查看:74
本文介绍了手势识别后多次点击 - 它应该在第一次点击后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题。我正在为应用程序创建一个NUI,我将一些简单的手势绑定到右箭头和左箭头。问题是当我开始申请时。当我第一次做出手势时,我的应用程序连续击中了2次。在
之后它按我的要求100%工作。只有一开始就是问题。



我在我的历史结构中添加了两个Joints和timestamp,它被放入ArrayList中$


            this._history.Add(新HistoryItem()

                {

                    timestamp = timestamp,

                    activeHand = hand,

                    controlJoint = controlJoint

               }

  &NBSP ;        );
$


然后在foreach循环中我正在比较数据



    if(Math.Abs​​((hand.Position.X - item.controlJoint.Position.X))< MainWindow.treshold&& Math.Abs​​((hand.Position.Y - item.controlJoint.Position.Y) )< MainWindow.verticalTreshold)
$


如果它命中我立即打破lopp,用


  &NBSP;&NBSP;休息;
$


之后我清除历史记录ArrayList



    this._history.Clear();
$


所以我没理得。为什么在开始后连续两次点击?

I've got a strange problem. I'm creating a NUI for application and I binded some simple gestures to right and left arrow. The problem is when I start application. When I make gesture for the first time my application is hitting 2 times in a row. After that it works 100% as I want. Only the start is the problem.

I'm adding two Joints and timestamp to my history struct which is put into the ArrayList

            this._history.Add(new HistoryItem()
                {
                    timestamp = timestamp,
                    activeHand = hand,
                    controlJoint = controlJoint
                }
            );

then in foreach loop I'm comparing data

    if (Math.Abs((hand.Position.X - item.controlJoint.Position.X)) < MainWindow.treshold && Math.Abs((hand.Position.Y - item.controlJoint.Position.Y)) < MainWindow.verticalTreshold)

If it hits I instantly break the lopp with

    break;

after that I clear the history ArrayList

    this._history.Clear();

So I don't get it. Why after the start it hits two times in a row ?

//编辑

我创造了一种解决方法。我加入了时间控制。我正在比较调用代码的时间戳和最后一个手势识别的时间戳。如果它太快(我几分钟无法制作的话)我不允许打箭头。我不确定
如果它是一个完美的解决方案,但它是一个有效的解决方案

I've created kind of workaround. I've added time control. I'm comparing timestamp of invoking the code and timestamp of last gesture recognition. If its too fast ( i meen couple of ms which it impossible to make ) I don't allow to hit an arrow. I'm not sure if it's a perfect solution but it is a working solution

推荐答案

好的我的问题是代码。 Ofc在调试中无法解决的小错误。我用了一个功能来分析帧的历史。

Ok my problem was the code. Ofc a small bug untracable in the debug. I used one fucntion to analyse a history of frames.

该方法有两种模式。我已经分离了它并创建了两个不同的方法,每个方法用于每个任务,现在它工作得很好

The method was working in 2 modes. I`ve detached that and created 2 diffrent methods, each for each task and now it works great


这篇关于手势识别后多次点击 - 它应该在第一次点击后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆