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

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


The first thing you need to do is decide on an algorithm. As far as I know there are roughly speaking three ways to detect steps using accelerometers that are described in the literature:

  1. Use the Pythagorean theorem to calculate the magnitude of the acceleration vector of each sample from the accelerometer. Low-pass filter the magnitude signal to remove high frequency noise and then look for peaks and valleys in the filtered signal. You may need to add additional requirements to remove false positives. This is by far the simplest way to detect steps, it is also the way that most if not all ordinary pedometers of the sort that you can buy from a sports store work.

  2. Use Pythagoras' like in (1), then run the signal through an FFT and compare the output from the FFT to known outputs of walking. This requires you to have access to a fairly large amount of training data.

  3. Feed the accelerometer data into an algorithm that uses some suitable machine learning technique, for example a neural network or a digital wavelet transform. You can of course include other sensors in this approach. This also requires you to have access to a fairly large amount of training data.

Once you have decided on an algorithm you will probably want to use something like Matlab or SciPy to test your algorithm on your computer using recordings that you have made on Android phones. Dump accelerometer data to a cvs file on your phone, make a record of how many steps the file represents, copy the file to your computer and run your algorithm on the data to see if it gets the step count right. That way you can detect problems with the algorithm and correct them.

If this sounds difficult, then the best way to get access to good step detection is probably to wait until more phones come with the built-in step counter that KitKat enables.


I am using step detection in my walking instrument.I get nice results of step detection.I use achartengine to plot accelerometer data.Take a look here.What I do:

  1. Analysis of magnitude vector for accelerometer sensor.
  2. Setting a changeable threshold level. When signal from accelerometer is above it I count it as a step.
  3. Setting the time of inactive state (for step detection) after first crossing of the threshold.

Point 3. is calculated:

  • arbitrary setting the maximum tempo of our walking (e.g. 120bpm)
  • if 60bpm - 1000msec per step, then 120bpm - 500msec per step
  • accelerometer passes data with certain desired frequency (SENSOR_DELAY_NORMAL, SENSOR_DELAY_GAME, etc.). When DELAY_GAME: T ~= 20ms (this is included in Android documentation)
  • n - samples to omit (after passing the threshold)
  • n = 500msec / T
  • n = 500 / 20 = 25 (plenty of them. You can adjust this value).
  • after that, the threshold becomes active.

Take a look at this picture:My application