简体   繁体   English

如何在Android中识别TAP(抖动)模式?

[英]How to recognize TAP (shake) pattern in Android?

I want to capture a "TAP" on an Android device. 我想在Android设备上捕获“ TAP”。 For example, say the device is in the user's pocket. 例如,假设设备在用户的口袋中。 And then he touched the phone twice from outside his pocket with a particular pattern. 然后,他摸了摸手机两次从他的口袋外面有一个特定的模式。 Say, hitting with two/three fingers like `TAP -- TAP.' 说,用两根/三根手指击打,如“ TAP-TAP”。 I want to capture this. 我想捕捉一下。

I guess, it should be achievable using accelerometer. 我猜想,使用加速度计应该可以实现。 Now, I can read, X,Y,Z ... but how can I recognize that it is `TAP - TAP'? 现在,我可以读取X,Y,Z ...,但是我怎么能识别出它是“ TAP-TAP”呢? Is it possible? 可能吗?

Or, is there other way to achieve this? 或者,还有其他方法可以实现这一目标吗? Thanks. 谢谢。

Thing is that it might be pretty hard to dissociate regular shaking when the user is walking (especially if he has loose pockets) from that TAP TAP. 事实是,当用户从该TAP TAP行走时(尤其是口袋松动的情况下),很难消除常规摇晃。 Is it supposed to work like when the user walks, or run ? 它应该像用户走路或跑步时一样工作吗?

To achieve that, I would first osbserve the accelerometer over duration, as well as the TAP TAP incidence on those same accelero measurements. 为此,我将先观察一下加速度计的持续时间,以及在相同加速度测量中的TAP TAP发生率。 Best way to notice that special action is then to set up a pattern. 注意到特殊动作的最好方法就是建立模式。 Here is a first example I could think of (very basic) : 这是我想到的第一个示例(非常基本):

  • a threshold (average values + OFFSET) is reached in a certain accelerometer axis, which could be considered as a first tap. 在某个加速度计轴上达到一个阈值(平均值+偏移),可以将其视为第一次轻拍。
  • values turn back around the average. 值又回到平均值附近。
  • the same threshold is reached - that is before X milliseconds 达到相同的阈值-在X毫秒之前
  • action detected. 检测到动作。

All the works consists in being able to find the correct pattern and the corresponding algorithm, knowing that the accelerometer is very noise-sensitive (especially in a pocket). 所有工作都在于能够知道加速度计对噪声非常敏感(尤其是放在口袋中),从而能够找到正确的模式和相应的算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM