如何提高加速度计和指南针传感器的精度?

发布于 2024-12-06 22:32:02 字数 155 浏览 1 评论 0原文

我正在创建一个增强现实应用程序,当手机面向兴趣点(GPS 位置存储在手机上)时,它可以简单地可视化文本视图。文本视图绘制在屏幕中的兴趣点位置上。

它工作正常,问题是指南针和加速度计非常“变体”,并且由于传感器的不精确性,文本视图不断地左右上下移动。

有办法解决吗?

i am creating an augmented reality app that simply visualices a textview when the phone is facing a Point of Interest (wich gps position is stored on the phone). The textview is painted on the point of interest location in the screen.

It works ok, the problem is that compass and accelerometer are very "variant", and the textview is constantly moving up and down left and right because the innacuracy of the sensors.

there is a way to solve it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

秋叶绚丽 2024-12-13 22:32:02

我们的问题是一样的。当我创建简单的增强现实项目时,我也遇到了同样的问题。解决方案是使用指数平滑或移动平均函数。我建议指数平滑,因为它只需要存储一个先前的值。示例实现如下:

private float[] exponentialSmoothing( float[] input, float[] output, float alpha ) {
        if ( output == null ) 
            return input;
        for ( int i=0; i<input.length; i++ ) {
             output[i] = output[i] + alpha * (input[i] - output[i]);
        }
        return output;
}

Alpha 是平滑因子(0<= alpha <=1)。如果设置 alpha = 1,输出将与输入相同(根本没有平滑)。如果设置 alpha = 0,输出将永远不会改变。要消除噪声,您可以简单地平滑加速度计和磁力计值。

就我而言,我使用加速度计 alpha 值 = 0.2 和磁力计 alpha 值 = 0.5。物体会更加稳定,动作也相当漂亮。

Our problem is same. I also had same problem when I create simple augmented reality project. The solution is to use exponential smoothing or moving average function. I recommend exponential smoothing because it only need to store one previous values. Sample implementation is available below :

private float[] exponentialSmoothing( float[] input, float[] output, float alpha ) {
        if ( output == null ) 
            return input;
        for ( int i=0; i<input.length; i++ ) {
             output[i] = output[i] + alpha * (input[i] - output[i]);
        }
        return output;
}

Alpha is smoothing factor (0<= alpha <=1). If you set alpha = 1, the output will be same as the input (no smoothing at all). If you set alpha = 0, the output will never change. To remove noise, you can simply smoothening accelerometer and magnetometer values.

In my case, I use accelerometer alpha value = 0.2 and magnetometer alpha value = 0.5. The object will be more stable and the movement is quite nice.

只想待在家 2024-12-13 22:32:02

如果您想更进一步,您应该查看方向数据或传感器融合的低通滤波器。

祝您的应用好运。

JQ科雷亚

You should take a look at low-pass filters for you orientation data or sensor fusion if you want to a step further.

Good Luck with your app.

JQCorreia

我的痛♀有谁懂 2024-12-13 22:32:02

我用一个简单的技巧解决了这个问题。这会稍微延迟你的结果,但它们肯定会避免指南针和加速度计的不准确。

创建最后 N 值的历史记录(因此将值保存到数组中,递增索引,当达到 N 时再次从零开始)。然后您只需使用存储值的算术平均值即可。

I solved it with a simple trick. This will delay your results a bit but they surly avoid the inaccuracy of the compass and accelerometer.

Create a history of the last N values (so save the value to an array, increment index, when you reach N start with zero again). Then you simply use the arithmetic average of the stored values.

枯寂 2024-12-13 22:32:02

陀螺仪传感器读数的集成可以极大地提高最终方向估计的稳定性。
如果您的设备有,请查看稳定指南针应用程序陀螺仪,或者如果您没有陀螺仪,请观看视频。

陀螺仪的集成可以使用互补滤波器以相当简单的方式完成。

Integration of gyroscope sensor readings can give a huge improvement in the stability of the final estimation of the orientation.
Have a look at the steady compass application if your device has a gyroscope, or just have a look at the video if you do not have a gyroscope.

The integration of gyroscope can be done in a rather simple way using a complementary filter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文