java 如何使用加速度计进行手势识别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/198982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:23:31  来源:igfitidea点击:

How to do Gesture Recognition using Accelerometers

javaembeddedaccelerometergesture-recognition

提问by smaclell

My goal is to recognize simple gestures from accelerometers mounted on a sun spot. A gesture could be as simple as rotating the device or moving the device in several different motions. The device currently only has accelerometers but we are considering adding gyroscopes if it would make it easier/more accurate.

我的目标是识别安装在太阳黑子上的加速度计的简单手势。手势可以像旋转设备或以几种不同的动作移动设备一样简单。该设备目前只有加速度计,但我们正在考虑添加陀螺仪,如果它能让它更容易/更准确。

Does anyone have recommendations for how to do this? Any available libraries in Java? Sample projects you recommend I check out? Papers you recommend?

有没有人有关于如何做到这一点的建议?Java 中有哪些可用的库?你推荐我检查的示例项目?你推荐的论文?

The sun spot is a Java platform to help you make quick prototypes of systems. It is programmed using Java and can relay commands back to a base station attached to a computer. If I need to explain how the hardware works more leave a comment.

sun spot 是一个 Java 平台,可帮助您快速制作系统原型。它使用 Java 编程,可以将命令转发回连接到计算机的基站。如果我需要解释硬件的工作原理,请发表评论。

回答by moonshadow

The accelerometers will be registering a constant acceleration due to gravity, plus any acceleration the device is subjected to by the user, plus noise.

加速度计将记录由于重力引起的恒定加速度,加上用户受到的任何加速度,加上噪音。

You will need to low pass filter the samples to get rid of as much irrelevant noise as you can. The worst of the noise will generally be higher frequency than any possible human-induced acceleration.

您将需要对样本进行低通滤波,以尽可能多地去除不相关的噪声。最糟糕的噪音通常会比任何可能的人为加速度更高的频率。

Realise that when the device is not being accelerated by the user, the only force is due to gravity, and therefore you can deduce its attitudein space. Moreover, when the total acceleration varies greatly from 1g, it must be due to the user accelerating the device; by subtracting last known estimate of gravity, you can roughly estimate in what direction and by how much the user is accelerating the device, and so obtain data you can begin to match against a list of known gestures.

意识到当设备没有被用户加速时,唯一的力是由于重力,因此您可以推断出它在空间中的姿态。而且,当总加速度从1g变化很大时,一定是由于用户加速了设备;通过减去上次已知的重力估计,您可以粗略估计用户加速设备的方向和速度,从而获得可以开始与已知手势列表进行匹配的数据。

With a single three-axis accelerometer you can detect the current pitch and roll, and also acceleration of the device in a straight line. Integrating acceleration minus gravity will give you an estimate of current velocity, but the estimate will rapidly drift away from reality due to noise; you will have to make assumptions about the user's behaviour before / between / during gestures, and guide them through your UI, to provide points where the device is not being accelerated and you can reset your estimates and reliably estimate the direction of gravity. Integrating again to find position is unlikely to provide usable results over any useful length of time at all.

使用单个三轴加速度计,您可以检测当前的俯仰和滚转,以及设备在直线上的加速度。积分加速度减去重力将为您提供当前速度的估计值,但由于噪声,估计值会迅速偏离现实;您必须在手势之前/之间/期间对用户的行为做出假设,并引导他们通过您的 UI,提供设备未加速的点,您可以重置您的估计并可靠地估计重力方向。再次积分以找到位置根本不可能在任何有用的时间长度内提供可用的结果。

If you have two three-axis accelerometers some distance apart, or one and some gyros, you can also detect rotation of the device (by comparing the acceleration vectors, or from the gyros directly); integrating angular momentum over a couple of seconds will give you an estimate of current yaw relative to that when you started integrating, but again this will drift out of true rapidly.

如果你有两个相距一定距离的三轴加速度计,或者一个和一些陀螺仪,你也可以检测设备的旋转(通过比较加速度矢量,或直接从陀螺仪检测);在几秒钟内积分角动量将使您估计当前偏航相对于您开始积分时的偏航,但这同样会迅速偏离真实情况。

回答by Abraham Philip

Since no one seems to have mentioned existing libraries, as requested by OP, here goes:

http://www.wiigee.org/

Meant for use with the Wiimote, wiigeeis an open-source Java based implementation for pattern matching based on accelerometer readings. It accomplishes this using Hidden Markov Models[1].

It was apparently used to great effect by a company, Thorn Technologies, and they've mentioned their experience here : http://www.thorntech.com/2013/07/mobile-device-3d-accelerometer-based-gesture-recognition/

Alternatively, you could consider FastDTW(https://code.google.com/p/fastdtw/). It's less accurate than regular DTW[2], but also computationally less expensive, which is a big deal when it comes to embedded systems or mobile devices.

由于似乎没有人按照 OP 的要求提到现有的库,因此请访问:

http: //www.wiigee.org/

用于 Wiimote,wiigee是一种基于 Java 的开源实现,用于基于加速度计的模式匹配读数。它使用隐马尔可夫模型[1]来实现这一点。

它显然被 Thorn Technologies 公司使用,效果很好,他们在这里提到了他们的经验:http: //www.thorntech.com/2013/07/mobile-device-3d-accelerometer-based-gesture-recognition /

或者,您可以考虑FastDTW( https://code.google.com/p/fastdtw/)。它不如常规DTW准确[2],但计算成本也更低,这对于嵌入式系统或移动设备来说是一个大问题。

[1] https://en.wikipedia.org/wiki/Hidden_Markov_model
[2] https://en.wikipedia.org/wiki/Dynamic_time_warping

EDIT: The OP has mentioned in one of the comments that he completed his project, with 90% accuracy in the field and a sub-millisecond compute time, using a variant of $1 Recognizer. He also mentions that rotation was not a criteria in his project.

[1] https://en.wikipedia.org/wiki/Hidden_​​Markov_model
[2] https://en.wikipedia.org/wiki/Dynamic_time_warping

编辑:OP 在评论之一中提到他完成了他的项目,使用$1 Recognizer的变体,现场准确度为 90%,计算时间为亚毫秒。他还提到轮换不是他项目的标准。

回答by Brian

What hasn't been mentioned yet is the actual gesture recognition. This is the hard part. After you have cleaned up your data (low pass filtered, normalized, etc) you still have most of the work to do.

尚未提到的是实际的手势识别。这是困难的部分。清理完数据(低通滤波、归一化等)后,您仍有大部分工作要做。

Have a look at Hidden Markov Models. This seems to be the most popular approach, but using them isn't trivial. There is usually a preprocessing step. First doing STFT and clustering the resultant vector into a dictionary, then feeding that into a HMM. Have a look at jahmm in google code for a java lib.

看看隐马尔可夫模型。这似乎是最流行的方法,但使用它们并非易事。通常有一个预处理步骤。首先进行 STFT 并将结果向量聚类到字典中,然后将其输入到 HMM 中。在 google 代码中查看 java lib 中的 jahmm。

回答by Toybuilder

Adding to moonshadow's point about having to reset your baseline for gravity and rotation...

添加moonshadow关于必须重置重力和旋转基线的观点......

Unless the device is expected to have stable moments of rest (where the only force acting on it is gravity) to reset its measurement baseline, your system will eventually develop an equivalent of vertigo.

除非预期设备具有稳定的静止时刻(作用于它的唯一力是重力)以重置其测量基线,否则您的系统最终会产生眩晕。