Pedometer (step counter)

I am developing the Pedometer Android application to count the number of steps taken and using the steps of calculating the distance traveled and calories burned. I followed the tutorial Create a simple pedometer and step counter in Android and do exactly the same. It determines the number of steps when the sensor detects movement.

But there are some problems:

  • When I stand in the same place with my device in my hand and simply move my hand or give a jerk to the device, it detects a change and adds to the number of steps.
  • If I move very slowly with the device in my hand, it does not detect a change.
  • If I jump, he adds a few steps to the counter.

I checked some other applications from the Play Store, they do not do this kind of thing.

I searched, but cannot find a suitable solution or tutorial for it. Any help or suggestions. thank

+4
source share
3 answers

The problem is that your implementation is not complicated enough: it checks to see if there is a surge in accelerometer data and suggests that the spike is coming from the step. He has no idea where the acceleration acceleration comes from: perhaps you also jump or shake the device in your hand.

How to make it more accurate? Well, this is a really difficult question, which has been the subject of scientific work for a very long time. Even the most sophisticated fitness trackers (which use machine learning, signal processing and other statistical methods) can hardly determine when this step is real, and when it is just noisy or the user is playing with the device.

, Android step , , .

, AI ( , ), .

0

SensorEventListener onSensorChanged onAccuracyChanged, .

    public class StepActivity extends Activity implements SensorEventListener{
    SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    Sensor sSensor= sensorManager .getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);

    ...

}

SensorManager Sensor Sensor, , onSensorChanged, SensorEvent , , , TYPE_STEP_DETECTOR.

private long steps = 0;

@Override
public void onSensorChanged(SensorEvent event) {
    Sensor sensor = event.sensor;
    float[] values = event.values;
    int value = -1;

    if (values.length > 0) {
        value = (int) values[0];
    }


    if (sensor.getType() == Sensor.TYPE_STEP_DETECTOR) {
        steps++;
    }
}
0

Source: https://habr.com/ru/post/1687770/


All Articles