how to calculate exact foot step count using accelerometer in android?

前端 未结 5 1123
既然无缘
既然无缘 2020-12-07 10:01

I am developing some application like Runtastic Pedometer using the algorithm but I am not getting any similarity between the results.

my code is as follows:

5条回答
  •  执笔经年
    2020-12-07 10:45

    One main difference I spotted between your implementation and the code in the grepcode project is the way you register the listener.

    Your code:

    mSensorManager.registerListener(mStepDetector,
                                    mSensor,
                                    SensorManager.SENSOR_DELAY_NORMAL);
    

    Their code:

    mSensorManager.registerListener(mStepDetector,
                                    mSensor,
                                    SensorManager.SENSOR_DELAY_FASTEST);
    

    This is a big difference. SENSOR_DELAY_NORMAL is intended for orientation changes, and is therefor not that fast (ever noticed that it takes some time between you rotating the device, and the device actually rotating? That's because this is some functionality that does not need to be super fast (that would probably be pretty annoying even). The rate at which you get updates is not that high).

    On the other hand, SENSOR_DELAY_FASTEST is intended for things like pedometers: you want the sensor data as fast and often as possible, so your calculations of steps will be as accurate as possible.

    Try to switch to the SENSOR_DELAY_FASTEST rate, and test again! It should make a big difference.

提交回复
热议问题