Accelerometer-based activity recognition for smart apps.

Techniques for identifying activities such as walking, running, or driving are widely used on smart-phone applications. These applications can help you analyze your trips and extract information about your everyday life.

act.png

But how does it work?

A smart-phone has a 3-axis accelerometer sensor which records the x, y, and z acceleration of your device, including gravity. For example, when your smart-phone sits still on your desk, one of the axis is constantly giving a number of around 9.81 which is the gravity acceleration here on Earth. The other two axes are near 0.

Congratulations, you have just learned how to detect the “Still” activity! If you know a little bit of programming for Android or iOS, you could easily implement an app that will do something when your phone sits still. Or not.

When you are walking, the acceleration on your body is periodical. What this means is that one of the axes’ values (depends on the orientation of your device) will be increasing and decreasing in a periodic fashion as you take each step. In contrast, when you are in a vehicle, the random vibrations will be causing small non-periodic accelerations on all the axes. There are many approaches for differentiating between the two kinds of acceleration. One simple way is to set a peak threshold and detect peaks when acceleration exceeds the said threshold. If the difference in time between peaks is near the mean time of all the peak differences (in a sliding window), then you can assume that the user of the device is walking, or running. As a bonus, you can also count the number of steps the user has taken, since each peak is most probably a foot step. On the other hand, if you get a greater number of smaller peaks in a non-periodic fashion, then the user is probably in a vehicle.

The aforementioned approach is obviously very simplistic, and may or may not work! If you are looking for something more advanced, you can use the Activity Recognition API for Android and CMMotionActivity for iOS. These APIs are implemented by Google and Apple, respectively, and are most probably using Machine Learning methods. Such methods can be trained on large amounts of data and differentiate between activities using induced models.

If you wish to experience activity recognition first-hand, you may try my latest Android app “Kilometre”, which detects in-vehicle trips and automatically calculates your fuel consumption and expenses.

tshot000tshot001tshot004

Advertisements