Step counting method based on walking stateTechnical Field
The invention relates to the technical field of step counting, in particular to a step counting method based on a walking state.
Background
In recent years, various smart phones and wearable devices have become more popular, and among these devices, particularly wearable devices, there are sports and health related applications. One of the core algorithms for these applications is the step-counting algorithm. The existing step counting algorithm adopts a simpler threshold detection method, only provides a step counting function and cannot provide gait information.
The main methods in the prior art are as follows: setting an acceleration threshold and the shortest time interval between the two parts before starting; reading accelerometer data; separating the component of the acceleration in the gravity direction caused by the walking of the user from the accelerometer data, and recording the data as V; it is checked whether two consecutive V values cross the set threshold from low to high. As long as the first value V1 is smaller than the threshold value and the second value V2 is larger than the threshold value, two continuous V values are judged to cross the set threshold value from low to high; and meanwhile, if the time interval between the current time and the last step counting time exceeds the set time length, the step counting is carried out.
However, the prior art has the following disadvantages:
step counting is usually not very accurate, some common interference cannot be eliminated, and the step counting can be caused when a user swings the equipment randomly; although these step-counting algorithms can be applied to some applications with low precision, such as counting the number of steps taken by a user in one day, if the step-counting algorithms are applied to an application similar to PDR (pedestrian dead reckoning), the effect of the error on the result is large.
Too little information is provided; only the most basic step counting function is provided, and more gait information cannot be provided; if more information about the gait of the user is known, more data about the movement of the user can be deduced from this. For example, in a fitness type application, if the approximate step size and frequency of walking of each step of the user can be known, the energy consumed by the user and the total distance walked can be more accurately estimated.
It is necessary to solve these disadvantages.
Disclosure of Invention
The invention aims to provide a step counting method based on a walking state, which aims to solve the technical problems that: step counting is usually not very accurate and provides too little information.
Therefore, the invention provides a step counting method based on a walking state, which comprises the following steps:
step 1: continuously acquiring acceleration data from an acceleration sensor; calculating global acceleration through multiple groups of original acceleration data; calculating linear acceleration ACC on three axes through original acceleration data and global acceleration datax,ACCyAnd ACCz;
Step 2: determining linear accelerations ACC on three axesx,ACCyAnd ACCzWhether the data exceeds a set threshold value or not, if so, marking the data as abnormal data and clearing; calculating the component of the linear acceleration in the gravity direction, and performing smooth filtering to obtain ACCg;
And step 3: let ACCgPlotting into a first curve, ACCyDrawing a second curve, and overlapping the first curve and the second curve to form an overlapped image;
and 4, step 4: setting walking recognition conditions according to walking characteristics, wherein the walking recognition conditions are ACCgAnd ACCyThe composition of characteristic points, utilize walking to presume the condition analysis and overlap the picture, judge whether takes place walking;
and 5: when walking is judged to occur, ACC at walking time is determinedgValue calculation step size from timestamp of walking moment and last ACCgAnd calculating the step frequency by the timestamp of the wave valley value to obtain walking data.
Further, the step 1 of acquiring a group of raw acceleration data by the acceleration sensor specifically includes: measuring the acceleration on the X axis, the Y axis and the Z axis by using an acceleration sensor to obtain acceleration values on the X axis, the Y axis and the Z axis which are RAW _ ACC respectivelyX,RAW_ACCYAnd RAW _ ACCZ。
Further, the step of calculating the component of the filtered linear acceleration in the gravity direction and performing parallel filtering specifically comprises: carrying out multiple data measurements by using an acceleration sensor to obtain multiple groups of acceleration values on an X axis, a Y axis and a Z axis; calculating the average value of acceleration values on multiple groups of X-axis, Y-axis and Z-axis to obtain components on the X-axis, Y-axis and Z-axis of global acceleration, and respectively recording the components as ACCworldx、ACCworldyAnd ACCworldzThe method specifically comprises the following steps:
wherein RAW _ ACCX, RAW _ ACCY and RAW _ ACCZ are measured values of the acceleration sensor on the X-axis, Y-axis and Z-axis, respectively.
Further, step 2 specifically comprises: the components of the linear acceleration in the X, Y and Z axes, denoted ACC respectivelyx、ACCyAnd ACCzThe method specifically comprises the following steps:
ACCx=RAW_ACCxk-ACCworldx
ACCy=RAW_ACCyk-ACCworldy
ACCz=RAW_ACCzk-ACCworldz;
wherein ACCworldx、ACCworldyAnd ACCworldzComponents on the global acceleration X-axis, Y-axis and Z-axis, respectively; the RAW _ ACCX, RAW _ ACCY, and RAW _ ACCZ are measured values of the acceleration sensor on the X-axis, Y-axis, and Z-axis, respectively.
Further, step 2 specifically comprises:
wherein ACCx、ACCyAnd ACCzThe components of the linear acceleration on the X-axis, the Y-axis and the Z-axis respectively;
normalizing the global acceleration, specifically:
measurement values of the acceleration sensor:
RAW_ACC=[RAW_ACCx RAW_ACCy RAW_ACCz]
transposing the measured value matrix of the acceleration sensor, multiplying the transposed measured value matrix by the global acceleration normalization value to obtain the dot product of two space vectors, and subtracting the global accelerationModeling to obtain linear acceleration values in the gravity direction, accumulating linear acceleration values in n gravity directions to obtain ACCg;
Wherein n is 10.
Further, a plurality of ACCsgDrawing a first curve, and drawing multiple ACCsyDrawing a second curve, and overlapping the first curve and the second curve to form an overlapped image;
the walking characteristics are as follows: between the trough of the first curve and the first crest after the trough, the corresponding second curve has a crest and the value of the crest is larger than zero; when the first curve is at a peak, the ACC at the peakgACC on the second curve of its corresponding positionyIs a negative value; when the wave crest on the second curve and the close wave trough are within a set time threshold value;
the specific setting of the walking determination conditions according to the walking characteristics is as follows:
ACC when in the first curvegACC in the second curve at peakyIs a negative value; while ACC in the second curveyHas a peak time stamp greater than ACC in the first curvegA trough timestamp of; while ACC in the second curveyACC in first curve of peak and adjacent peakgThe time interval between the wave crests does not exceed a set threshold; while ACC in the first curvegWave trough and its adjacent ACCgThe time interval between wave crests exceeds a set threshold; again, ACC in the first curvegThe time interval between the peak and the last invalid data exceeds the set threshold.
Further, step size and step frequency are calculated, wherein the step size LestComprises the following steps:
wherein ACCgFor linear acceleration values in n directions of gravityAn accumulated value of (d);
to LestAnd (3) constraining to obtain a final step length L:
the step frequency F can be obtained according to the following formula:
wherein, TpeakDenotes ACCgTime stamp of wave crest, TtroughRepresenting corresponding ACCsgTime stamp of one ACCg trough on the peak.
The beneficial effect of above-mentioned scheme: most of equipment shaking interference can be eliminated, whether a user really walks or not is detected, wrong step counting under some abnormal conditions is eliminated, and information such as step length, step frequency and the like is provided; the step counting precision can be effectively improved.
Drawings
FIG. 1 is a flow chart of a step counting method based on walking status according to the present invention;
FIG. 2 is a schematic view of a first curve of the present invention;
FIG. 3 is a schematic view of an overlay image formed by a first curve and a second curve according to the present invention;
FIG. 4 is a schematic step-counting diagram according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the step-counting effect under abnormal interference according to the present invention.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings.
As shown in fig. 1 to 5, the step counting method based on the walking state includes the following steps:
step 1: continuously acquiring acceleration data from an acceleration sensor; calculating global acceleration through multiple groups of original acceleration data; calculating linear acceleration ACC on three axes through original acceleration data and global acceleration datax,ACCyAnd ACCz;
Step 2: determining linear accelerations ACC on three axesx,ACCyAnd ACCzWhether the data exceeds a set threshold value or not, if so, marking the data as abnormal data and clearing; calculating the component of the linear acceleration in the gravity direction, and performing smooth filtering to obtain ACCg;
And step 3: let ACCgPlotting into a first curve, ACCyDrawing a second curve, and overlapping the first curve and the second curve to form an overlapped image;
and 4, step 4: setting walking recognition conditions according to walking characteristics, wherein the walking recognition conditions are ACCgAnd ACCyThe composition of characteristic points, utilize walking to presume the condition analysis and overlap the picture, judge whether takes place walking;
and 5: when walking is judged to occur, ACC at walking time is determinedgValue calculation step size from timestamp of walking moment and last ACCgAnd calculating the step frequency by the timestamp of the wave valley value to obtain walking data.
In the above embodiment, the step 1 of acquiring a group of raw acceleration data by the acceleration sensor specifically includes: measuring the acceleration on the X axis, the Y axis and the Z axis by using an acceleration sensor to obtain acceleration values on the X axis, the Y axis and the Z axis which are RAW _ ACC respectivelyX,RAW_ACCYAnd RAW _ ACCZ。
In the above embodiment, the calculating the component of the filtered linear acceleration in the gravity direction, and performing parallel filtering specifically includes: carrying out multiple data measurements by using an acceleration sensor to obtain multiple groups of acceleration values on an X axis, a Y axis and a Z axis; calculating the average value of acceleration values on multiple groups of X-axis, Y-axis and Z-axis to obtain components on the X-axis, Y-axis and Z-axis of global acceleration, and respectively recording the components as ACCworldx、ACCworldyAnd ACCworldzThe method specifically comprises the following steps:
wherein RAW _ ACCX, RAW _ ACCY and RAW _ ACCZ are measured values of the acceleration sensor on the X-axis, Y-axis and Z-axis, respectively.
In the above embodiment, step 2 specifically includes: the components of the linear acceleration in the X, Y and Z axes, denoted ACC respectivelyx、ACCyAnd ACCzThe method specifically comprises the following steps:
ACCx=RAW_ACCxk-ACCworldx
ACCy=RAW_ACCyk-ACCworldy
ACCz=RAW_ACCzk-ACCworldz;
wherein ACCworldx、ACCworldyAnd ACCworldzComponents on the global acceleration X-axis, Y-axis and Z-axis, respectively; the RAW _ ACCX, RAW _ ACCY, and RAW _ ACCZ are measured values of the acceleration sensor on the X-axis, Y-axis, and Z-axis, respectively.
In the above embodiment, step 2 specifically includes:
wherein ACCx、ACCyAnd ACCzThe components of the linear acceleration on the X-axis, the Y-axis and the Z-axis respectively;
normalizing the global acceleration, specifically:
measurement values of the acceleration sensor:
RAW_ACC=[RAW_ACCx RAW_ACCy RAW_ACCz]
transmitting accelerationThe measurement values of the sensors are subjected to matrix transposition and multiplied by the global acceleration normalization value to obtain a dot product of two space vectors, then a mode of the global acceleration is subtracted to obtain linear acceleration values in the gravity direction, and the linear acceleration values in n gravity directions are accumulated to obtain ACCg;
Wherein n is 10.
In the above-described embodiment of the present invention,
multiple ACCsgDrawing a first curve, and drawing multiple ACCsyDrawing a second curve, and overlapping the first curve and the second curve to form an overlapped image;
the walking characteristics are as follows: between the trough of the first curve and the first crest after the trough, the corresponding second curve has a crest and the value of the crest is larger than zero; when the first curve is at a peak, the ACC at the peakgACC on the second curve of its corresponding positionyIs a negative value; when the wave crest on the second curve and the close wave trough are within a set time threshold value;
the specific setting of the walking determination conditions according to the walking characteristics is as follows:
ACC when in the first curvegAt peak, corresponding to ACC in the second curveyIs a negative value; while ACC in the second curveyHas a peak time stamp greater than ACC in the first curvegA trough timestamp of; while ACC in the second curveyACC in first curve of peak and adjacent peakgThe time interval between the wave crests does not exceed a set threshold; while ACC in the first curvegWave trough and its adjacent ACCgThe time interval between wave crests exceeds a set threshold; again, ACC in the first curvegThe time interval between the peak and the last invalid data exceeds a set threshold;
wherein the maximum value of the linear acceleration is 6.8;
ACCgthe peak range of the wave is 3.3-45;
ACCgthe wave trough range of (1) is-45 to-3.3;
ACCgthe maximum time interval between the wave peak and the last ACCY wave peak is 350 ms;
ACCg200ms of minimum time interval between the trough and its adjacent ACCg peak;
ACCgthe maximum time interval between the peak and the last invalid data is 850 ms.
ACC when in the first curvegACC in the second curve at peakyAnd the negative value is used for filtering the error step counting caused by the abnormal shaking of the equipment.
In the above embodiment, the step size and the step frequency are calculated, wherein the step size LestComprises the following steps:
wherein ACCgIs the accumulated value of linear acceleration values in n gravity directions;
to LestAnd (3) constraining to obtain a final step length L:
the step frequency F can be obtained according to the following formula:
wherein, TpeakDenotes ACCgTime stamp of wave crest, TtroughRepresenting an ACC on the corresponding ACCg peakgThe time stamp of the trough.
FIG. 4 is a schematic diagram of an implementation of step counting; each vertical line in the graph represents one step counting, and the characters below display information such as step length, step frequency and the like; FIG. 5 is a schematic diagram of the step counting effect performed under abnormal disturbance, which is an image generated by the human shaking device, and it can be seen that the waveform generated under abnormal disturbance is similar to the waveform generated under normal walking, but the step counting is not caused (which can be compared with the step counting schematic diagram performed under normal state); the technical scheme can calculate the step size and the step frequency, can eliminate most of equipment shaking interference, detect whether a user is really walking or not, eliminate wrong step counting under some abnormal conditions, and provide information such as the step size, the step frequency and the like; the step counting precision can be effectively improved.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.