0% found this document useful (0 votes)
3 views

optimised-algorithm-accurate

The paper presents an optimized algorithm for accurate step counting using smartphone accelerometry, achieving an average accuracy of 95%. The algorithm, based on a windowed peak detection method, has been validated with a novel ground truth device and is available as an open-source project for Android. This research addresses the challenges of step counting due to various smartphone carrying positions and aims to provide a reliable tool for fitness and health applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

optimised-algorithm-accurate

The paper presents an optimized algorithm for accurate step counting using smartphone accelerometry, achieving an average accuracy of 95%. The algorithm, based on a windowed peak detection method, has been validated with a novel ground truth device and is available as an open-source project for Android. This research addresses the challenges of step counting due to various smartphone carrying positions and aims to provide a reliable tool for fitness and health applications.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/328990649

An Optimised Algorithm for Accurate Steps Counting From Smart-Phone


Accelerometry

Conference Paper in Conference proceedings: ... Annual International Conference of the IEEE Engineering in Medicine and Biology Society. IEEE Engineering in Medicine and Biology Society.
Conference · July 2018
DOI: 10.1109/EMBC.2018.8513319

CITATIONS READS
13 2,411

4 authors, including:

Dario Salvi Carmelo Velardo


Malmö University University of Oxford
80 PUBLICATIONS 1,125 CITATIONS 82 PUBLICATIONS 1,998 CITATIONS

SEE PROFILE SEE PROFILE

L. Tarassenko
University of Oxford
427 PUBLICATIONS 18,267 CITATIONS

SEE PROFILE

All content following this page was uploaded by Dario Salvi on 21 December 2018.

The user has requested enhancement of the downloaded file.


An optimised algorithm for accurate steps counting from smart-phone
accelerometry
Dario Salvi, Carmelo Velardo, Jamieson Brynes, Lionel Tarassenko

Abstract— Step counting from smart-phones allows a wide devices is being investigated widely [5], little is still known
range of applications related to fitness and health. Estimating about mobile applications.
steps from phones’ accelerometers is challenging because of the The research community, and developers in general, would
multitude of ways a smart-phone can be carried. We focus our
work on the windowed peak detection algorithm, which has therefore benefit from a validated, open-source implemen-
previously been shown to be accurate and efficient and thus tation of a step-counting algorithm for smart-phones. Even
suitable for mobile devices. We explore and optimise further though there are a number of open-source projects related
the algorithm and its parameters making use of data collected to step-counting, to the best of our knowledge, none have
by three volunteers holding the phone in six different positions. been validated with robust methods. The aim of this paper
In order to simplify the analysis of the data, we also built
a novel device for the detection of the ground truth steps. is to describe how an algorithm for smart-phone based step
Over the collected data set, the algorithm reaches 95% average counting has been designed, optimised and validated. The
accuracy. We implemented the algorithm for the Android OS algorithm we propose makes use of the data generated by the
and released it as an open source project. A separate dataset accelerometer sensor, is robust to noise, is accurate enough
was collected with the algorithm running on the smart-phone to be meaningful for common fitness and health applications
for further validation. The validation confirms the accuracy of
the algorithm in real-time conditions. and is computationally efficient to be executable in real-time
by a smart-phone. The algorithm has been implemented in
I. INTRODUCTION Python and Java and is available as an open-source project
In the last 10 years, no other electronic device has had the at: https://oxford-step-counter.github.io/.
same commercial and societal impact as the smart-phone. II. RELATED WORK
Mobile phone penetration is greater than that of personal
computers and, in the United Kingdom, it has already There have been a number of attempts to develop step
reached peaks of 85% for people aged 17-75 [1]. Modern counting algorithms based on an accelerometers signal. In [6]
smart-phones embed a vast number of sensors connected a relationship between walking speed and the accelerometer
to powerful processing units and capacious memories. Even signals is used to devise an algorithm based on thresholding
low-end devices have built-in accelerometers, proximity sen- the magnitude. The algorithm was tested on five walking
sors, gyroscopes, magnetometers and Global Positioning samples ranging from 16 to 44 steps and achieved an average
System receivers. accuracy of 96.6%. The data collection protocol was not
This technology allows for several applications, from nav- detailed except for the fact that the device was fixed near
igation and positioning [2] to tracking for health and fitness the centre of mass of the subject.
purposes [3]. Particularly relevant for health and fitness, is In [7], the authors tested a multitude of algorithms for
the ability to measure physical activity. Step counting is the both walk detection and step counting. The paper describes
most commonly used parameter extracted in apps designed a wide range of techniques, from simple thresholding in
to measure and influence physical activity [4]. the time domain, to frequency domain analysis to non-
Recently, high-end smart-phones have often incorporated linear template matching and machine learning. To com-
low-power step counters, which are part of the motion- pare them, authors decided to benchmark nine algorithms:
sensing chip-set, but older or cheaper devices still lack windowed peak detection, mean crossing counts, normalized
this functionality. To compensate for the lack of hardware autocorrelation, dynamic time warping, short term Fourier
resources, mobile applications like Google Fit or Samsung transform, continuous wavelet transform, discrete wavelet
Health compute the step count using the main processing transform, hidden Markov model, and k-means clustering.
unit, but the accuracy and the details of their algorithms are They collected 130 data recordings from 27 subjects holding
unknown. The lack of a proper evaluation of these products a smart-phone in 4 ways: in-hand, in a front pocket, in a
makes it difficult to employ them for medical purposes, back pocket, and in a handbag. A video recording was taken
where transparency about the accuracy and the limitations of of each session for reference. Authors determined that the
the technology are needed. While the accuracy of wearable windowed peak detection, the hidden Markov model and
the continuous wavelet transform methods worked the best
All the authors are with the Institute of Biomedical Engineering, across the scenarios, with a median error of about 1.3%.
Department of Engineering Science, University of Oxford, Oxford, Given the computational complexity of the two latter tech-
United Kingdom. [email protected], [email protected],
[email protected], [email protected]. niques, authors concluded that the windowed peak detection
This work was supported by NIHR Oxford Biomedical Research Centre. is the most efficient algorithm.
Fig. 1. Block diagram of the step counting algorithm. Between each pair
of stages there is a buffer to allow parallelism.

In [8], Gu et al. present an algorithm based on the


peak detection method that is also robust to false positives.
Their approach consists in adding constraints to the peak
detection in terms of periodicity (time difference between
two neighbouring peaks), similarity (peak distance between
two windows of acceleration), and continuity (number of
neighbouring windows of acceleration readings with the vari-
ance surpassing a threshold). These features allow filtering
out "false walking", e.g. when users remain still and use
their phone for writing text messages, calling, watching Fig. 2. Signal at each processing stage. The ground truth shows the moment
videos, playing games, etc. Eight volunteers were recruited when a step was detected by the ground truth device. This signal may be
slightly delayed due to latency introduced by the wireless connection.
and asked to walk 300 steps with a smart-phone in different
motion states: (a) walking with the phone in a fixed phone
pose, (b) walking with the phone in arbitrary phone poses and
(c) walking for some segments with false walking states. The Therefore this stage is responsible for computing the mag-
average error produced by their algorithm ranged from 3.54% nitude of the triaxial accelerometry signal and ensuring a
in the walking state to 14.04% in the false walking state. constant sampling frequency by means of linear interpola-
They compared these performances with common fitness tion.
applications, which performed worse especially when in the Within this work we have assumed the sampling frequency
presence of false walking. to be 100 Hz, but the algorithm does not depend on this
Unfortunately, none of these studies have made the source value.
code of the algorithms available, nor the data sets used for 2) Filtering stage: Accelerometers are subject to noise
their validation. from a variety of sources (mechanical, electrical, thermal,
etc.), therefore some noise-reduction technique is needed
III. METHODS especially at frequencies that are not related to human
walking or running. In order to reduce the noise level, we
A. Step counting algorithm have implemented a finite impulse response (FIR) low-pass
To estimate the number of steps from the smart-phone filter with a cut-off frequency of 3 Hz, which allows a variety
accelerometer signals, we used the windowed peak detection of walking speeds. This value should include even the pace
technique because of its efficiency, as suggested by [7]. of the speediest walkers, which was identified as 5.4 mph
Particularly, our algorithm is based on the approach proposed (8.7 km/h) by the American College of Sports Medicine [10],
by [9] and can be split into 5 stages, each responsible for a with a ratio of 2000 steps per mile (1250 steps per km). An
particular function (see figure 1). example of the raw accelerometer signal after interpolation
To allow fast processing of the data, each block can be and filtering is shown in figure 2.
instantiated in a parallel thread, while buffers are used to We consider different types of window functions for
hold the data temporarily between each block. For each stage evaluation: moving average, Gaussian window, Hann window
we present a set of options and parameters that need to be and the Kaiser-Bessel window.
optimised. 3) Scoring stage: The function of the scoring stage is
1) Pre-processing stage: Common smart-phones provide to evaluate the peakiness of a given sample. The result
accelerometry signals over three orthogonal axes; however of this stage should increase the magnitude of any peaks,
the step-counting algorithm is concerned with the magnitude making them more evident for the subsequent peak detection.
rather than any single directional component because the Different methods were considered:
physical orientation of the device is unknown. Although • Maximum Difference: This considers the N previous
common smart-phone operating systems allow a desired samples and determines the maximum difference be-
sampling rate for the accelerometer to be set, there is no tween these and the sample in question, then computes
guarantee that the sampling rate will be kept with precision. the same for the N samples to the right and averages
the two maximum differences as the result. If pi is the
peakiness of sample xi then for 1 ≤ k ≤ N :
max(xi − xi−k ) + max(xi − xi+k )
k k
pi = (1)
2
• Mean Difference: This method is similar to the Maxi-
mum Difference method, except that instead of taking
the maximum of the difference, it uses the mean of Fig. 3. First version of the Fig. 4. Second version of
the differences. This preserves the overall shape of the ground truth device. Push buttons the ground truth device. Pressure-
are placed under the tip of the sensitive foils are placed in the
waveform. shoes and connected to the board shoe under the heel. A conductive
PN through wires. thread is used to connect the foil to
k=−N,k6=i (xi − xi+k ) the board.
pi = , (2)
2N
• Modified Pan-Tompkins Scoring: This is an adaptation
of a well-known algorithm used for peak detection in step. Once the walking signal is captured and converted to
electrocardiogram waveforms [11]. Given a window of a binary format (i.e. foot down / foot up), the device sends
N samples, the algorithm zero-means the data within the result to a smart-phone application through a Bluetooth
the window, sets all the negative data points to zero Low Energy (BLE) link. The same application can be used
and squares the samples. to record the raw accelerometry data from the phone. The
An example of the output from the scoring stage is shown parallel recording of the two signals on one device allows to
in figure 2. have them synchronised effortlessly.
4) Detection stage: This stage identifies potential can- The ground truth device was built using the RFduino BLE-
didate peaks to be associated with a step by statistically enabled Arduino-compatible prototyping board. The device
detecting outliers. As the algorithm processes the signal, underwent two iterations: in the first, two common push
it keeps track of a running mean and standard deviation. buttons were placed under the tip of the shoe. While effective
These two quantities are used to determine whether any given in detecting steps, this solution did not prove robust as
sample is an outlier. If the difference between the sample and the buttons broke after a few recording sessions. For the
the mean is above c times the standard deviation, then it is second iteration we placed a pressure-sensitive foil, Velostat,
marked as a potential step. The parameter c is considered for between the foot and the insole. Velostat is a polymeric foil
optimisation. impregnated with carbon black that makes it electrically con-
5) Post-processing stage: This stage slides a window of ductive, and is used primarily for packaging. The properties
a fixed size, twindow , across the potential peaks and only of the material are such that if subject to an electric current, it
keeps the maximum sample within the window. As the small changes the value of its resistance when pressed or stretched.
dots in figure 2 show, all of the potential peak points are Two 5x5 cm Velostat foils were wired to the analogue-
clustered around the rise to the main peak. This stage selects to-digital converters of the board where special-purpose
the local maximum among them. By tuning the window size, firmware was developed to distinguish between ’weight-
one can limit the number of steps within the window, thus not on’ and ’weight-off’ states. The firmware uses an adaptive
allowing peaks less than twindow apart. This approach can be threshold to determine the transition between the two states.
tuned to accommodate the periodicity of human walk. We set The threshold adapts as the medium point between the
the window length to 200 ms, corresponding to a maximum minimum and the maximum value. Every five seconds, the
walking speed of 5 steps/s, which is faster than the speediest minimum is increased and the maximum decreased of 10%
walking pace (3 steps per second). The effect of this stage of the difference. This approach guarantees that the threshold
can be seen with the circles in figure 2. adapts to changes in the signal (e.g. if the foil moves inside
the shoe).
B. Ground truth data collection The device samples the resistance of the two foils at 50
The proposed algorithm was fine-tuned and validated Hz and transmits it over BLE to the phone. The mobile
against a self-collected dataset composed of raw accelerom- app logs both the accelerometer signals and the ground-truth
etry data and a ground truth signal. Previous works have signal and provides a simple user interface for controlling
used two approaches to ground truth collection: manual the recording session (a start/stop button and a timer). The
step counting [8] or video annotation [7]. Although simple software also allows these files to be sent remotely to an
to implement, these methodologies either do not provide HTTP endpoint after having compressed them.
step-by-step information, which may help understand the Figures 3 and 4 show the 2 versions of the device and
behaviour of the algorithm, or are time intensive and prone figure 5 shows one of the signals generated by stepping on
to error. Velostat foils.
We used a custom-built electronic device able to derive The device was validated by comparing its output with
step-by-step information. The device is placed in the shoes manually counted steps. Steps were counted by two observers
of the participants, allowing the detection of each single and disagreements resulted in the test being discarded. Exper-
TABLE I
S ET OF PARAMETERS OPTIMISED FOR EACH STAGE AND MINIMUM ,
MAXIMUM AND STEP VALUE .

Stage Parameters Min Step Max


Filtering Window size 13 8 53
Scoring Window size 3 8 51
Detection Threshold 1.2 0.2 1.4

TABLE II
P HYSICAL CHARACTERISTICS OF THE VOLUNTEERS WHO COLLECTED
THE DATA AND AVERAGE ± STANDARD DEVIATION OF THE DURATION
AND NUMBER OF STEPS OF THE COLLECTED TRACKS .

Fig. 5. Digitised value of the voltage measured on one Velostat foil (blue)
and the computed threshold (red). Age Weight(kg) Height(cm) Duration(s) Steps
38 86 180 163±20 537±50
33 80 186 171±27 481±58
iments were performed over short distances with the number 21 68 172 153±18 547±79
of steps varying between 22 and 79 (average 36 ±14 standard
deviation) and time varying between 14 and 41 seconds
(average 24±8 s). a distributed cloud-computing platform (Google Cloud Com-
Of 17 experiments, 12 showed no difference in the number pute) was employed to spread the processing load across
of steps counted by the device and the researchers, 4 had a multiple machines. Each permutation of parameters was
1-step difference and 1 had a 2-step difference. This yields ranked according to the mean error obtained on all the
to an average accuracy of 99% and standard deviation of 2%. recordings.
We considered this accuracy to be sufficient for the purpose
IV. RESULTS
of this work.
The details of the three researchers (all male) who col-
C. Data collection lected the data are summarised in table II together with
average and standard deviation of the duration and number
In order to optimise the parameters of the algorithm with
of steps.
different scenarios, we collected data from three researchers
Table III shows the optimal set of parameters obtained
walking for two to three minutes with the phone held in
by the distributed optimisation phase. With these set of
six different positions: in a hand, in a front pocket, in a
parameters, the average accuracy is 95% ± 4.5% standard
back pocket, in an armband, in a shoulder purse, and in
deviation.
a neck pouch on a lanyard. These scenarios are similar
If we split the analysis according to the position of the
to the ones proposed by [7]. This resulted in a dataset
smart-phone during the recordings we obtain the results in
containing 36 distinct recordings, each with approximately
table IV (each scenario has six recordings). It is possible to
2.5 minutes of accelerometer and ground-truth data. Six extra
observe that the in-hand and purse positions give rise the
experiments were dedicated to assess the differences between
lowest accuracies. These may be caused by the harmonics
three different phones (Google Pixel, Samsung Galaxy S6,
LG Nexus 5) in similar conditions: phone held in hand, same
floor and same user. TABLE III
To validate the algorithm when running on the phone, 12 S ET OF PARAMETERS THAT OBTAINS THE MINIMUM AVERAGE ERROR .
extra recordings were collected by two researchers holding
the phone in the same six positions as the ones used for Stage Parameters Value
optimising the algorithm. Window size M=13
Filter type Gaussian
Filtering
D. Algorithm optimisation Filter SD 0.35
To select the optimal set of parameters for our algorithm Cutoff frequency 3Hz
an exhaustive grid search across the parameter space was Gain at cutoff -60dB
performed. The explored range of the parameters is shown
in table I together with parameters that were kept constant. Type Mean Difference
Scoring
The sampling frequency was fixed at 100 Hz for all the tests. Window size N = 35
Both the algorithm and the benchmarking software were
developed in Python version 3. The optimisation of the Detection Threshold 1.2
parameters was performed on the 36 recordings of the
scenarios dataset. In order to expedite the exhaustive search, Post-Processing twindow 200 ms
TABLE IV
We have not evaluated scenarios of false walking activities
ACCURACY OF THE OPTIMISED ALGORITHM PER POSITION , N=6 FOR
as was done in [8]. For these scenarios, Gu et al. offer some
EACH POSITION
valid additions to the Windowed Peak Detection that would
need to be added to our implementation.
Position Average accuracy ± SD
In hand 93% ± 3.8% R EFERENCES
Front pocket 95% ± 2.8% [1] P. Lee, “Mobile Consumer Survey 2017: The UK cut,”
Back pocket 98% ± 1.2% Deloitte [Last accessed: 27 September 2017], Tech. Rep.,
Purse 90% ± 7.2% 2017. [Online]. Available: http://www.deloitte.co.uk/mobileuk/?_ga=
2.95282970.782041114.1506509099-13344498.1506509099
Armband 95% ± 2.5% [2] H.-E. Chen, Y.-Y. Lin, C.-H. Chen, and I.-F. Wang, “Blindnavi:
Neck pouch 98% ± 1.0% A navigation app for the visually impaired smartphone user,” in
Proceedings of the 33rd Annual ACM Conference Extended Abstracts
on Human Factors in Computing Systems, ser. CHI EA ’15. New
TABLE V
York, NY, USA: ACM, 2015, pp. 19–24.
ACCURACY OF THE OPTIMISED ALGORITHM PER PHONE MODEL [3] J. P. Higgins, “Smartphone Applications for Patients’ Health and
Fitness,” The American Journal of Medicine, vol. 129, no. 1, pp. 11–
19, Jan. 2016.
Phone model Accuracy Accuracy [4] J. Bort-Roig, N. D. Gilson, A. Puig-Ribera, R. S. Contreras, and S. G.
recording 1 recording 2 Trost, “Measuring and Influencing Physical Activity with Smartphone
Google Pixel 97.9% 95.30% Technology: A Systematic Review,” Sports Medicine, vol. 44, no. 5,
pp. 671–686, May 2014.
Google Nexus 5 96.1% 97.3% [5] P. Alinia, C. Cain, R. Fallahzadeh, A. Shahrokni, D. Cook, and
Samsung S6 99.6% 95.5% H. Ghasemzadeh, “How accurate is your activity tracker? a compar-
ative study of step counts in low-intensity physical activities,” JMIR
mHealth and uHealth, vol. 5, no. 8, p. e106, 2017.
[6] N. Z. Naqvi, A. Kumar, A. Chauhan, and K. Sahni, “Step count-
introduced in the walking frequency range by the arm ing using smartphone-based accelerometer,” International Journal on
swinging when holding the phone, or by the purse swinging Computer Science and Engineering, vol. 4, no. 5, pp. 675–681, May
2012.
back and forth under the arm. [7] A. Brajdic and R. Harle, “Walk detection and step counting on uncon-
If we analyse the six recordings that use different smart- strained smartphones,” in Proceedings of the 2013 ACM international
phones (results in table V) we can conclude that the choice joint conference on Pervasive and ubiquitous computing. ACM, 2013,
pp. 225–234.
of the phone does not affect the accuracy of our algorithm [8] F. Gu, K. Khoshelham, J. Shang, F. Yu, and Z. Wei, “Robust and
significantly, which confirms the findings of [7]. accurate smartphone-based step counting for indoor localization,”
IEEE Sensors Journal, vol. 17, no. 11, pp. 3453–3460, 2017.
The average accuracy obtained with the 12 validation [9] G. Palshikar, “Simple algorithms for peak detection in time-series,”
tracks collected with the algorithm running on the phone Tata Research Development and Design Centre, Tech. Rep., 2009.
is 93 ± 13%. This confirms that the algorithm performs with [10] W. W. Hoeger, L. Bond, L. Ransdell, J. M. Shimon, and S. Merugu,
“One-mile step count at walking and running speeds,” ACSM’s Health
a similar accuracy also when running on a smart-phone. The & Fitness Journal, vol. 12, no. 1, pp. 14–19, 2008.
high variance is due to one track taken in the back pocket [11] J. Pan and W. J. Tompkins, “A real-time QRS detection algorithm,”
when the algorithm counted almost twice the number of IEEE transactions on biomedical engineering, no. 3, pp. 230–236,
1985.
steps. The reason may be due to the fact that the pocket was
loose and allowed the phone to rebound and thus introduced
components in the signal at twice the frequency of the gait.

V. CONCLUSIONS AND FUTURE WORK


Our paper builds on the results of [7]. We agreed to their
recommendation of using the Windowed Peak Detection and
we explored further different design choices and parameters.
We confirm that the accuracy of the algorithm is above 90%
for the dataset on which it is optimised and, in addition, that
the performance is similar when the algorithm runs on the
phone with data it was not optimised on. We also show a
different approach for the collection of ground truth data that
is more scalable and we provide all our datasets and code as
open source to the community.
There are limitations to this study that could benefit from
further investigation. All our recordings were gathered during
walking on a hard floor and it will be necessary to investigate
softer surfaces like carpet or grass. To optimise parameters,
further scenarios will be added to the analysis such as
running and climbing stairs. Also, longer datasets would be
needed from more subjects to confirm the findings.

View publication stats

You might also like