过滤加速度计数据噪声
如何过滤 Android 中加速度计数据的噪音?我想为我的样本数据创建一个高通滤波器,以便我可以消除低频分量并专注于高频分量。我读过卡尔曼滤波器可能是最好的选择,但是我如何在主要用 Android Java 编写的应用程序中集成或使用此方法?或者可以首先完成吗?或者通过Android NDK?这是否有可能实时完成?
任何想法将不胜感激。谢谢你!
How do I filter noise of the accelerometer data in Android? I would like to create a high-pass filter for my sample data so that I could eliminate low frequency components and focus on the high frequency components. I have read that Kalman filter might be the best candidate for this, but how do I integrate or use this method in my application which will mostly written in Android Java? or can it be done in the first place? or through Android NDK? Is there by any chance that this can be done in real-time?
Any idea will be much appreciated. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Apple SDK 中的示例实际上以更简单的方式实现了过滤,即使用渐变:
The samples from Apple's SDK actually implement the filtering in an even simpler way which is by using ramping:
以下是 Android 代码,改编自苹果自适应高通滤波器示例。只需插入并实现 onFilteredAccelerometerChanged()
Here's the code for Android, adapted from the apple adaptive high pass filter example. Just plug this in and implement onFilteredAccelerometerChanged()
对于那些想知道norm()和clamp()方法在rbgrn的答案中做什么的人,你可以在这里看到它们:
http://developer.apple.com/library /IOS/samplecode/AccelerometerGraph/Listings/AccelerometerGraph_AccelerometerFilter_m.htmlFor those wondering what norm() and clamp() methods do in the answer from rbgrn, you can see them here:
http://developer.apple.com/library/IOS/samplecode/AccelerometerGraph/Listings/AccelerometerGraph_AccelerometerFilter_m.html我似乎记得这是在苹果 iPhone 的示例代码中完成的。让我们看看...
在 Google 上查找 AccelerometerFilter.h / .m(或获取 Apple 的 AccelerometerGraph 示例)和此链接:http://en.wikipedia.org/wiki/High-pass_filter(这就是苹果代码的基础)。
Wiki 中也有一些伪代码。但将数学转化为代码相当简单。
I seem to remember this being done in Apple's sample code for the iPhone. Let's see...
Look for AccelerometerFilter.h / .m on Google (or grab Apple's AccelerometerGraph sample) and this link: http://en.wikipedia.org/wiki/High-pass_filter (that's what Apple's code is based on).
There is some pseudo-code in the Wiki, too. But the math is fairly simple to translate to code.
IMO,设计卡尔曼滤波器作为您的第一次尝试使可能相当简单的问题变得过于复杂。我会从一个简单的 FIR 滤波器开始,只有在您测试过它并合理确定它无法提供您想要的东西时才尝试更复杂的东西。然而,我的猜测是,它将能够完成您需要的一切,并且更加轻松高效。
IMO, designing a Kalman filter as your first attempt is over-complicating what's probably a fairly simple problem. I'd start with a simple FIR filter, and only try something more complex when/if you've tested that and found with reasonable certainty that it can't provide what you want. My guess, however, is that it will be able to do everything you need, and do it much more easily and efficiently.