7

Currently I am interning at a software company and one of my tasks has been to implement the recognition of mouse gestures. One of the senior developers helped me get started and provided code/projects that uses the $1 Unistroke Recognizer http://depts.washington.edu/aimgroup/proj/dollar/. I get, in a broad way, what the $1 Unistroke Recognizer is doing and how it works but am a bit overwhelmed with trying to understand all of the internals/finer details of it.

My problem is that I am trying to recognize the gesture of moving the mouse downards, then upwards. The $1 Unistroke Recognizer determines that the gesture I created was a downwards gesture, which is infact what it ought to do. What I really would like it to do is say "I recognize a downards gesture AND THEN an upwards gesture."

I do not know if the lack of understanding of the $1 Unistroke Recognizer completely is causing me to scratch my head, but does anyone have any ideas as to how to recognize two different gestures from moving the mouse downwards then upwards?

Here is my idea that I thought might help me but would love for someone who is an expert or even knows just a bit more than me to let me know what you think. Any help or resources that you know of would be greatly appreciated.

How My Application Currently Works:

The way that my current application works is that I capture points from where the mouse cursor is while the user holds down the left mouse button. A list of points then gets feed to a the gesture recognizer and it then spits out what it thinks to be the best shape/gesture that cooresponds to the captured points.

My Idea:

What I wanted to do is before I feed the points to the gesture recognizer is to somehow go through all the points and break them down into separate lines or curves. This way I could feed each line/curve in one at a time and from the basic movements of down, up, left, right, diagonals, and curves I could determine the final shape/gesture.

One way I thought would be good in determining if there are separate lines in my list of points is sampling groups of points and looking at their slope. If the slope of a sampled group of points differed X% from some other group of sampled points then it would be safe to assume that there is indeed a separate line present.

What I Think Are Possible Problems In My Thinking:

  • Where do I determine the end of a line and the start of a separate line? If I was to use the idea of checking the slope of a group of points and then determined that there was a separate line present that doesn't mean I nessecarily found the slope of a separate line. For example if you were to draw a straight edged "L" with a right angle and sample the slope of the points around the corner of the "L" you would see that the slope would give resonable indication that there is a separate line present but those points don't correspond to the start of a separate line.

  • How to deal with the ever changing slope of a curved line? The gesture recognizer that I use handles curves already in the way I want it too. But I don't want my method that I use to determine separate lines keep on looking for these so called separate lines in a curve because its slope is changing all the time when I sample groups of points. Would I just stop sampling points once the slope changed more than X% so many times in a row?

  • I'm not using the correct "type" of math for determining separate lines. Math isn't my strongest subject but I did do some research. I tried to look into Dot Products and see if that would point me in some direction, but I don't know if it will. Has anyone used Dot Prodcuts for doing something like this or some other method?

Final Thoughts, Remarks, And Thanks:

Part of my problem I feel like is that I don't know how to compeletly ask my question. I wouldn't be surprised if this problem has already been asked (in one way or another) and a solution exist that can be Googled. But my search results on Google didn't provide any solutions as I just don't know exactly how to ask my question yet. If you feel like it is confusing please let me know where and why and I will help clarify it. In doing so maybe my searches on Google will become more precise and I will be able to find a solution.

I just want to say thanks again for reading my post. I know its long but didn't really know where else to ask it. Imma talk with some other people around the office but all of my best solutions I have used throughout school have come from the StackOverflow community so I owe much thanks to you.

Edits To This Post:

(7/6 4:00 PM) Another idea I thought about was comparing all the points before a Min/Max point. For example, if I moved the mouse downards then upwards, my starting point would be the current Max point while the point where I start moving the mouse back upwards would be my min point. I could then go ahead and look to see if there are any points after the min point and if so say that there could be a new potential line. I dunno how well this will work on other shapes like stars but thats another thing Im going to look into. Has anyone done something similar to this before?

4

3 回答 3

1

如果您使用绝对角度,例如向上和向下,您可以简单地取两点(不一定相邻)之间的绝对斜率来确定它是 RIGHT、LEFT、UP、DOWN(如果这足以区分)

艺术是找到点之间的距离,使角度不是随机的(1px,角度将是45°的倍数)

有一个使用鼠标手势进行导航的 Firefox 插件,效果很好。我认为是 FireGestures,但我不确定。我想你可以从中得到一些灵感

附加思考:如果你通过连接g个连续的点来绘制一个形状,然后连接回第一个点,面积与最终线段长度的比率也是手势“边缘”的指标

于 2010-07-07T15:15:29.057 回答
1

如果您的问题可以缩小到将一般曲线分解成直线或平滑弯曲的部分线,那么您可以试试这个。

在非常简化的情况下,比较段的斜率并确定大于某个阈值的断点。想象一个完美形成的 L 形,两条直线之间有一个直角。显然,只要阈值在 0 到 90 度之间,角点将是唯一一个斜率差高于阈值的点,因此是一个可识别的断点。

但是,垂直线和水平线可能会略微弯曲,因此阈值需要足够大,才能将这些小的斜率差异作为断点忽略。您还必须决定算法应该将多尖锐的角作为休息。是否需要 90 度或更高,或者甚至 30 度就足够了?这是一个重要的问题。

最后,为了使这个稳健,我不会满足于比较两个相邻段的斜率。手可能会颤抖,拐角可能会被磨平,寻找直线和尖角的理想条件可能永远不会出现。对于为休息而调查的每个点,我将取前N个分段的平均斜率,并将其与后续N个分段的平均斜率进行比较。这可以使用运行均值有效地实现。通过选择一个好的样本数N(取决于输入的精度、点的总数等),算法可以避免噪声并做出更好的检测。

基本上该算法将是:

  • 对于每个调查点(开始N点进入序列,结束前N点。)
    • 计算前N个段的平均斜率。
    • 计算下N个段的平均斜率。
    • 如果平均值的差异大于阈值,则将当前点标记为断点。

这完全出乎我的意料。你必须在你的应用程序中尝试它。

于 2010-07-07T13:30:17.080 回答
1

如果您只对上/下/左/右感兴趣,第一个近似值是检查圆的 45 度线段。这很容易通过检查(连续)点之间的水平差异与点之间的垂直差异来完成。

假设您的水平差异大于垂直差异,那么这将是“正确的”。

例如,唯一的困难是区分 UP/DOWN 和 UP/RIGHT/DOWN。但这可以通过点之间的距离来完成。如果您确定鼠标向右移动了不到 20 像素,那么您可以忽略该移动。

于 2010-07-15T14:01:38.257 回答