CN107462258B - Step counting method based on mobile phone three-axis acceleration sensor - Google Patents

Step counting method based on mobile phone three-axis acceleration sensor Download PDF

Info

Publication number
CN107462258B
CN107462258B CN201710569013.4A CN201710569013A CN107462258B CN 107462258 B CN107462258 B CN 107462258B CN 201710569013 A CN201710569013 A CN 201710569013A CN 107462258 B CN107462258 B CN 107462258B
Authority
CN
China
Prior art keywords
data
peak
trough
calculation window
acceleration
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201710569013.4A
Other languages
Chinese (zh)
Other versions
CN107462258A (en
Inventor
彭琛
韩立新
勾智楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hohai University HHU
Original Assignee
Hohai University HHU
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hohai University HHU filed Critical Hohai University HHU
Priority to CN201710569013.4A priority Critical patent/CN107462258B/en
Publication of CN107462258A publication Critical patent/CN107462258A/en
Application granted granted Critical
Publication of CN107462258B publication Critical patent/CN107462258B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G01MEASURING; TESTING
    • G01CMEASURING DISTANCES, LEVELS OR BEARINGS; SURVEYING; NAVIGATION; GYROSCOPIC INSTRUMENTS; PHOTOGRAMMETRY OR VIDEOGRAMMETRY
    • G01C22/00Measuring distance traversed on the ground by vehicles, persons, animals or other moving solid bodies, e.g. using odometers, using pedometers
    • G01C22/006Pedometers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72448User interfaces specially adapted for cordless or mobile telephones with means for adapting the functionality of the device according to specific conditions
    • H04M1/72457User interfaces specially adapted for cordless or mobile telephones with means for adapting the functionality of the device according to specific conditions according to geographic location
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M2250/00Details of telephonic subscriber devices
    • H04M2250/12Details of telephonic subscriber devices including a sensor for measuring a physical value, e.g. temperature or motion

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Radar, Positioning & Navigation (AREA)
  • Remote Sensing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Human Computer Interaction (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Measurement Of The Respiration, Hearing Ability, Form, And Blood Characteristics Of Living Organisms (AREA)

Abstract

The invention discloses a step counting method based on a three-axis acceleration sensor of a mobile phone, which comprises the following steps: acquiring data, namely acquiring triaxial data of a triaxial acceleration sensor according to a calculation window; data preprocessing, namely, performing average smoothing on the data and solving a resultant acceleration; extracting characteristics, namely respectively extracting the mean value and the variance of data and the number of wave crests of the combined acceleration, clustering the combined acceleration by using a clustering algorithm, and extracting a clustering center as the combined acceleration characteristics; position discrimination, namely classifying the features by using a classification algorithm to obtain class labels; waveform reconstruction, namely segmenting data into quadruples and segmenting the data into complete waves; and (4) step number calculation, namely acquiring a corresponding discrimination threshold according to the category, discriminating the reconstructed data by using the threshold, and adding 1 to the step number of the corresponding category when the condition is met. The step counting method can identify different positions of the mobile phone, is more accurate in step counting and has stronger anti-interference performance.

Description

一种基于手机三轴加速度传感器的计步方法A step counting method based on three-axis acceleration sensor of mobile phone

技术领域technical field

本发明涉及一种基于手机三轴加速度传感器的计步方法,属于消费应用电子技术领域。The invention relates to a step counting method based on a three-axis acceleration sensor of a mobile phone, and belongs to the technical field of consumer application electronics.

背景技术Background technique

随着人民生活水平的提高,人们对如何进行合理的身体锻炼已经越来越重视,对身体状况进行及时监控,及时获取运动数据成为广大热爱运动的群体的基本需求。另一方面,在物联网的蓬勃发展的今天,越来越多的传感器设备被应用到可穿戴设备中。智能手机作为典型的智能可穿戴设备以及智能的监控设备走入了大众的生活中,在智能手机这个移动平台上出现了许多健康监控和运动指导的应用软件,这为获取健康信息提供了有力的物质和技术的支持。计步器就是相关应用的典型例子。With the improvement of people's living standards, people have paid more and more attention to how to carry out reasonable physical exercise. Timely monitoring of physical conditions and timely acquisition of exercise data have become the basic needs of the majority of sports-loving groups. On the other hand, with the booming development of the Internet of Things today, more and more sensor devices are applied to wearable devices. As a typical smart wearable device and smart monitoring device, smartphones have entered the lives of the public. Many applications for health monitoring and exercise guidance have appeared on the mobile platform of smart phones, which provides a powerful tool for obtaining health information. Material and technical support. A pedometer is a typical example of a related application.

目前存在很多统计使用者行走步数的设备,但是它们都有一些缺陷。现有的大多通过加速度传感器获取加速度信号,然后设定简单的阈值判断合加速度中波峰值是否有效,从而实现计步功能。由于传感器采集过程中容易出现伪波峰,该方法可能出现误判,导致计步精度偏低。此外也有利用运动的周期性特点,判断前后两个波的合加速度波形相似度是否在某些阈值范围内等等。由于运动者的运动形式多种多样,比如跑步,行走,同时在运动的过程中,当采集装置放置在身体的不同位置时,加速度变化不同,波形的相似度可能不够高。因此,仅使用合加速度数据以及提取波形的周期性特性进行步数统计容易出现误计或漏计的情况,现有方法还有不足的地方。There are many devices that count the steps taken by the user, but they all have some flaws. Most of the existing ones obtain the acceleration signal through the acceleration sensor, and then set a simple threshold value to judge whether the peak value of the resultant acceleration is valid, so as to realize the step counting function. Since false peaks are prone to appear in the sensor acquisition process, this method may be misjudged, resulting in low step counting accuracy. In addition, it also uses the periodic characteristics of motion to determine whether the similarity of the combined acceleration waveforms of the two waves before and after is within a certain threshold range, and so on. Because the movement forms of the athlete are various, such as running and walking, and during the movement, when the acquisition device is placed in different positions of the body, the acceleration changes are different, and the similarity of the waveforms may not be high enough. Therefore, only using the resultant acceleration data and the periodic characteristics of the extracted waveform to count steps is prone to miscounting or missing counts, and the existing methods still have shortcomings.

发明内容SUMMARY OF THE INVENTION

本发明所要解决的技术问题是提供一种基于手机三轴加速度传感器的计步方法,该方法提取三轴加速度数据以及合加速度数据的特征,利用分类算法识别需要计步的数据,通过重构数据去除伪波峰以及伪波谷带来的影响,此外,识别手机在运动过程中所处在的不同位置,对不同位置的数据设置不同的阈值进行过滤,最终提高计步精准度,具有较高的抗干扰性。The technical problem to be solved by the present invention is to provide a pedometer method based on a three-axis acceleration sensor of a mobile phone. The method extracts the characteristics of the three-axis acceleration data and the combined acceleration data, uses a classification algorithm to identify the data that needs to be counted, and reconstructs the data by reconstructing the data. Remove the influence of false peaks and false valleys, in addition, identify the different positions of the mobile phone during the movement, set different thresholds to filter the data of different positions, and finally improve the accuracy of step counting, with high resistance to intrusive.

本发明为解决上述技术问题采用以下技术方案The present invention adopts the following technical solutions to solve the above technical problems

本发明提供一种基于手机三轴加速度传感器的计步方法,具体步骤如下:The invention provides a step counting method based on a three-axis acceleration sensor of a mobile phone, and the specific steps are as follows:

步骤1,根据设定采样频率与采样时间窗口确定采样计算窗口,采集手机三轴加速度传感器的三轴加速度数据,每个采样计算窗口内的每一轴数据按照采集顺序编号为0,1,…,n-1,其中,n表示每个采样计算窗口内每一个轴的的数据个数;Step 1: Determine the sampling calculation window according to the set sampling frequency and sampling time window, collect the three-axis acceleration data of the three-axis acceleration sensor of the mobile phone, and each axis data in each sampling calculation window is numbered 0, 1, ... according to the collection sequence. ,n-1, where n represents the number of data for each axis in each sampling calculation window;

步骤2,在每个采样计算窗口内,对采集到的三轴加速度数据分别进行平滑处理,并计算平滑后的合加速度;Step 2, in each sampling calculation window, smooth the collected three-axis acceleration data respectively, and calculate the smoothed resultant acceleration;

步骤3,在每个采样计算窗口内,对步骤2中平滑后的三轴加速度数据以及合加速度进行特征提取,其中,提取x轴加速度的平均值xMean和方差xVariance作为x轴数据特征,提取y轴加速度的平均值yMean和方差yVariance作为y轴数据特征,提取z轴加速度的平均值zMean和方差zVariance作为z轴数据特征,提取合加速度波峰个数peakCount作为波峰的出现特征;利用聚类算法将合加速度数据聚成3类,分别对每类合加速度数据求取平均值,并将3个平均值按照由大到小进行排序作为合加速度特征<clusterPeak,clusterMean,clusterThrough>,clusterPeak>clusterMean>clusterThrough;Step 3: In each sampling calculation window, feature extraction is performed on the smoothed three-axis acceleration data and the resultant acceleration in step 2, wherein the mean value xMean and variance xVariance of the x-axis acceleration are extracted as the x-axis data features, and y is extracted. The average value yMean and variance yVariance of the axis acceleration are used as the y-axis data features, the average value zMean and variance zVariance of the z-axis acceleration are extracted as the z-axis data features, and the number of peaks of the composite acceleration peakCount is extracted as the appearance feature of the peak. The resultant acceleration data are grouped into 3 categories, and the average value of each type of resultant acceleration data is obtained respectively, and the 3 average values are sorted from large to small as the resultant acceleration feature <clusterPeak, clusterMean, clusterThrough>, clusterPeak>clusterMean>clusterThrough ;

步骤4,根据步骤3中提取到的特征,判断每个采样计算窗口内采集到的数据的类别;Step 4, according to the feature extracted in step 3, determine the category of the data collected in each sampling calculation window;

步骤5,若步骤4中的判别结果为静止噪声或运动噪声,则舍弃当前采样计算窗口内的数据,否则,对当前采样计算窗口内的合加速度数据进行波形重构;其中,波形重构的方法具体如下:Step 5, if the discrimination result in Step 4 is static noise or motion noise, discard the data in the current sampling calculation window, otherwise, perform waveform reconstruction on the resultant acceleration data in the current sampling calculation window; The method is as follows:

5.1,计算当前采样计算窗口内合加速度的平均值,利用平均值将当前采样计算窗口内的合加速度分割为多个波峰所在区域和波谷所在区域,其中,波峰所在区域与波谷所在区域交替出现;5.1. Calculate the average value of the resultant acceleration in the current sampling calculation window, and use the average value to divide the resultant acceleration in the current sampling calculation window into multiple areas where the peaks are located and the areas where the troughs are located, where the areas where the peaks are located and the areas where the troughs are located alternately appear;

5.2,搜索每一个波峰所在区域,获取当前波峰所在区域中最大的波峰,作为该区域的真波峰peak,并记录真波峰在当前采样计算窗口内对应数据编号peakIndex;5.2. Search the area where each peak is located, obtain the largest peak in the area where the current peak is located, and use it as the true peak of the area, and record the corresponding data number peakIndex of the true peak in the current sampling calculation window;

5.3,搜索每一个波谷所在的区域,获取每个波谷所在区域中最小的波谷,作为该区域的真波谷,同时记录真波谷值在当前采样计算窗口内对应数据编号;5.3. Search the area where each trough is located, obtain the smallest trough in the area where each trough is located, as the true trough of the region, and record the corresponding data number of the true trough value in the current sampling calculation window;

5.4,真波峰peak与其前最后一个真波谷troughLeft、其后第一个真波谷troughRight以及半波长度halfWaveLength组成重构波形四元组<peak,troughLeft,troughRight,halfWaveLength>,完成一个波形的重构,halfWaveLength=max{|peakIndex-troughIndexLeft|,|peakIndex-troughIndexRight|},troughIndexLeft表示troughLeft在当前采样计算窗口内对应数据编号,troughIndexRight表示troughRight在当前采样计算窗口内对应数据编号;5.4, the true peak peak and the last true trough before it troughLeft, the first true trough troughRight after it, and the half-wave length halfWaveLength form the reconstructed waveform quadruple <peak, troughLeft, troughRight, halfWaveLength> to complete the reconstruction of a waveform, halfWaveLength=max{|peakIndex-troughIndexLeft|, |peakIndex-troughIndexRight|}, troughIndexLeft indicates the corresponding data number of troughLeft in the current sampling calculation window, troughIndexRight indicates the corresponding data number of troughRight in the current sampling calculation window;

步骤6,根据当前采样计算窗口内采集到数据的类别,设定阈值四元组<peakThreshold,troughThreshold,maxWaveLength,minWaveLength>,对步骤5中得到的重构波形进行逐一判决:Step 6, according to the type of data collected in the current sampling calculation window, set the threshold quadruple <peakThreshold, troughThreshold, maxWaveLength, minWaveLength>, and judge the reconstructed waveforms obtained in step 5 one by one:

6.1,根据当前采样计算窗口内采集到数据的类别,从预设阈值四元组中获取对应的阈值四元组<peakThreshold,troughThreshold,maxWaveLength,minWaveLength>,其中,peakThreshold作为真波峰的阈值,troughThreshold作为真波谷的阈值,maxWaveLength以及minWaveLength分别为halfWaveLength的最大可取值以及最小可取值;6.1. According to the type of data collected in the current sampling calculation window, obtain the corresponding threshold quadruple <peakThreshold, troughThreshold, maxWaveLength, minWaveLength> from the preset threshold quadruple, where peakThreshold is the threshold of the true wave peak, and troughThreshold is the threshold value of the true wave peak. The threshold of the true wave valley, maxWaveLength and minWaveLength are the maximum and minimum possible values of halfWaveLength respectively;

6.2,将重构波形的波形四元组<peak,troughLeft,troughRight,halfWaveLength>逐一与阈值四元组进行比较:首先,判断真波峰,若peak>peakThreshold则进入下一步,否则比较下一个重构波形的波形四元组;然后,判断真波谷,若troughLeft<troughThreshold且troughRight<troughThreshold则进入下一步,否则比较下一个重构波形的波形四元组;最后,判断半波长,若halfWaveLength>minWaveLength且halfWaveLength<maxWaveLength则当前重构波形计为一步,且对应数据类别的总步数加一;否则比较下一个重构波形的波形四元组;6.2. Compare the waveform quadruplet <peak, troughLeft, troughRight, halfWaveLength> of the reconstructed waveform with the threshold quadruple one by one: first, determine the true peak, if peak>peakThreshold, go to the next step, otherwise compare the next reconstruction The waveform quadruple of the waveform; then, determine the true valley, if troughLeft<troughThreshold and troughRight<troughThreshold, go to the next step, otherwise compare the waveform quadruple of the next reconstructed waveform; finally, determine the half wavelength, if halfWaveLength>minWaveLength and If halfWaveLength<maxWaveLength, the current reconstructed waveform is counted as one step, and the total number of steps corresponding to the data category is increased by one; otherwise, the waveform quadruple of the next reconstructed waveform is compared;

步骤7,各个采样计算窗口内的步数根据不同数据类别分别相加,即实现计步。Step 7, the number of steps in each sampling calculation window is added according to different data categories, that is, step counting is realized.

作为本发明的进一步优化方案,步骤2中采用平均值平滑法对三轴数据的每一轴数据分别进行平滑处理,平滑公式为:As a further optimization scheme of the present invention, in step 2, the average value smoothing method is used to smooth the data of each axis of the three-axis data, and the smoothing formula is:

Figure BDA0001349139670000031
Figure BDA0001349139670000031

其中,s为预设的平滑窗口大小且为大于零的偶数,ai+j表示平滑前采样计算窗口内编号为i+j的数据,ai′表示平滑后采样计算窗口内编号为i的数据,n表示采样计算窗口内的数据个数。Among them, s is the preset smoothing window size and is an even number greater than zero, a i+j represents the data numbered i+j in the sampling calculation window before smoothing, and a i ′ represents the data number i in the sampling calculation window after smoothing data, n represents the number of data in the sampling calculation window.

作为本发明的进一步优化方案,步骤5中步骤5.1中利用平均值将当前采样时间窗口内的合加速度分割为波峰所在区域和波谷所在区域,具体为:通过判断合加速度是否大于平均值进行分割,当合加速度大于平均值时其所在区域为波峰所在区域,当合加速度值小于平均值时其所在区域为波谷所在区域。As a further optimization scheme of the present invention, in step 5.1, the average value is used to divide the resultant acceleration in the current sampling time window into the area where the peak is located and the area where the trough is located, specifically: by judging whether the resultant acceleration is greater than the average value for segmentation, When the resultant acceleration value is greater than the average value, the region where it is located is the region where the wave crest is located, and when the resultant acceleration value is less than the average value, the region where it is located is the region where the wave trough is located.

作为本发明的进一步优化方案,步骤5.4中当前一个采样计算窗口内最后的合加速度数据中无法重构一个完整波形四元组时,将该部分合加速度数据添加到下一个采样计算窗口的前部,以保证相邻采样计算窗口中计算的连续性。As a further optimization scheme of the present invention, in step 5.4, when a complete waveform quadruple cannot be reconstructed from the last resultant acceleration data in the previous sampling calculation window, the partial resultant acceleration data is added to the front of the next sampling calculation window , to ensure the continuity of calculations in adjacent sampling calculation windows.

作为本发明的进一步优化方案,采样计算窗口的长度windowLength=采样频率f*采样时间窗口的长度N。As a further optimization solution of the present invention, the length of the sampling calculation window windowLength=sampling frequency f*the length N of the sampling time window.

作为本发明的进一步优化方案,步骤4中每个采样计算窗口内采集到的数据的类别的判断方法为:As a further optimization scheme of the present invention, the method for judging the type of the data collected in each sampling calculation window in step 4 is:

4.1,根据数据类别分别采集手机三轴加速度数据,并按照步骤1至3的方法进行特征提取,将提取到的特征作为训练集,其中,数据类别包括a)静止噪声、b)手机在上衣口袋、c)手机在裤子口袋、d)手机在手中时行走、e)手机在手中时跑步、f)手机在其他位置、g)运动噪声;4.1. Collect the three-axis acceleration data of the mobile phone according to the data category, and perform feature extraction according to the methods of steps 1 to 3, and use the extracted features as a training set, where the data categories include a) static noise, b) mobile phone in the jacket pocket , c) mobile phone in trouser pocket, d) walking with mobile phone in hand, e) running with mobile phone in hand, f) mobile phone in other position, g) motion noise;

4.2,构建分类模型,并利用步骤4.1中的训练集对分类模型进行训练学习;4.2, build a classification model, and use the training set in step 4.1 to train and learn the classification model;

4.3,将每个采样计算窗口内采集到的数据提取到的特征输入训练学习后的分类模型,分类模型的输出即为其对应的类别。4.3. Input the features extracted from the data collected in each sampling calculation window into the classification model after training and learning, and the output of the classification model is its corresponding category.

作为本发明的进一步优化方案,步骤4.2中的分类模型为三层神经网络,其中,第一层和第二层的激活函数均为带泄露线性整流函数,第三层采用归一化指数函数softmax函数,采用带动量的随机梯度下降算法对三层神经网络进行训练,损失函数为交叉熵损失函数。As a further optimization scheme of the present invention, the classification model in step 4.2 is a three-layer neural network, wherein the activation functions of the first layer and the second layer are linear rectification functions with leakage, and the third layer adopts the normalized exponential function softmax The stochastic gradient descent algorithm with momentum is used to train the three-layer neural network, and the loss function is the cross entropy loss function.

本发明采用以上技术方案与现有技术相比,具有以下技术效果:Compared with the prior art, the present invention adopts the above technical scheme, and has the following technical effects:

1、本发明方法采集三轴加速度传感器的三轴数据,提取数据特征,借助分类算法进行手机位置状态的判别,可以识别手机在运动过程中所处的不同位置,重构数据识别出完整波,对不同的位置类别分别进行计步,使得计步更加精准;1. The method of the present invention collects the three-axis data of the three-axis acceleration sensor, extracts the data features, and judges the position state of the mobile phone by means of a classification algorithm, which can identify the different positions of the mobile phone during the movement process, and reconstruct the data to identify the complete wave, Step counting is performed for different location categories to make step counting more accurate;

2、本发明方法识别手机在运动过程中所处的不同位置,可以对不同的位置类别进行识别并进行计步,满足使用者对不同应用场景的需求;2. The method of the present invention identifies different positions of the mobile phone during the movement process, and can identify different position categories and perform pedometer counting, so as to meet the needs of users for different application scenarios;

3、本发明方法通过重构数据识别出真正的波峰以及真正的波谷,去除伪波峰以及伪波谷的影响,具有较强的抗干扰性;3. The method of the present invention identifies the real crest and the real trough by reconstructing the data, removes the influence of the false crest and the false trough, and has strong anti-interference;

4、本发明方法基于手机平台,可以利用随身携带的手机作为数据采集、计算、存储和展示设备,普通智能手机中都有三轴加速度传感器,实用性强,具有很强的可移植性。4. The method of the present invention is based on the mobile phone platform, and the portable mobile phone can be used as a data collection, calculation, storage and display device. There are three-axis acceleration sensors in ordinary smart phones, which are highly practical and highly portable.

附图说明Description of drawings

图1为本发明实施例的系统流程图;1 is a system flow chart of an embodiment of the present invention;

图2为本发明实施例的三轴加速度示意图;2 is a schematic diagram of a three-axis acceleration according to an embodiment of the present invention;

图3为本发明实施例的波形重构流程图;3 is a flowchart of waveform reconstruction according to an embodiment of the present invention;

图4为本发明实施例的波谷解析流程图;Fig. 4 is the trough analysis flow chart of the embodiment of the present invention;

图5为本发明实施例的步数计算流程图。FIG. 5 is a flow chart of step count calculation according to an embodiment of the present invention.

具体实施方式Detailed ways

下面结合附图对本发明的技术方案做进一步的详细说明:Below in conjunction with accompanying drawing, the technical scheme of the present invention is described in further detail:

如图1所示,给出了本发明实施例的系统流程,包括以下步骤:As shown in FIG. 1 , a system flow of an embodiment of the present invention is given, including the following steps:

101、数据采集:包括设置手机三轴加速度传感器的采样频率以及采样时间窗口,计算采样计算窗口,并存储采集到的三轴加速度的值。每个采样计算窗口内的每一个轴的数据按照采集顺序编号为0,1,…,n-1,其中,n表示每个采样计算窗口内每一个轴的数据个数。101. Data acquisition: including setting the sampling frequency and sampling time window of the mobile phone triaxial acceleration sensor, calculating the sampling calculation window, and storing the collected triaxial acceleration values. The data of each axis in each sampling calculation window is numbered 0,1,...,n-1 according to the acquisition sequence, where n represents the number of data of each axis in each sampling calculation window.

计算采样计算窗口,公式为:windowLength=f*N。其中,windowLength表示采样计算窗口的总长度,单位为个;f表示采样频率,单位为赫兹;N表示采样的时间长度,单位为秒;举例来说,当f=50赫兹,N=4时,得到windowLength=4*50=200个,此时,当加速度传感器在x轴,y轴以及z轴分别采集到200个对应方向上的数据时,当前计算窗口关闭,将数据传递到下一步骤,开启新的计算窗口接受新数据。Calculate the sampling calculation window, the formula is: windowLength=f*N. Among them, windowLength represents the total length of the sampling calculation window, in units of pieces; f represents the sampling frequency, in Hertz; N represents the time length of sampling, in seconds; for example, when f=50 Hz and N=4, It is obtained that windowLength=4*50=200. At this time, when the acceleration sensor collects 200 data in the corresponding directions on the x-axis, y-axis and z-axis respectively, the current calculation window is closed, and the data is passed to the next step. Open a new calculation window to accept new data.

所述的三轴加速度传感器的三轴如图2所示,分别记为x轴、y轴以及z轴。以屏幕朝上水平放置时的状态为例,所述x轴采集加速度传感器左右运动时该方向加速度变化情况;所述y轴采集加速度传感器前后运动时该方向上加速度变化情况;所述z轴采集加速度传感器上下运动时该方向上加速度变化情况。The three axes of the three-axis acceleration sensor are shown in FIG. 2 , which are respectively denoted as the x-axis, the y-axis and the z-axis. Taking the state when the screen is placed horizontally upwards as an example, the x-axis collects the acceleration changes in this direction when the acceleration sensor moves left and right; the y-axis collects the acceleration changes in this direction when the acceleration sensor moves back and forth; the z-axis collects The acceleration change in this direction when the acceleration sensor moves up and down.

102、数据预处理:包括采用平均值平滑法对101中采集得到数据进行平滑处理。根据预设的平滑窗口系数s对三轴加速度中的x轴加速度、y轴加速度以及z轴加速度分别进行平滑,平滑公式如下:102. Data preprocessing: including smoothing the data collected in 101 by using the average value smoothing method. According to the preset smoothing window coefficient s, the x-axis acceleration, y-axis acceleration and z-axis acceleration in the three-axis acceleration are respectively smoothed. The smoothing formula is as follows:

Figure BDA0001349139670000051
Figure BDA0001349139670000051

其中,s为预设的平滑窗口大小且为大于零的偶数,ai+j表示平滑前采样计算窗口内编号为i+j的数据,ai′表示平滑后采样计算窗口内编号为i的数据,n表示采样计算窗口内的数据个数。Among them, s is the preset smoothing window size and is an even number greater than zero, a i+j represents the data numbered i+j in the sampling calculation window before smoothing, a i ′ represents the data number i in the sampling calculation window after smoothing data, n represents the number of data in the sampling calculation window.

将平滑后的x轴加速度、y轴加速度以及z轴加速度计算合加速度值,公式如下:Calculate the resultant acceleration value from the smoothed x-axis acceleration, y-axis acceleration and z-axis acceleration. The formula is as follows:

Figure BDA0001349139670000052
Figure BDA0001349139670000052

其中,xf、yf、zf分别为平滑后的x轴加速度、y轴加速度以及z轴加速度。Among them, x f , y f , and z f are the smoothed x-axis acceleration, y-axis acceleration, and z-axis acceleration, respectively.

103、特征提取:提取当前计算窗口内加速度的特征,包括:分别提取三轴加速度传感器中x轴,y轴以及z轴加速度值的特征;提取三轴合加速度值的特征,提取波峰的出现特征。103. Feature extraction: extracting the features of the acceleration in the current calculation window, including: extracting the features of the x-axis, y-axis, and z-axis acceleration values in the three-axis acceleration sensor respectively; extracting the features of the three-axis combined acceleration value, and extracting the appearance feature of the wave crest .

分别提取三轴加速度传感器x轴,y轴以及z轴加速度的特征,包括:计算窗口内提取x轴加速度值的平均值xMean以及方差xVariance,分别作为当前计算窗口内x轴方向上运动的大小特征以及混乱程度;类似的,提取y轴加速度值的平均值yMean以及方差yVariance,提取z轴加速度值的平均值zMean以及方差zVariance。提取当前计算窗口内合加速度波峰个数作为波峰的出现特征,记为peakCount;同时,提取三轴合加速度值的特征。Extract the characteristics of the x-axis, y-axis and z-axis acceleration of the three-axis accelerometer respectively, including: the mean value xMean and the variance xVariance of the x-axis acceleration values extracted in the calculation window, respectively, as the size characteristics of the movement in the x-axis direction in the current calculation window and the degree of confusion; similarly, extract the mean yMean and variance yVariance of the y-axis acceleration values, and extract the mean zMean and variance zVariance of the z-axis acceleration values. The number of combined acceleration peaks in the current calculation window is extracted as the appearance feature of the peak, which is recorded as peakCount; at the same time, the feature of the three-axis combined acceleration value is extracted.

提取三轴合加速度值的特征,包括:利用预先设置聚类个数的聚类算法将合加速度数据聚成3类,分别将属于同一类的数据求取平均合加速度值,对得到的3个平均值进行从大到小排序,得到3个聚类中心<clusterPeak,clusterMean,clusterThrough>作为合加速度特征,clusterPeak表示波峰的均值特征,clusterMean表示平均值附近的特征,clusterThrough表示波谷的均值特征。Extracting the characteristics of the three-axis combined acceleration value, including: using a clustering algorithm with a preset number of clusters to cluster the combined acceleration data into three categories, obtain the average combined acceleration value for the data belonging to the same category, and analyze the obtained three The average value is sorted from large to small, and three cluster centers <clusterPeak, clusterMean, clusterThrough> are obtained as the resultant acceleration feature.

提取波峰的出现特征peakCount,计算当前计算窗口内合加速度值中波峰的出现次数。其中的波峰满足如下公式:Extract the peak occurrence feature peakCount, and calculate the number of occurrences of the peak in the combined acceleration value in the current calculation window. where the peaks satisfy the following formula:

ah-1<ah a h-1 <a h

ah+1<ah a h+1 <a h

其中,ah表示采样计算窗口内数据编号为h的合加速度值,ah-1表示采样计算窗口内数据编号为h-1的合加速度值,ah+1表示采样计算窗口内数据编号为h+1的合加速度值。Among them, a h represents the resultant acceleration value of the data number h in the sampling calculation window, a h-1 represents the resultant acceleration value of the data number h-1 in the sampling calculation window, and a h+1 means that the data number in the sampling calculation window is The resultant acceleration value of h+1.

以上构成特征值组The above constitute the eigenvalue group

<xMean,xVariance,yMean,yVariance,zMean,zVariance,peakCount,clusterPeak,clusterMean,clusterThrough>。<xMean,xVariance,yMean,yVariance,zMean,zVariance,peakCount,clusterPeak,clusterMean,clusterThrough>.

104、数据类别的判别:根据提取的x轴的特征,y轴的特征,z轴的特征,合加速度的特征以及波峰的出现特征组成当前采集的计算窗口的特征值组,利用分类算法进行对采集到的数据的类别进行判别。其中,数据的类别包括:a)静止噪声、b)手机在上衣口袋、c)手机在裤子口袋、d)手机在手中时行走、e)手机在手中时跑步、f)手机在其他位置、g)运动噪声,b到f这5种类别表示手机的位置,f是当手机放置于包内等其他位置时的统称。104. Discrimination of data types: According to the extracted features of the x-axis, the features of the y-axis, the features of the z-axis, the features of the resultant acceleration, and the appearance of the wave peaks, the feature value group of the currently collected calculation window is formed, and the classification algorithm is used to classify the data. The category of the collected data is determined. Among them, the categories of data include: a) static noise, b) mobile phone in jacket pocket, c) mobile phone in trouser pocket, d) walking with mobile phone in hand, e) running with mobile phone in hand, f) mobile phone in other location, g ) motion noise, the five categories b to f represent the position of the mobile phone, and f is the general term for when the mobile phone is placed in other places such as a bag.

所述的分类算法,在本发明中使用的是多层神经网络,网络分为3层,第一层和第二层的激活函数为带泄露线性整流函数,第三层采用归一化指数函数softmax函数。在其训练学习的过程中,首先根据不同的类别分别采集相应的三轴数据,进行101、102、103的处理提取特征,然后进行类别标记,即按照a到g的顺序根据所处类别进行独热码编码得到类别标签,将特征数据与对应的类别标签输入到多层神经网络中,采用带动量的随机梯度下降算法进行训练,损失函数为交叉熵损失函数。The classification algorithm used in the present invention is a multi-layer neural network, the network is divided into three layers, the activation functions of the first layer and the second layer are linear rectification functions with leakage, and the third layer adopts a normalized exponential function. softmax function. In the process of training and learning, firstly collect the corresponding three-axis data according to different categories, perform 101, 102, and 103 processing to extract features, and then perform category labeling, that is, according to the order of a to g, according to the category. The category labels are obtained by hot coding, and the feature data and corresponding category labels are input into the multi-layer neural network, and the stochastic gradient descent algorithm with momentum is used for training, and the loss function is the cross entropy loss function.

105、波形重构:根据104中的类别判别结果,当判别结果为a或者g时,表示当前采样计算窗口内的数据为无效数据,舍去当前采样计算窗口内的数据。否则,重构当前采样计算窗口内的数据,计算当前计算窗口内合加速度值的平均值,利用该平均值解析出真波峰和真波谷,重构得到波形四元组,将计算窗口内的数据解析成多个四元组的集合,即可得到重构的多个完整的波形四元组。105. Waveform reconstruction: According to the category discrimination result in 104, when the discrimination result is a or g, it indicates that the data in the current sampling calculation window is invalid data, and the data in the current sampling calculation window is discarded. Otherwise, reconstruct the data in the current sampling calculation window, calculate the average value of the resultant acceleration values in the current calculation window, use the average value to analyze the true peak and true trough, reconstruct the waveform quadruple, and calculate the data in the window By parsing it into a set of multiple quadruplets, multiple complete waveform quadruplets can be obtained.

重构获取波形四元组:计算当前计算窗口内合加速度值的平均值,利用平均值分割出波峰所在区域以及波谷所在区域,当合加速度值大于平均值时,当前所在区域为需要搜索的波峰区域,当合加速度值小于平均值时,当前所在区域为需要搜索的波谷区域;搜索波峰所在区域,获取该波峰区域中最大的波峰,作为当前区域的真正波峰peak,并记录真波峰所在的数据编号peakIndex;搜索波谷所在的区域,获取该波谷区域最小的波谷,作为当前区域的真正波谷。Reconstruction to obtain waveform quadruple: Calculate the average value of the resultant acceleration values in the current calculation window, and use the average value to divide the area where the peaks and troughs are located. When the resultant acceleration value is greater than the average value, the current area is the peak that needs to be searched. area, when the resultant acceleration value is less than the average value, the current area is the trough area to be searched; search the area where the peak is located, and obtain the largest peak in the peak area as the true peak of the current area, and record the data where the true peak is located Number peakIndex; search the region where the trough is located, and obtain the smallest trough in the trough region as the real trough in the current region.

一个完整波由三个区域构成,分别是左波谷区域、波峰区域以及右波谷区域。波峰区域与波谷区域交替出现,从左波谷区域穿越平均值到达波峰区域,波峰区域穿越平均值到达右波谷区域,一个完整波两次穿越平均值。A complete wave consists of three regions, namely the left trough region, the peak region and the right trough region. The crest area and the trough area alternately appear, from the left trough area to cross the average to the peak area, the peak area to cross the average to the right trough area, and a complete wave crosses the average twice.

为了去除伪波峰的影响,定义一个波的真波峰为:在两次穿越平均值中,一个波峰区域内,众多波峰中波峰最大的值,波峰满足如下公式:In order to remove the influence of false peaks, the true peak of a wave is defined as: in the average value of two crossings, within a peak area, the maximum peak value among many peaks, and the peak satisfies the following formula:

ah-1<ah a h-1 <a h

ah+1<ah a h+1 <a h

类似的,定义一个真波谷为:在两次穿越平均值中,一个波谷区域内,众多波谷中取波谷最小的值,波谷满足以下公式:Similarly, a true trough is defined as: in the average value of two crossings, in a trough area, the minimum value of the trough is taken among the many troughs, and the trough satisfies the following formula:

ak-1>ak a k-1 >a k

ak+1>ak a k+1 >a k

其中,ak表示采样计算窗口内数据编号为k的合加速度值,ak-1表示采样计算窗口内数据编号为k-1的合加速度值,ak+1表示采样计算窗口内数据编号为k+1的合加速度值。Among them, a k represents the resultant acceleration value of the data number k in the sampling calculation window, a k-1 represents the resultant acceleration value of the data number k-1 in the sampling calculation window, and a k+1 means that the data number in the sampling calculation window is The resultant acceleration value of k+1.

具体操作包括:在一个波峰搜索区域中,获取波峰的最大值,记录真波峰所在的数据编号,计为peakIndex;类似的,在一个波谷搜索区域中,获取最小的一个波谷,记录真波谷的所在的数据编号,最终得到一个四元组<peak,troughLeft,troughRight,halfWaveLength>,其中各变量分别为:真波峰peak,遇到真波峰前的最后一个真波谷troughLeft,真波峰过后的第一个真波谷troughRight,halfWaveLength表示半波的长度。The specific operations include: in a peak search area, obtain the maximum value of the peak, record the data number where the true peak is located, which is counted as peakIndex; similarly, in a valley search area, obtain the smallest trough and record the location of the true trough , and finally get a quadruple <peak, troughLeft, troughRight, halfWaveLength>, in which the variables are: true peak peak, the last true trough before the true peak, troughLeft, and the first true peak after the true peak. The troughRight, halfWaveLength represents the length of the half wave.

halfWaveLength的计算公式为:The formula for calculating halfWaveLength is:

halfWaveLength=max{|peakIndex-troughIndexLeft|,|peakIndex-troughIndexRight|}halfWaveLength=max{|peakIndex-troughIndexLeft|,|peakIndex-troughIndexRight|}

其中,troughIndexLeft表示troughLeft所在的数据编号,troughIndexRight表示troughRight所在的数据编号。Among them, troughIndexLeft represents the data number where troughLeft is located, and troughIndexRight represents the data number where troughRight is located.

以上完成一个波的重构,在一个采样计算窗口中,可以重构得到多个重构波形四元组。为了保证计算窗口内相邻完整波数据的连续性,一个四元组的troughRight为下一个四元组的troughLeft。The above completes the reconstruction of one wave, and in one sampling calculation window, multiple reconstructed waveform quadruplets can be reconstructed. In order to ensure the continuity of adjacent complete wave data within the calculation window, the troughRight of one quadruple is the troughLeft of the next quadruple.

完整波的搜索从真波谷开始,当无法完整地得到上面的四元组时,认为当前波不完整,需要保存当前残波数据,等待下一个计算窗口的数据到来,将合加速度数据中,troughLeft所在区域及其以后的数据添加到下一个计算窗口数据的前部,继续搜索真波峰以及真波谷。当得到一个完整波的波形四元组时,进行下一步骤的计算。The search for a complete wave starts from the true wave valley. When the above quadruple cannot be obtained completely, the current wave is considered to be incomplete, and the current residual wave data needs to be saved, waiting for the arrival of the data in the next calculation window. In the combined acceleration data, troughLeft The data of the region and its later are added to the front of the data of the next calculation window, and the search for true peaks and valleys is continued. When the waveform quadruple of a complete wave is obtained, the calculation of the next step is performed.

如图3所示为步骤105进行波形重构的具体流程:Figure 3 shows the specific flow of waveform reconstruction in step 105:

301、判断合加速度值是否大于均值。如果大于均值,表示进入波峰搜索区域,则开始寻找波形四元组<peak,troughLeft,troughRight,halfWaveLength>中的真波峰信息;否则,开始寻找真波谷信息。301. Determine whether the resultant acceleration value is greater than the average value. If it is greater than the average value, it indicates that it enters the peak search area, and starts to search for the true peak information in the waveform quadruple <peak, troughLeft, troughRight, halfWaveLength>; otherwise, starts to search for the true trough information.

302、判断当前值的前一个值是否小于均值。如果是进行信息保存;否则,表示上一个波的信息已经保存好了,无需在进行信息保存。302. Determine whether the previous value of the current value is less than the mean value. If it is to save the information; otherwise, it means that the information of the previous wave has been saved, and there is no need to save the information.

303、信息保存。当小于均值时,说明当前正在穿越均值,到达波峰所在的区域。此时,将真波谷信息保存为上一个波的四元组信息中的真波谷值troughRight以及数据编号troughIndexRight,计算上一个波中的halfWaveLength,公式为:303. Information preservation. When it is less than the mean value, it means that it is currently crossing the mean value and reaching the area where the wave peak is located. At this time, save the true wave valley information as the true wave valley value troughRight and the data number troughIndexRight in the quadruple information of the previous wave, and calculate the halfWaveLength in the previous wave. The formula is:

max{|peakIndex-troughIndexLeft|,|peakIndex-troughIndexRight|}max{|peakIndex-troughIndexLeft|,|peakIndex-troughIndexRight|}

以上完成上一个波的特征采集。同时,将波谷信息保存为当前波的真左波谷值troughLeft,记录数据编号troughIndexLeft,将原有波谷区域清空。The above completes the feature acquisition of the previous wave. At the same time, save the trough information as the true left trough value troughLeft of the current wave, record the data number troughIndexLeft, and clear the original trough area.

304、判断当前合加速度值是否为波峰。如果不是波峰,舍去数据,读取下一个合加速度值。304. Determine whether the current resultant acceleration value is a peak. If it is not a peak, discard the data and read the next resultant acceleration value.

305、当前合加速度为波峰值,需要判断当前合加速度值是否为波峰域中最大值。将当前合加速度值与已有的波峰域中的波峰进行判断,查找最大值。如果不是最大值,舍去数据,读取下一个合加速度值。305. The current resultant acceleration is the peak value of the wave, and it is necessary to judge whether the current resultant acceleration value is the maximum value in the wave peak domain. Judging the current resultant acceleration value and the peaks in the existing peak domain to find the maximum value. If it is not the maximum value, discard the data and read the next resultant acceleration value.

306、当前合加速度为波形四元组所潜在的真波峰peak值,保存peakIndex,并将当前波峰加入波峰域中。306. The current resultant acceleration is the potential true peak value of the waveform quadruple, save the peakIndex, and add the current peak to the peak domain.

307、当前合加速度值不大于均值,是波谷所在的区域,进行真波谷相关特征的提取。307. The current resultant acceleration value is not greater than the average value, which is the region where the trough is located, and extracts the relevant features of the true trough.

如图4所示为步骤307进行波谷解析的具体流程:Figure 4 shows the specific process of performing valley analysis in step 307:

401、判断是否为当前波中第一次进入波谷所在区域,如果是,那么需要保存当前波的真波峰信息。否则,表示当前波的真波峰信息已经保存,直接进行波谷搜索。401. Determine whether it is the first time in the current wave to enter the region where the trough is located, and if so, the true peak information of the current wave needs to be saved. Otherwise, it means that the true peak information of the current wave has been saved, and the trough search can be performed directly.

402、当前是从真波峰穿越平均值进入到波谷所在的波段,需要将当前完整波的真波峰特征信息保存到四元组中,即保存真波峰的值peak,以及真波峰所在的数据编号peakIndex,同时清空波峰区域。402. Currently, the true wave peak crosses the average value and enters the wave band where the wave trough is located. It is necessary to save the true wave peak characteristic information of the current complete wave into the quadruple, that is, save the value peak of the true wave peak and the data number peakIndex where the true wave peak is located. , while clearing the crest area.

403、判断当前合加速度值是否为波谷,如果不是,则输入下一个合加速度值。403. Determine whether the current resultant acceleration value is a trough, and if not, input the next resultant acceleration value.

404、判断当前的波谷是否为波谷域中的最小值,将当前的合加速度值与域中的已有波谷值进行对比,选出最小值作为最终候选的真波谷值。404. Determine whether the current trough is the minimum value in the trough domain, compare the current resultant acceleration value with the existing trough value in the domain, and select the minimum value as the final candidate true trough value.

405、保存当前得到的候选的最小波谷值,将波谷的信息进行保存,包括波谷值以及波谷对应的数据编号,将波谷值加入到波谷域当中。输入下一个合加速度值进行判断。405. Save the currently obtained candidate minimum trough value, save the trough information, including the trough value and the data number corresponding to the trough, and add the trough value to the trough domain. Input the next resultant acceleration value for judgment.

106、步数计算:根据105波形重构得到的四元组数据,以及104中判别所得到的数据类别信息,利用每种类别的对应的阈值四元组进行判别,当满足阈值四元组的要求,则在对应类别的总计步数加1。106. Calculation of steps: According to the quadruple data obtained by waveform reconstruction in 105, and the data category information obtained by discriminating in 104, use the corresponding threshold quadruple of each category to discriminate, when the threshold quadruple is satisfied. If required, add 1 to the total number of steps in the corresponding category.

根据步骤104得到的数据类别信息,获取相应类别的阈值四元组<peakThreshold,troughThreshold,maxWaveLength,minWaveLength>,将所得到的波形四元组特征<peak,troughLeft,troughRight,halfWaveLength>与通过阈值四元组进行比较,筛选出符合要求的四元组,进行步数计算。According to the data category information obtained in step 104, obtain the threshold quadruple <peakThreshold, troughThreshold, maxWaveLength, minWaveLength> of the corresponding category, and compare the obtained waveform quadruple feature <peak, troughLeft, troughRight, halfWaveLength> with the passing threshold quadruple The groups are compared, and the quadruplets that meet the requirements are screened out, and the number of steps is calculated.

如图5所示为步骤106进行步数计算的具体流程:Figure 5 shows the specific flow of step 106 for calculating the number of steps:

501、步骤104获取数据类别type。501. Step 104 obtains the data category type.

502、根据获取的类别type,当类别对应为静止噪声或者运动噪声时,舍去。否则,取出对应的阈值四元组<peakThreshold,troughThreshold,maxWaveLength,minWaveLength>。使用阈值对重构得到的四元组数据进行判别。502 . According to the obtained category type, when the category corresponds to static noise or motion noise, discard it. Otherwise, take out the corresponding threshold quadruple <peakThreshold, troughThreshold, maxWaveLength, minWaveLength>. Use a threshold to discriminate the reconstructed quadruple data.

503、判别真波峰值是否在预定范围内,如果peak<peakThreshold,那么舍去当前重构数据,判断下一个重构波形四元组。503. Determine whether the peak value of the true wave is within a predetermined range, and if peak<peakThreshold, discard the current reconstructed data, and determine the next reconstructed waveform quadruple.

504、判断真左波谷是否在预定的范围内,如果troughLeft>troughThreshold,那么当前重构数据不是有效的数据,舍去。504. Determine whether the true left wave trough is within a predetermined range, and if troughLeft>troughThreshold, then the current reconstructed data is not valid data and is discarded.

505、判断真右波谷是否在预定的范围内,如果troughRight>troughThreshold,那么表示当前数据为无效数据,舍去。505. Determine whether the true right wave trough is within a predetermined range, and if troughRight>troughThreshold, it means that the current data is invalid data and is discarded.

506、判断半波长是否在设定的范围内,如果halfWaveLength<minWaveLength,那么当前数据为无效数据,舍去。506. Determine whether the half-wavelength is within the set range. If halfWaveLength<minWaveLength, then the current data is invalid data and is discarded.

507、判断半波长的是否超出预先设定的范围,如果halfWaveLength>maxWaveLength,那么当前数据不符合要求,舍去。507. Determine whether the half-wavelength exceeds the preset range. If halfWaveLength>maxWaveLength, the current data does not meet the requirements and is discarded.

508、当前重构四元组数据为有效数据,属于正确的计步数据,将type类型的数据的计步总数加上一步。508. The current reconstructed quadruple data is valid data, which belongs to the correct step count data, and one step is added to the total step count of the data of type type.

以上所述,仅为本发明中的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉该技术的人在本发明所揭露的技术范围内,可理解想到的变换或替换,都应涵盖在本发明的包含范围之内,因此,本发明的保护范围应该以权利要求书的保护范围为准。The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited to this, any person familiar with the technology can understand the transformation or replacement that comes to mind within the technical scope disclosed by the present invention, All should be included within the scope of the present invention, therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (7)

1. A step counting method based on a mobile phone three-axis acceleration sensor is characterized by comprising the following specific steps:
step 1, determining a sampling calculation window according to a set sampling frequency and a sampling time window, and acquiring triaxial acceleration data of a triaxial acceleration sensor of a mobile phone, wherein the number of each axis data in each sampling calculation window is 0,1, … and n-1 according to an acquisition sequence, wherein n represents the number of each axis data in each sampling calculation window;
step 2, smoothing the collected triaxial acceleration data in each sampling calculation window, and calculating the smoothed resultant acceleration;
step 3, in each sampling calculation window, performing feature extraction on the three-axis acceleration data and the combined acceleration after smoothing in the step 2, wherein an average value xMean and a variance xVariance of the x-axis acceleration are extracted as x-axis data features, an average value yMean and a variance yVariance of the y-axis acceleration are extracted as y-axis data features, an average value zMean and a variance zVariance of the z-axis acceleration are extracted as z-axis data features, and the peak number peakCount of the combined acceleration is extracted as an appearance feature of a peak; clustering the resultant acceleration data into 3 classes by using a clustering algorithm, respectively obtaining an average value of each class of the resultant acceleration data, and sequencing the 3 average values from large to small to obtain a resultant acceleration characteristic < clusterPeak, clusterMean, clusterThrough >, clusterPeak > clusterMean > clusterThrough, clusterPeak represents the average characteristic of a peak, clusterMean represents the characteristic near the average value, and clusterThrough represents the average characteristic of a trough;
step 4, judging the category of the data collected in each sampling calculation window according to the characteristics extracted in the step 3;
step 5, if the judgment result in the step 4 is static noise or motion noise, discarding the data in the current sampling calculation window, otherwise, performing waveform reconstruction on the combined acceleration data in the current sampling calculation window; the waveform reconstruction method specifically comprises the following steps:
5.1, calculating the average value of the combined acceleration in the current sampling calculation window, and dividing the combined acceleration in the current sampling calculation window into a plurality of areas where wave crests are located and areas where wave troughs are located by using the average value, wherein the areas where the wave crests are located and the areas where the wave troughs are located alternately appear;
5.2, searching the area of each peak, acquiring the largest peak in the area of the current peak as the true peak of the area, and recording the corresponding data number peak index of the true peak in the current sampling calculation window;
5.3, searching the area where each wave trough is located, acquiring the minimum wave trough in the area where each wave trough is located as the true wave trough of the area, and simultaneously recording the corresponding data number of the true wave trough value in the current sampling calculation window;
5.4, the true peak, the last true valley trough before the true peak, the first true valley trough after the true peak, and the half-wave length halfWaveLength form a reconstructed waveform quadruple < peak, trough left, trough right, halfWaveLength >, completing reconstruction of a waveform, the halfWaveLength is max { | peak index-trough left |, | peak index-troughIndexRight | }, the troughIndexLeft represents that the trough left corresponds to a data number in the current sampling calculation window, and the troughIndexRight represents that the trough right corresponds to a data number in the current sampling calculation window;
step 6, setting a threshold quadruple < peak threshold, troughThreshold, maxWaveLength, minWaveLength > according to the type of the data acquired in the current sampling calculation window, and judging the reconstructed waveform obtained in the step 5 one by one:
6.1, according to the category of data acquired in the current sampling calculation window, acquiring a corresponding threshold quadruple < peakThreshold, troughTHhreshold, maxWaveLength and minWaveLength > from a preset threshold quadruple, wherein peakThreshold is used as a threshold of a true peak, troughTHhreshold is used as a threshold of a true trough, and maxWaveLength and minWaveLength are respectively a maximum retrievable value and a minimum retrievable value of the halfWaveLength;
6.2, the waveform quadruples < peak, trough left, trough right, halfWaveLength > of the reconstructed waveform are compared one by one with the threshold quadruples: firstly, judging a true peak, entering the next step if peak is greater than peak threshold, and otherwise, comparing waveform quadruples of the next reconstructed waveform; then, judging the true wave trough, if trough left < troughThreshold and trough right < troughThreshold, entering the next step, otherwise, comparing the waveform quadruplet of the next reconstructed waveform; finally, judging the half wavelength, if the half wavelength is greater than minWaveLength and the half wavelength is less than maxWaveLength, counting the current reconstructed waveform as one step, and adding one to the total step number of the corresponding data type; otherwise, comparing the waveform quadruple of the next reconstructed waveform;
and 7, respectively adding the step numbers in the sampling calculation windows according to different data types, namely realizing step counting.
2. The step counting method based on the three-axis acceleration sensor of the mobile phone according to claim 1, characterized in that, in step 2, an average smoothing method is adopted to perform smoothing processing on each axis data of the three-axis data, and the smoothing formula is:
Figure FDA0002412329070000021
where s is a preset smooth window size and is an even number greater than zero, ai+jRepresents data of number i + j in the sample before smoothing calculation window, a'iThe number of the data with the number i in the sampling calculation window after smoothing is shown, and n represents the number of the data in the sampling calculation window.
3. The step counting method based on the three-axis acceleration sensor of the mobile phone according to claim 1, characterized in that in step 5, in step 5.1, the average value is used to divide the combined acceleration in the current sampling time window into a region where a peak is located and a region where a trough is located, specifically: and dividing by judging whether the combined acceleration is greater than the average value, wherein the area where the combined acceleration is greater than the average value is the area where the wave crest is located, and the area where the combined acceleration is less than the average value is the area where the wave trough is located.
4. The step counting method based on the three-axis acceleration sensor of the mobile phone according to claim 3, characterized in that in step 5.4, when a complete waveform quadruple cannot be reconstructed from the last combined acceleration data in the previous sampling calculation window, the partial combined acceleration data is added to the front of the next sampling calculation window to ensure the continuity of the calculation in the adjacent sampling calculation windows.
5. The step counting method based on the three-axis acceleration sensor of the mobile phone according to claim 1, characterized in that the length of the sampling calculation window is windows length, sampling frequency f, and length N of the sampling time window.
6. The step counting method based on the three-axis acceleration sensor of the mobile phone according to claim 1, characterized in that the method for judging the category of the data collected in each sampling calculation window in step 4 is as follows:
4.1, respectively acquiring three-axis acceleration data of the mobile phone according to data categories, extracting features according to the methods in the steps 1 to 3, and taking the extracted features as a training set, wherein the data categories comprise a) static noise, b) the mobile phone in a jacket pocket, c) the mobile phone in a trousers pocket, d) the mobile phone walks in the hand, e) the mobile phone runs in the hand, f) the mobile phone is in other positions, and g) motion noise;
4.2, constructing a classification model, and training and learning the classification model by using the training set in the step 4.1;
and 4.3, inputting the features extracted from the data collected in each sampling calculation window into the classification model after training and learning, wherein the output of the classification model is the corresponding class.
7. The step counting method based on the three-axis acceleration sensor of the mobile phone according to claim 6, characterized in that the classification model in step 4.2 is a three-layer neural network, wherein the activation functions of the first layer and the second layer are both leaky linear rectification functions, the third layer adopts a normalized exponential function softmax function, the three-layer neural network is trained by a stochastic gradient descent algorithm with momentum, and the loss function is a cross entropy loss function.
CN201710569013.4A 2017-07-13 2017-07-13 Step counting method based on mobile phone three-axis acceleration sensor Expired - Fee Related CN107462258B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710569013.4A CN107462258B (en) 2017-07-13 2017-07-13 Step counting method based on mobile phone three-axis acceleration sensor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710569013.4A CN107462258B (en) 2017-07-13 2017-07-13 Step counting method based on mobile phone three-axis acceleration sensor

Publications (2)

Publication Number Publication Date
CN107462258A CN107462258A (en) 2017-12-12
CN107462258B true CN107462258B (en) 2020-06-16

Family

ID=60546251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710569013.4A Expired - Fee Related CN107462258B (en) 2017-07-13 2017-07-13 Step counting method based on mobile phone three-axis acceleration sensor

Country Status (1)

Country Link
CN (1) CN107462258B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109190553A (en) * 2018-08-30 2019-01-11 上海奥孛睿斯科技有限公司 Step detection method
CN109350072B (en) * 2018-11-15 2020-08-04 北京航空航天大学 Step frequency detection method based on artificial neural network
CN109540143B (en) * 2018-11-27 2022-12-02 中国广核电力股份有限公司 Pedestrian unconventional action direction identification method based on multi-sensing-source dynamic peak fusion
CN110595501B (en) * 2019-10-09 2022-10-04 成都乐动信息技术有限公司 Running distance correction method based on three-axis sensor
CN110721456B (en) * 2019-10-09 2020-12-25 成都乐动信息技术有限公司 Pedal frequency detection method based on three-axis sensor
CN110852260B (en) * 2019-11-08 2023-05-30 青岛联合创智科技有限公司 Drowning behavior recognition method based on accelerometer
CN111238527B (en) * 2020-01-15 2023-09-29 桂林市优创电子科技有限公司 Step counting method based on triaxial acceleration sensor
CN111442785B (en) * 2020-03-27 2021-01-26 广东工业大学 Inertial-based pedometer method, device and storage medium
CN111358472B (en) * 2020-03-27 2022-08-23 山东建筑大学 Gait detection algorithm, device and system
CN112067015B (en) * 2020-09-03 2022-11-22 青岛歌尔智能传感器有限公司 Step counting method and device based on convolutional neural network and readable storage medium
CN112923922B (en) * 2021-03-04 2022-01-25 香港理工大学深圳研究院 Method, system and storage medium for counting steps and determining position information of pedestrian
CN113008231A (en) * 2021-04-30 2021-06-22 东莞市小精灵教育软件有限公司 Motion state identification method and system, wearable device and storage medium
CN113378801B (en) * 2021-08-11 2021-11-09 深圳市梦瑶科技有限公司 Intelligent bracelet accurate step counting method based on neural network
CN114034313B (en) * 2021-11-10 2024-04-02 广东乐心医疗电子股份有限公司 Step counting method and device
CN114139669B (en) * 2021-11-19 2024-10-22 歌尔科技有限公司 Rope skipping counting method, device and medium thereof
CN114739412B (en) * 2022-04-11 2024-05-03 河海大学 A real-time pedestrian gait detection method and device based on smart phone
CN114815695B (en) * 2022-04-28 2025-06-03 广东万颗子智控科技有限公司 Remote control command generation method, device, remote control device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6441846B1 (en) * 1998-06-22 2002-08-27 Lucent Technologies Inc. Method and apparatus for deriving novel sports statistics from real time tracking of sporting events
CN104567912A (en) * 2015-02-02 2015-04-29 河海大学 Method for realizing pedometer on Android mobile phone
CN104990562A (en) * 2015-06-29 2015-10-21 合肥工业大学 Step counting method based on autocorrecting computing
CN104983489A (en) * 2015-07-28 2015-10-21 河北工业大学 Road condition identifying method for lower limb prosthesis walking
CN106767888A (en) * 2016-11-15 2017-05-31 皖西学院 A kind of meter based on Wave crest and wave trough detection walks algorithm

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6441846B1 (en) * 1998-06-22 2002-08-27 Lucent Technologies Inc. Method and apparatus for deriving novel sports statistics from real time tracking of sporting events
CN104567912A (en) * 2015-02-02 2015-04-29 河海大学 Method for realizing pedometer on Android mobile phone
CN104990562A (en) * 2015-06-29 2015-10-21 合肥工业大学 Step counting method based on autocorrecting computing
CN104983489A (en) * 2015-07-28 2015-10-21 河北工业大学 Road condition identifying method for lower limb prosthesis walking
CN106767888A (en) * 2016-11-15 2017-05-31 皖西学院 A kind of meter based on Wave crest and wave trough detection walks algorithm

Also Published As

Publication number Publication date
CN107462258A (en) 2017-12-12

Similar Documents

Publication Publication Date Title
CN107462258B (en) Step counting method based on mobile phone three-axis acceleration sensor
Yang et al. Deep convolutional neural networks on multichannel time series for human activity recognition.
CN103970271B (en) The daily routines recognition methods of fusional movement and physiology sensing data
Rui et al. Segmenting visual actions based on spatio-temporal motion patterns
Cao et al. Adaptive receptive field U-shaped temporal convolutional network for vulgar action segmentation
WO2021115064A1 (en) Fitness exercise recognition method based on wearable sensor
CN111582361B (en) Human behavior recognition method based on inertial sensor
CN106096662A (en) Human motion state identification based on acceleration transducer
CN112464738A (en) Improved naive Bayes algorithm user behavior identification method based on mobile phone sensor
CN102567715B (en) Hierarchical recognition method of human action based on pyroelectric infrared detection
Athota et al. Human activity recognition based on hybrid learning algorithm for wearable sensor data
Al-Ghannam et al. Prayer activity monitoring and recognition using acceleration features with mobile phone
CN111931616A (en) Emotion recognition method and system based on mobile intelligent terminal sensor equipment
CN112801009A (en) Facial emotion recognition method, device, medium and equipment based on double-flow network
CN114120370A (en) CNN-LSTM-based human body falling detection implementation method and system
Gao et al. Deep model-based semi-supervised learning way for outlier detection in wireless capsule endoscopy images
Li et al. Multiresolution fusion convolutional network for open set human activity recognition
Zhu et al. Deep ensemble learning for human activity recognition using smartphone
CN114913547A (en) Fall detection method based on improved Transformer network
CN117133057A (en) Physical exercise counting and illegal action distinguishing method based on human body gesture recognition
CN107506781A (en) A kind of Human bodys&#39; response method based on BP neural network
Xu et al. Skeleton-based tai chi action segmentation using trajectory primitives and content
CN114881079A (en) Method and system for abnormal detection of human motion intention for wearable sensor
Fu et al. Ping pong motion recognition based on smart watch
CN109271889A (en) A kind of action identification method based on the double-deck LSTM neural network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200616