UBC Faculty Research and Publications

Introducing GaitLib : a library for real-time gait analysis in smartphones Wu, Michael Ming-An; Schneider, Oliver Stirling; Karuei, Idin; Leong, Larissa; MacLean, Karon May 28, 2014

You don't seem to have a PDF reader installed, try download the pdf

Item Metadata


52383-gaitlib-paper.pdf [ 1.03MB ]
JSON: 52383-1.0050993.json
JSON-LD: 52383-1.0050993-ld.json
RDF/XML (Pretty): 52383-1.0050993-rdf.xml
RDF/JSON: 52383-1.0050993-rdf.json
Turtle: 52383-1.0050993-turtle.txt
N-Triples: 52383-1.0050993-rdf-ntriples.txt
Original Record: 52383-1.0050993-source.json
Full Text

Full Text

Introducing GaitLib:A Library for Real-time Gait Analysis in SmartphonesMichael M.A. Wumike.wu@alumni.ubc.caOliver S. Schneideroschneid@cs.ubc.caIdin Karueiidin@cs.ubc.caLarissa A. Leonglarissa.leong@alumni.ubc.caKaron E. MacLeanmaclean@cs.ubc.caDepartment of Computer ScienceUniversity of British ColumbiaVancouver, CanadaABSTRACTModern smartphones are pervasive, powerful, and richly en-dowed with sensors. These have recently enabled smartphoneuse for gait analysis, a powerful resource for many appli-cations including biometric identification and context-awareapps that motivate exercises. However, there is little supportfor software R&D with mobile gait analysis beyond basicsensing. Through a participatory design process, we devel-oped GaitLib, a library for real-time gait analysis in smart-phones. With on-board accelerometers and other sensors,GaitLib supports both cadence estimation and gait classifi-cation. The library is implemented on the Android platform,using Weka as the classification engine while supporting cus-tomizable gait analysis algorithms. An end user who partic-ipated in the design team used successive versions of the li-brary in a series of studies, providing design input which wasused to improve the library’s functionality and usability. Thislibrary can support and stimulate future research in gait anal-ysis and the development of innovative applications.Author Keywordsopen-source library; mobile; cadence; gait classification;AndroidINTRODUCTIONAs smartphones become more powerful and well resourced,they are increasingly present in our day-to-day life. Thispervasiveness means context-aware applications, such as rec-ognizing attributes in the wearer’s gait, have great potential.Gait analysis plays an important role in, for example, medi-cal monitoring [2], user identification to improve security [4],and exercise applications [3].However, few mobile apps use gait information intelligentlybeyond basic sensing. This is in part due to the absence ofany general gait analysis tools for developers, which makesdoing analysis of any sophistication very challenging. Con-sequently, many applications of gait classification remain un-explored, given the limited resources of most mobile app de-velopment teams and academic researchers.In this paper, we introduce GaitLib, an easy-to-use libraryfor real-time gait analysis on smartphones. GaitLib currentlyFigure 1. GaitLib can be used in the implementation of smartphoneapps, smartwatch apps, Arduino programs, etc. Arrows indicate flowof real-time cadence and gait data; wireless connections are shown withdotted lines.supports two challenges in gait analysis: cadence estima-tion and gait classification. We provide a default algorithmfor each, but support easy addition of alternative algorithms.This extensibility gives developers the flexibility to customizethe approach they take to responding intelligently to users’gait. GaitLib is open-sourced and ready for development oncommercially-available Android devices.GaitLib was inspired by the need of our own group to reusealgorithms we developed for spatio-temporal guidance andexergame support. It was developed in a participatory designapproach wherein architecture and development team mem-bers (referred to here as Dev) supported another author (theend-user member, or EU) who was extensively consulted onthe design. We strove to make GaitLib robust, easy-to-useand extensible; using the library ourselves – a.k.a. “dogfood-ing”, let us achieve this.Prior to GaitLib, EU developed one of the default algorithms,RRACE [8] for cadence detection, and then used RRACE insubsequent experiments as a measurement for ground truth.During these experiments, EU used an earlier version ofGaitLib to make his job easier and provided feedback to Dev.Later, EU used an updated version of GaitLib to build a demofor a conference. After the demo was built and piloted, amember of Dev conducted an open-ended post interview toget an idea of how well GaitLib worked for EU.1We will begin by discussing related studies that we consultedduring the design of GaitLib and the novelty of GaitLib oversimilar systems. Then, we will detail our approach and de-scribe the architecture of the library, followed by an overviewthe functionalities and the customizable features. We willconclude this paper with a discussion of the performance andusability of the library and some of our planned future works.RELATED WORKThe three main types of sensor technologies that have beenused in systems for gait analysis are cameras and machinevision, floor sensors, and wearable sensors [4]. Methods in-volving wearable sensors began by attaching multiple sen-sors to specific parts of user’s body [1], and evolved to car-rying a single three-axis accelerometer mounted on a cellphone, where the accuracy of gait classification (processedon a server) reached 80% [7]. Smartphone’s on-board ac-celerometers have been shown to achieve accuracy compa-rable to that of conventional standalone accelerometers [10].Thus, smartphones equipped with accelerometers are suitablefor gait analysis.Real-time on-device cadence estimation and gait classifica-tion were shown to be feasible in several studies. Using asingle accelerometer mounted on the waist as the sensor, sev-eral gait cycle parameters, including cadence, can be esti-mated by an on-device PIC microcontroller in real time [13].Gait classification was also achieved with high accuracy andorientation-independence [14], which is an important factorfor making gait recognition on mobile phones practical.The task of gait classification has been widely studied andthoroughly reviewed within a structured framework [11].Two groups have developed systems for activity and gait clas-sification on mobile phones [5, 12]. They used algorithmsthat allow the systems to build classifier models and performclassification in real time on a smartphone. Unlike GaitLib,theses systems are not development tools that software devel-opers and researchers can readily use for their own projects.APPROACHOur approach centered around requirements gathering and it-erative implementation of a tool to support EU, as a proxy foruses in future research planned by our group and by collabo-rators. EU was involved in the initial requirements gatheringand provided feedback in each development iteration.Key Requirements Gathered and AddressedCadence EstimationCadence is the measure of one’s step rate, in steps per sec-ond. This information can loosely categorize the user’s activ-ity. GaitLib also takes into account the overall speed at whichthe user is moving, and from cadence and speed, stride lengthand distance can be determined.Gait ClassificationThe goal of gait classification is to recognize the user’s cur-rent gait and infer the current activity performed by the user.This provides a more specific description about the user’sstate than cadence value. Given a list of gaits and a corre-sponding classifier model, GaitLib performs classification onthe device and returns the result.FilteringIn signal processing, filtering is a technique that modifies theoriginal signal to extract properties of the signal. GaitLib sup-ports applying filters to the cadence values so that developerscan further fine-tune the result.Real-timeGaitLib provides gait analysis at a real-time latency suitablefor interactive applications. Sensor data are continuously re-ceived and cached, while calculations and analyses are per-formed at a tunable sampling interval, generally around 1 sec-ond.ExtensibilityBesides custom filters, GaitLib supports using alternativeclassifier models for gait classification and different algo-rithms for cadence estimation. Developers can build custommodels that are tailored to their specific needs while still us-ing GaitLib’s framework and low-level sensor management.Development PlatformFor its flexibility with OS accesses and compatibility withmachine learning packages, we chose Android as the firstdevelopment platform on which to implement the library.GaitLib interacts with Android to receive data from the sen-sors and to read and write files in the device storage. The clas-sification algorithms are provided by Weka for Android [9],an adapted version of Weka 3: Data Mining Software [6].TestingGaitLib employs unit testing for internal functions. We builtan example application to test for interactive scenarios (e.g.,receiving sensor data) and EU provided real-world testing.LIBRARY ARCHITECTUREIn this section, we present the architecture of the system. Theoverall structure of GaitLib is shown in Figure 2.Primary ClassesThe main class in GaitLib is GaitAnalysis. It han-dles starting and stopping gait analysis, defining parameters,directly accessing latest results of cadence estimation andgait classification. It contains a CadenceDetector anda GaitClassifier, which are responsible for estimatingcadence and classifying gait, respectively.ExtensibilityThe CadenceDetector and GaitClassifier classesare abstract. They contain all of the functions except thosethat are specific to the algorithms. Beyond the two includeddefault implementations, additional custom algorithms can beintegrated by extending one of the abstract classes.IFilter InterfaceGaitLib supports filtering cadence values with an IFilterinterface, which can be added through GaitAnalysis.2Figure 2. Class diagram of GaitLib.GaitLib contains a number of frequently-used filters, such asmean filter and median filter. User can also define customfilters by implementing the IFilter interface.Sensor Data ProcessingThe SignalListener in GaitLib is used to re-ceive data from the device’s accelerometer, gyroscope,and location services. Based on the window size,SignalListener caches recent sensor readings, and thenCadenceDetector and GaitClassifier can retrievethe values as input to their algorithms.Logging ComponentRelevant classes implements the ILoggable interface tofacilitate logging of the raw sensor data and the results ofcadence estimation and gait classification. The logs are ex-ported as CSV files to the device storage by the logger.EXAMPLE APPLICATIONIn this section, we describe the workflow of setting up an ap-plication that uses GaitLib. Suppose Jim wants to create anapplication that represents the user’s gait by playing a differ-ent sound clip for each identified gait at the frequency deter-mined by user’s cadence.In a service of the Android app, Jim creates aGaitAnalysis object. Then, he registers itsSignalListener with Android’s sensor manager.Next, he defines the actions to take on the cadence and gaitFigure 3. Left: the example app showing the current cadence and gait.Right: a demo app sending cadence via network with parameter control.values received through a listener; in this case, he sends thevalues to another service that plays the sound clips and hedisplays the values on the screen (Figure 3). Finally, he startsgait analysis by calling the method in GaitAnalysis.By defining other actions on the cadence and gait values re-ceived from GaitLib, developers can create applications thatsend the real-time information to external devices or use theinformation within the app (Figure 1).CUSTOMIZABLE FEATURESTo personalize the gait classification, or to classify using analternative set of features, developers can build custom clas-sifier models to replace the default model. First, use the com-panion GaitLogger app to record user’s gait for different ac-tivities, then generate the features to be used for classification.Finally, train the model in Weka and load it onto the device.Figure 4 overviews this workflow.In addition to a custom classifier model, to use an alternativefeature set for classification, developers need to implementthe algorithms for feature extraction and classification in aconcrete GaitClassifier. Similarly, developers can im-plement additional concrete CadenceDetector to replacethe default cadence estimation algorithm.PERFORMANCE AND USABILITYPerformance: The default algorithms’ performance was eval-uated in [8, 11], and generally found to be competitive withthe reported state of the art. We informally tested the powerconsumption of the example application, which uses thesetwo algorithms, on three Galaxy Nexus devices and observedthat the app consumed 45% more power than idling.Usability: Beyond addressing all raised concerns, we eval-uated GaitLib’s usability through a post interview with ourend-user team member (EU).Figure 4. Workflow of training alternative classifier model.3EU used the library in two projects. In the first, he modifiedthe example app to record cadence data for two related exper-iments, tweaked the window size, double checked the sam-pling rate, and modified the UI to keep track of the last 10cadence values (for visibility and verification). He describedthat it only took “a day or half a day” to become familiarwith the library. EU used 4 phones for additional accuracy.He reported the problems he encountered, including severalcrashes, to the development team. In retrospect, most of hiseffort was spent managing and analyzing the collected data,not setting up the application. EU said that without the li-brary, he wouldn’t have been able to run the experiments ashe did, because the library let him make his own app withoutimplementing the algorithm from scratch.In his second project, EU used an updated version of GaitLibto create a demo for his work. He encountered none of theissues he had encountered before. Although we haven’t con-firmed the reasons for the earlier crashing on his app, we ex-pect it is related to the operating system attempting to reducepower consumption when the screen is off.CONCLUSION AND FUTURE WORKIn this paper, we presented GaitLib, a library for real-timemobile gait analysis on the Android platform. It supports de-tecting cadence and classifying gait continuously in real time,and it is extensible to incorporate alternative algorithms anddifferent classifier choices. We developed the library througha participatory design approach, in which an author, primarilyan end user, provided input in the design and gave feedbackas he used the library in two occasions. Overall, it is an easy-to-use tool for developers to apply in many application areas,such as apps that motivate exercise and ones that communi-cate user’s context to external devices.GaitLib, along with user guides and example applications, isopen-sourced and publicly available1. Future work includestesting GaitLib on a variety of Android devices with differ-ent sensor specifications to ensure consistency and robust-ness. The classifier model training process could be furthersimplified, e.g., adding support for training simple classifiermodels on the device. A built-in user profile managementcould be beneficial as, for example, the average stride lengthof a person can be used in estimation of speed when GPS isunavailable. Platform support could be expanded to iOS andWindows Phone for app developers to provide seamless ex-perience of their products across different devices.ACKNOWLEDGEMENTSThis work was funded in part by the Natural Sciences andEngineering Research Council of Canada (NSERC).1https://github.com/m-wu/gaitlibREFERENCES1. Bao, L., and Intille, S. Activity Recognition fromUser-Annotated Acceleration Data. In PervasiveComputing, A. Ferscha and F. Mattern, Eds. SpringerBerlin / Heidelberg, 2004, 1–17.2. Begg, R. K., Palaniswami, M., Owen, B., and Member,S. Support vector machines for automated gaitclassification. IEEE transactions on bio-medicalengineering 52, 5 (May 2005), 828–38.3. Consolvo, S., Klasnja, P., McDonald, D. W., Avrahami,D., Froehlich, J., LeGrand, L., Libby, R., Mosher, K.,and Landay, J. A. Flowers or a robot army? In Proc.UbiComp ’08, ACM Press (Sept. 2008), 54.4. Derawi, M. O., Nickel, C., Bours, P., and Busch, C.Unobtrusive User-Authentication on Mobile PhonesUsing Biometric Gait Recognition. In IIH-MSP 2010,IEEE (Oct. 2010), 306–311.5. Frank, J., Mannor, S., and Precup, D. Activityrecognition with mobile phones. In Machine Learningand Knowledge Discovery in Databases. Springer Berlin/ Heidelberg, 2011, 630–633.6. Hall, M., National, H., Frank, E., Holmes, G.,Pfahringer, B., Reutemann, P., and Witten, I. H. TheWEKA data mining software: an update. SIGKDDExplorations 11, 1 (2009), 10–18.7. Iso, T., and Yamazaki, K. Gait analyzer based on a cellphone with a single three-axis accelerometer. In Proc.MobileHCI ’06, ACM Press (2006), 141.8. Karuei, I., Schneider, O. S., Stern, B., Chuang, M., andMacLean, K. E. Rrace: Robust realtime algorithm forcadence estimation. Pervasive and Mobile Computing(2013).9. Marsan, R. J. Weka for Android, 2011.https://github.com/rjmarsan/Weka-for-Android.10. Nishiguchi, S., Yamada, M., Nagai, K., Mori, S.,Kajiwara, Y., Sonoda, T., Yoshimura, K., Yoshitomi, H.,Ito, H., Okamoto, K., et al. Reliability and validity ofgait analysis by android-based smartphone.Telemedicine and e-Health 18, 4 (2012), 292–296.11. Schneider, O. S., MacLean, K. E., Altun, K., Karuei, I.,and Wu, M. Real-time gait classification for persuasivesmartphone apps: structuring the literature and pushingthe limits. In Proc. IUI 2013, ACM (2013), 161–172.12. Siirtola, P., and Ro¨ning, J. Recognizing human activitiesuser-independently on smartphones based onaccelerometer data. International Journal of InteractiveMultimedia & Artificial Intelligence 1, 5 (2012).13. Yang, C.-C., Hsu, Y.-L., Shih, K.-S., and Lu, J.-M.Real-time gait cycle parameter recognition using awearable accelerometry system. Sensors (Basel,Switzerland) 11, 8 (Jan. 2011), 7314–26.14. Yang, J. Toward physical activity diary: motionrecognition using simple acceleration features withmobile phones. In Proc. IMCE’09 (2009), 1–9.4


Citation Scheme:


Citations by CSL (citeproc-js)

Usage Statistics



Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            async >
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:


Related Items