This app demonstrates a simple approach for activity recognition without any Machine learning involved. The app requires an accelerometer sensor as well as an barometer sensor in order to function!
It is able to detect movement (like walking) as well as stair climbing.
For movement detection the following algorithm is used:
- Get linear acceleration vector
- Calculate the length of the acceleration vector: vectorLength = √(accX² + accY² + accZ²)
- Calculate the EWMA of this length: ewma(i) = 𝛼 * vectorLength + (1 - 𝛼) * ewma(i-1)
- Check the EWMA for a certain threshold
For stairs detection the following algorithm is used:
- Get pressure data
- Remember the initial pressure (only on 1st call)
- Calculate the EWMA of this data
- Check whether the device is moving (movement detection algorithm from before)
- Subtract the EWMA from the remembered pressure data
- Take its absolute value and check it for a certain threshold
- Save the EWMA for the next threshold comparison