Algorithm Design for Accurate Steps Counting Based on Smartphone Sensors for Indoor Applications

Algorithm Design for Accurate Steps Counting Based on Smartphone Sensors for Indoor Applications

Volume 5, Issue 6, Page No 811-816, 2020

Author’s Name: Hani Muhsena), Odeh Al-Amaydeh, Rakan Al-Hamlan

View Affiliations

Mechatronics Engineering Department, German Jordanian University, Amman, 11180, Jordan

a)Author to whom correspondence should be addressed. E-mail: Hani.Mohsen@gju.edu.jo

Adv. Sci. Technol. Eng. Syst. J. 5(6), 811-816 (2020); a  DOI: 10.25046/aj050696

Keywords: Algorithm design, Steps Counting, Pedometer, Accelerometer

Share

425 Downloads

Export Citations

This paper aims to design an accurate and robust algorithm for counting the steps based on the smartphone’s accelerometer for indoor applications. Different daily activities have been considered in the experimental scenarios, including normal walking with various smartphone positions and running activities. The detection process’s accuracy is ensured by setting an appropriate segregation approach and defining a fixed threshold for each experiment. The algorithm generates a new envelope signal that mimics the collected steps signal without the vibrations and noise elements to avoid miscounting the exact steps. The followed approach results have been compared with the pedometer applications on the android platform and HUAWEI Watch GT-731. The proposed algorithm showed improved detection accuracy in contrast to the other literature approaches. The obtained accuracy was around 99% for the standard walking scenario and approximately 97% for the running activity scenario.

Received: 09 October 2020, Accepted: 18 November 2020, Published Online: 24 November 2020

1. Introduction

Lately, the step count has been extensively used in various applications, such as health monitoring, auxiliary positioning, and gaming. Earlier, the Pedestrian Dead Reckoning (PDR) was used as a localization method based on advanced built-in sensors [1] that exist these days in Smartphones. These sensors found in the smartphones include accelerometers, proximity sensors, gyroscopes, magnetometers, and Global Positioning System. The accuracy of the steps count is one of the challenges of the PDR. Therefore, several studies have been addressed, increasing the accuracy of steps count while walking using the smartphone’s accelerometer [2–4].

One of the aspects has been considered in the literature: smartphone placement’s impact on measurement accuracy. The smartphone’s position and placement might cause jitter during the human motion, which leads to counting false steps [5]. Also, remaining still, watching videos, playing games, and many other activities can lead to a wrong step count [6]. In [7], it was recommended to place the smartphone at the user the fingertips with the view screen point upwards while using the phone. If the smartphone is placed in the jacket or trouser pocket, it is recommended to put the top of the smartphone upright. One of the challenges of this approach is getting rid of the noisy signals accompanying the detected steps. Therefore, a discrete Kalman filter was used in the literature to minimize the smartphone accelerometer’s noise during human motion [8]. The Footsteps are usually calculated using an algorithm in the smartphone on the android platform, which can count precisely by dividing the measurement processes into two phases. The first phase includes collecting the linear acceleration and the gravity values from the accelerometer of the smartphone. These values are then used to derive the horizontal components and identify possible start points of regular periodical fluctuations. The second phase includes finding the correlation coefficients to determine if the collected sensing measurements exhibit similar tendencies, and accordingly, it finds the steps count. The results showed higher measurement accuracies if the user holds the phone statically [9]. Although several approaches have been proposed and used for step counting, most of these approaches are not validated with robust methods. Therefore, this work aims to design a robust algorithm for step count purposes with high accuracy. The proposed algorithm will distinguish between false steps and real steps to reduce the measurement error and enhance its credibility.

This paper is structured as follows. In section II, a concise overview of related work. In section III, the proposed approach to count the steps is presented. The obtained results are discussed in section IV, and the paper ends with conclusions.

2. Related Work

Several algorithms have been proposed to enhance the step count based on the smartphone’s sensors in-state of the art. In [6, 10], a window peak detection algorithm has been proposed based on the smartphone’s accelerometer. The algorithm could afford an average accuracy of 95%, considering the different ways that a smartphone can be carried. The algorithm’s parameters have been optimized and applied to measured data from three different volunteers holding the smartphone at different positions. A new algorithm based on the smartphone sensor has been proposed in [11] to estimate the traveled distance by walking accurately. The algorithm counts the number of peaks in the measured signal by the smartphone’s accelerometer. The next step is to detect the step-length, which varies from one step to another. Many adaptive algorithms have been designed to count the footsteps based on LSM (Lifestyle modification). These approaches rely on measuring the movement by a 3-axis accelerometer.

 The proposed designs can enhance the step detection accuracy using step amplitude with accuracies, which can reach up to 99%. In [12], two adaptive algorithms have been proposed to count human steps using only the gyroscope. Accordingly, the Fast Fourier Transform (FFT) was applied to the measured data to obtain real-time walking frequency. The proposed algorithms’ average accuracy ranged from 95% to 97%, considering different walking speeds. Further, the step counting based on the smartphone’s accelerometer has been developed in Indoor Positioning System as proposed in [5]. The approach relies on pattern recognition for step detection and counting. Different scenarios for the smartphone placement and the number of steps higher than one hundred steps have been considered in the validation stage. The result showed high accuracy regardless of the smartphone position. In many step counting approaches, the non-invasive option depends on utilizing the accelerometer to determine the arm movement like a seizure sufferer. In these approaches, the algorithm depends on employing low-power, embedded microcontroller devices in real-time, and they are not intrusive to the patient’s life. Therefore, they are less likely to become non-compliant with monitoring [13]. These approaches are applied in wireless biomedical networks that attempt to monitor patients in a completely non-invasive, non-intrusive manner for a specific condition. Nowadays, the Global Positioning System (GPS) is employed to detect and count the steps outdoor. The GPS showed low accuracy in indoor scenarios due to the indoor equipment’s electromagnetic interference and the building structures [14]. Therefore, the PDR and smartphone’s sensors have been integrated to detect and count the steps accurately in indoor scenarios as in [15].

The power consumption of steps counting algorithms is one of the research topics, especially in smartphones with small battery capacity. In [16], the accelerometer Tap Interrupt algorithm was used to reduce power consumption. The accuracy and measured power consumption at the system level have been compared with a periodic sensor-reading algorithm. The tap interrupt approach presented a lifetime of the battery that is 175 % longer than that of a non-gyroscope 30 ms polling method. The battery life can be extended to 863 % by putting both the processor and the gyroscope in a sleep mode during most operating time. The average power consumption may be reduced by reducing the wake-up frequency from the sleep state and shortening the processing time at each wake-up. Recently, machine learning algorithms have been introduced for step length estimation based on the smartphone’s sensors. Utilizing these tools aims to improve the steps detection, counting, and step length estimation accuracy.

In [1], the neural network is implemented in a multi-mode intelligent recognition approach based on the smartphone’s sensors. The empirical results presented a maximum positioning error lower than 1% of the total path distance. In [17], an adaptive algorithm has been proposed to enhance the steps counting accuracy in indoor positioning services. The algorithm aims to solve the limitations by introducing four mains parameters. These parameters include the minimal peak distance, minimal peak prominence, thresholding, and vibration elimination. The algorithm presented an improved average accuracy of 97%. Also, the results were better than the results obtained by commercial steps counting applications. This paper aims to introduce an algorithm to obtain accurate and robust step counting for indoor applications. The results of this work will be compared with state of the art to validate the followed approach.

3. Methodology

In this work, the smartphone accelerometer is used to collect the acceleration value during human movement. The collected data is transferred to the MATLAB drive using an application installed on the users’ smartphones, called “MATLAB on mobile.” MATLAB on mobile offers accessibility on the available sensors in the user smartphone. The obtained data by the accelerometer of the smartphone include four parameters. The first parameter represents the timestamp values, where it will indicate the (date, time in Hours: Minutes: Seconds). The second parameter represents acceleration values on the X-axis. The third parameter defines the acceleration on the Y-axis, and the fourth parameter represents the acceleration on the Z-axis. Most of the available accelerometer modules measure the value of acceleration quantity as a vector, and many modules can detect both linear and angular acceleration [18]. Angular acceleration can be defined as the time rate of change in angular velocity.

In contrast, the linear acceleration is the time rate of change in linear velocity. In this work, only the linear acceleration vector is used to estimate the number of steps elapsed. The angular acceleration caused by the human steps has a small value and can be neglected. Hence, the linear acceleration within a short period can be calculated as follows according to [18]:

                                                               

where a is the acceleration in [m/s2], ∆v represents the change in velocity in [m/s], ∆t is the time interval in [s]. The accelerometer is used to measure the linear acceleration on the x-axis, y-axis, and z-axis independently. It is hard to predict the accelerometer’s orientation every time a user operates the count steps functionality. Therefore, the acceleration vector is converted at each time point into an overall scaler value. Hence, Acceleration values will be determined like human walking or running regardless of the accelerometer’s orientation. The overall acceleration value is calculated as the square root of three acceleration values, as expressed by equation (2) as in [11].

                                                          

Indeed, the gravitational force affects the acceleration value due to the architecture of the accelerometer module. So, it is hard to estimate the axis affected by gravity since it depends on the smartphone’s orientation when it is carried by hand or placed in the pocket. Fig.1 depicts the acceleration signals of the three axes. Therefore, the gravitational has been removed from the overall acceleration signal as follows.

Figure 1: Acceleration values on X, Y, and Z-axis,

Figure 2: Sum of Acceleration Vectors of X, Y, and Z-axis after subtracting the mean value

The human steps generate little height peaks in the acquired acceleration data. These peaks have limited heights, which might vary depending on the movement’s behavior while walking, as shown in figure 2. Also, electromagnetic interference can turn the measured signal into a noisy signal. This noise might result from the surrounding appliances. Therefore, finding maximum local peaks over a specifically tuned threshold can be employed to estimate the number of detected steps.

 The previous stage can be fulfilled by generating an envelope function MATLAB, which is determined using spline interpolation over local maxima separated by at least the samples (np). The number of samples (np) can be calculated using MATLAB. Consequently, the unwanted vibrations and fake steps are removed, making the steps counting much more accessible, as depicted in figure 3.

Figure 3: Applying the envelope function on the measured signal to remove the noise and eliminate the vibrations.

In this approach, it is found that the main parameter which impacts the estimation’s accuracy is the threshold definition. This threshold depends on the sampling rate, the step rate, and the average of the orthogonal accelerations’ envelope function. Therefore, the threshold   is defined by equation 4.

 

where   represent the upper peaks envelope, d is a correction factor, np is the number of samples, and it is defined as follows:

                                                          

In this work, the step rate  is assumed to equal five steps per second. This assumption valid since this value represents the average of the human steps per second. The sampling period  has been calculated using the new signal data’s timestamp by finding the difference between every two values in seconds.

The segregation approach in this work is performed by generating a new signal based on the envelope function, which returns the upper limit for the average of the measured accelerations signals to remove the impact of vibrations and noise to ease counting the number of the steps, as shown in Fig.3 in red. This transformation will lead to an accurate detection process. The next step is to find the maximum difference value to represent the sampling period and is given by equation (6).

Comparing the peaks of the final acceleration signal  obtained by the envelope function with the threshold  will estimate the number of steps over the path length. The constraint which must be fulfilled to count the number of peaks higher than the calculated threshold can be expressed mathematically by

The stages and the procedures of the proposed algorithm for steps counting purposes are summarized in Table 1.

Table 1: Proposed Algorithm steps.
Proposed Algorithm Steps

1.       Collect

2.       Calculate  and

3.       Define step rate

4.       Calculate the sampling period , and it is defined as  for  where k is the number of samples.

5.       Calculate the sampling rate as

6.       Calculate

7.       Apply envelope function on  to return the upper peaks envelope  .

8.       Define the threshold as follows:

 

9.       Count the peaks   for

10.    Display the step count if finished

4. Results and Discussion

The experiments were conducted at a public institution, which contains many electronic devices. These devices radiate electromagnetic noise, which interferes with measured data. The accelerometer of Huawei P30 has been used to collect the measurement data. Four different scenarios have been considered in this work and summarized in Table 2. The position of the smartphone during the experiments is depicted in figure 4.

Table 2: The symbols of the activities in the empirical scenarios.

Symbol Activity
A Walking at varying speeds with the smartphone is carried by the hand
B Walking at varying speeds with the smartphone is placed in the Jacket pocket
C Walking at varying speeds with the smartphone is placed in the trousers’ front pocket
D Running at varying speeds with the smartphone is carried by the hand

Figure 4: The position of the smartphone in the experimental scenarios.

4.1. Steps Counting During Different Daily Activities

In this part, the accuracy of the proposed algorithm for steps counting during different daily activities is investigated. The accuracy of steps detection can be expressed as follows:

                               

where Se is the number of the estimated steps, and Sa is the actual step number. Therefore, ten experiments with different speeds and path lengths have been considered for each case study, as summarized in Table 3. The algorithm could detect the number of steps with an average accuracy higher than 99% for normal walking when the smartphone is carried by the participant’s hand. The miscount was only for one or a maximum of two steps regardless of the path length. In the next scenario, the smartphone is placed horizontally in the pocket of the participant’s jacket. The results presented an average accuracy of about 98%. The third scenario considered putting the smartphone in the front pocket of the participant’s trouser.

The result showed a reduction in the average accuracy due to the smartphone’s position, and it was around 96.7%. Finally, the running activity has been investigated, considering the smartphone is carried by the participant’s hand. The average accuracy of the different tested scenarios is depicted in figure 5. The proposed algorithm showed an average accuracy of 96.9%. The algorithm presented a reduction of 1% accuracy than the standard walking scenario. figure 6 depicts the detected steps and actual steps in the different tested scenarios. In figure 6(a), the number of the detected steps was 19, which is lower than the actual steps by one step in scenario A. This error might result from miscounting one of the real steps by the proposed algorithm due to the set threshold value. figure 6(b) depicts the proposed algorithm’s ability to detect the exact number of the actual steps with zero error.

Table 3: Comparison between the actual steps number and the detected steps during different scenarios based on the proposed algorithm.

Test Scenarios
Exp. No. Actual Steps A B C D
1 10 10 11 9 11
2 20 19 20 21 21
3 30 29 30 29 29
4 40 40 39 39 40
5 50 50 51 51 51
6 60 60 59 60 61
7 70 70 70 73 72
8 80 80 82 80 81
9 90 91 88 92 92
10 100 100 100 96 103

The smartphone placement in the trouser pocket might lead to unwanted vibration, leading to counting more steps than the number of the actual steps, as depicted in figure 6 (c). In the running scenario, the error might result during the transition from the movement to still during the experiments, increasing the number of the detected steps, as shown in figure 6 (d).

Figure 5: The average accuracy of the ten experiments for each experimental scenario

4.2. Comparison with other Pedometers

In this section, the proposed algorithm has been investigated in terms of its accuracy compared to other pedometers. Therefore, two Android platform applications have been used to detect the number of steps during normal walking and running activity. Also, a HUAWEI Watch GT-731 is used to validate the proposed approach.  The first application was Pedometer by King Brain Inc., and the second application was a Pedometer for Walking. Both applications are available on the google play store. The tests have been conducted under the same conditions to validate the comparison study. The proposed algorithm results showed improved detection compared to other methods with at least 3%.

Figure 6: Steps detection considering different scenarios. (a) during normal walking and the smartphone is carried by hand; (b) during normal walking and the smartphone is placed in the right Jacket pocket; (c) during normal walking where the smartphone is placed in the left front pocket of the trouser; (d) during running and the smartphone is carried by hand.

Figure 7: The average accuracy of the proposed algorithm compared to Android applications and HUAWEI Watch GT-731.

The average accuracy of the HUAWEI Watch GT-731 was in second place, with 96.12% for the typical walking scenario and 93.73% for the running scenario. It is worth to mention here the HUAWEI watch does not utilize the smartphone accelerometer, which is the case for the other applications. The result of this study are depicted in figure 7.

5. Conclusion

This work aims to propose a robust algorithm for step detection with high accuracy for indoor systems.  Mainly, the proposed algorithm will collect the acceleration data from the smartphone’s accelerometer. In the proposed algorithm, a new signal based on the envelope function has been generated to return the upper limit for the average of all measured accelerations signals. The previous phase will remove the impact of vibrations and noise, and it will ease counting the number of steps and obtaining accurate results. It is found that the setting of the threshold will affect the accuracy of the detection process. Therefore, a new formula for the set threshold was created based on the acceleration signals’ envelope and the number of samples. The proposed algorithm has been investigated for two case scenarios: the normal walking scenario and the running scenario considering different smartphone’s position — the obtained accuracy based on the proposed algorithm higher than 97% for all considered scenarios, as summarized in Table 4. The results of the proposed approach presented improved accuracy compared to other works. Finally, the proposed algorithm can be used for online and offline step counting with a maximum step rate of 5 steps per second. The sampling rate can be set from 50 Hz to 100 Hz.  The threshold’s value depends on the measured accelerations signal and the correction factor.

Table 4: Comparison of the average accuracy between the proposed algorithm and state of the art.

Avg. Accuracy

(Normal Walk)

Avg. Accuracy

(Running)

Proposed Algorithm 99.06% 96.87%
[4] 96.5% N.A
[6] 93% N.A
[12] 96.6% N.A
[5] 94% 78.3%
[3] 93.7% N.A

Conflict of Interest

The authors declare no conflict of interest.

  1. L. Xu, Z. Xiong, J. Liu, Z. Wang, Y. Ding, “A novel pedestrian dead reckoning algorithm for multi-mode recognition based on smartphones,” Remote Sensing, 11(3), 2019, doi:10.3390/rs11030294.
  2. W. Wu, “Research on Algorithm Design and Implementation of Counting Steps Based on Mobile Phone Sensor,” 148(Wartia), 71–74, 2017, doi:10.2991/wartia-17.2017.14.
  3. X. Kang, B. Huang, G. Qi, “A novel walking detection and step counting algorithm using unconstrained smartphones,” Sensors (Switzerland), 18(1), 2018, doi:10.3390/s18010297.
  4. F. Gu, K. Khoshelham, J. Shang, F. Yu, Z. Wei, “Robust and accurate smartphone-based step counting for indoor localization,” IEEE Sensors Journal, 17(11), 3453–3460, 2017, doi:10.1109/JSEN.2017.2685999.
  5. J. Santos, A. Costa, M.J. Nicolau, “Autocorrelation analysis of accelerometer signal to detect and count steps of smartphone users,” 2019 International Conference on Indoor Positioning and Indoor Navigation, IPIN 2019, 2019, doi:10.1109/IPIN.2019.8911755.
  6. D. Salvi, C. Velardo, J. Brynes, L. Tarassenko, “An Optimised Algorithm for Accurate Steps Counting from Smart-Phone Accelerometry,” Proceedings of the Annual International Conference of the IEEE Engineering in Medicine and Biology Society, EMBS, 2018-July, 4423–4427, 2018, doi:10.1109/EMBC.2018.8513319.
  7. K. Tran, T. Le, T. Dinh, “A high-accuracy step counting algorithm for iPhones using Accelerometer,” 2012 IEEE International Symposium on Signal Processing and Information Technology, ISSPIT 2012, 213–217, 2012, doi:10.1109/ISSPIT.2012.6621289.
  8. G. Rodríguez, F.E. Casado, R. Iglesias, C. V. Regueiro, A. Nieto, “Robust step counting for inertial navigation with mobile phones,” Sensors (Switzerland), 18(9), 1–21, 2018, doi:10.3390/s18093157.
  9. M.S. Pan, H.W. Lin, “A step counting algorithm for smartphone users: Design and implementation,” IEEE Sensors Journal, 15(4), 2296–2305, 2015, doi:10.1109/JSEN.2014.2377193.
  10. W.W. Myo, W. Wettayaprasit, P. Aiyarak, “A more reliable step counter using built-in accelerometer in smartphone,” Indonesian Journal of Electrical Engineering and Computer Science, 12(2), 775–782, 2018, doi:10.11591/ijeecs.v12.i2.pp775-782.
  11. A. Abadleh, E. Al-Hawari, E. Alkafaween, H. Al-Sawalqah, “Step detection algorithm for accurate distance estimation using dynamic step length,” Proceedings – 18th IEEE International Conference on Mobile Data Management, MDM 2017, 324–328, 2017, doi:10.1109/MDM.2017.52.
  12. X. Kang, B. Huang, R. Yang, G. Qi, “Accurately counting steps of the pedestrian with varying walking speeds,” Proceedings – 2018 IEEE SmartWorld, Ubiquitous Intelligence and Computing, Advanced and Trusted Computing, Scalable Computing and Communications, Cloud and Big Data Computing, Internet of People and Smart City Innovations, SmartWorld/UIC/ATC/ScalCom/CBDCo, 679–686, 2018, doi:10.1109/SmartWorld.2018.00134.
  13. G.L. Santos, P.T. Endo, K.H. de C. Monteiro, E. da S. Rocha, I. Silva, T. Lynn, “Accelerometer-based human fall detection using convolutional neural networks,” Sensors (Switzerland), 19(7), 1–12, 2019, doi:10.3390/s19071644.
  14. Lai, J. H., Nai, L., Suzumura, T., & Xia, Y. (2018). U.S. Patent No. 10,136,265. Washington, DC: U.S. Patent and Trademark Office.
  15. A. Wang, X. Ou, B. Wang, “Improved Step Detection and Step Length Estimation Based on Pedestrian Dead Reckoning,” in 2019 IEEE 6th International Symposium on Electromagnetic Compatibility (ISEMC), 1–4, 2019.
  16. S.Y. Kim, G.I. Kwon, “Interrupt-Based Step-Counting to Extend Battery Life in an Activity Monitor,” Journal of Sensors, 2016, 2016, doi:10.1155/2016/5824523.
  17. V.T. Pham, D.A. Nguyen, N.D. Dang, H.H. Pham, V.A. Tran, K. Sandrasegaran, D.T. Tran, “Highly accurate step counting at variouswalking states using low-cost inertial measurement unit support indoor positioning system,” Sensors (Switzerland), 18(10), 2018, doi:10.3390/s18103186.
  18. H. Crew, The Principles of Mechanics, BiblioBazaar, LLC, 43-45, 2008.

Citations by Dimensions

Citations by PlumX

Google Scholar

Scopus