Pedometer (Step Counter)

Harry .Naeem picture Harry .Naeem · Oct 19, 2017 · Viewed 32.2k times · Source

I am developing a Pedometer Android application to count number of steps taken and using the steps calculate the distance covered and calories burned. I have followed the tutorial Create a Simple Pedometer and Step Counter in Android and done exactly like it. It detects number of steps when the sensor detects motion.

But there are some problems with it:

  1. When I stand at the same place with my device in my hand and just move my hand or give a jerk to device, it detects the change and adds to step count.
  2. If I move very slowly with device in my hand it does not detect the change.
  3. If i jump, then it adds several steps in the counter.

I have checked some other applications from Play Store they do not do this kind of stuff.

I have searched but cannot find an appropriate solution or tutorial for it. Any help or suggestions. Thanks

Answer

TukeV picture TukeV · Oct 19, 2017

The problem here is that your implementation is not sophisticated enough: it only checks if there is a spike in the accelerometer data and assumes that the spike is coming from a step. It has no idea where the spike in acceleration is really coming from: it might as well come from you jumping or shaking the device in your hand.

How to make it more accurate then? Well, that is a really difficult question which has been topic for scientific papers for a really long time. Even the most sophisticated fitness trackers (which use machine learning, signal processing and other statistical methods) have difficulties to determine when the step is real and when it is just noice or user playing with the device.

Luckily Android does have it's own builtin step counter and step detector, which are more sophisticated than the class in yor example.

So unless you really want to learn signal processing and AI (which I highly recommended, although I don't know much about the data science of step detection), I would suggest to use builtin detector and counter.