How to improve accuracy of accelerometer and compass sensors?

后端 未结 4 1222
北荒
北荒 2021-02-01 11:07

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

相关标签:
4条回答
  • 2021-02-01 11:15

    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.

    0 讨论(0)
  • 2021-02-01 11:20

    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

    0 讨论(0)
  • 2021-02-01 11:22

    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.

    0 讨论(0)
  • 2021-02-01 11:39

    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.

    0 讨论(0)
提交回复
热议问题