A step counting method based on a wearable device and a wearable device
By using adaptive detection windows and signal processing technology, the problem of inaccurate step counting in wrist-worn wearable devices has been solved, achieving higher step counting accuracy and anti-interference capabilities.
Patent Information
- Application Number
- CN202311701165.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-11
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-12-11
AI Technical Summary
The accuracy of step counting results is reduced due to low signal quality and high interference in wrist-worn wearable devices.
An adaptive detection window is used to detect peaks. The threshold k of the adaptive detection window is automatically adjusted according to the characteristics of each signal segment to filter out motion peaks. Combined with moving average and bandpass filtering, interference peaks are eliminated. Data is added before and after the signal segment to prevent missed detection. The step counting strategy is adjusted according to the peak interval and walking frequency.
It improves the step counting accuracy of wrist-worn wearable devices, has strong anti-interference capabilities, reduces step counting errors, ensures that the peak of each signal segment is most likely to be a motion peak, and prevents cumulative errors.
Smart Images

Figure CN117685998B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of wearable pedometers, and more particularly to a step counting method and wearable device based on a wearable device. Background Technology
[0002] With the development of smart electronic devices in today's society, pedometer functions in 3C electronic products have gradually become widespread. In addition to mobile phones, smart wearable devices such as watches, bracelets, and ankle bracelets are also equipped with pedometer functions. However, unlike ankle bracelets, which can detect steps through zero velocity points, wrist-worn wearable devices are more susceptible to interference. The uncertainty of arm swing makes the signal quality collected by the accelerometer much lower than that collected by ankle bracelets. However, pedometers on wrist-worn wearable devices still mainly rely on peak detection. Existing technologies have disclosed many peak detection pedometer solutions, such as the method disclosed in patent CN114061616A, which collects acceleration and angular velocity through accelerometers and gyroscopes, detects peaks using the bubble method, and finally determines the current motion state to count steps. However, when this method is applied to wrist-worn wearable devices, the low signal quality and high degree of interference may lead to a decrease in the accuracy of the pedometer results. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a step counting method with strong anti-interference capability based on wearable devices, so as to solve the problem of inaccurate step counting by wrist wearable devices in the prior art.
[0004] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0005] A step counting method based on wearable devices includes the following steps:
[0006] S1. Acceleration signals are collected via an accelerometer and transmitted at fixed time intervals;
[0007] S2. Preprocess the acceleration signal to obtain a smooth acceleration signal;
[0008] S3. Detect the peak of the acceleration signal;
[0009] Step S3 further includes:
[0010] S31. Set an adaptive detection window for the entire acquired signal, determine the window threshold k of the adaptive detection window, the threshold k ranges from 1 to half the signal length, count the number of sampling points that are larger than both the kth number on the left and the kth number on the right when different threshold k are used, the k corresponding to the largest number of sampling points is the optimal k, and the optimal k is the window threshold of the adaptive detection window.
[0011] S32. Traverse and detect the acceleration signal ACC through an adaptive detection window. i=1:n , where n is the signal length, such as ACC i >ACC i-k …ACC i-1 And ACC i >ACC i+1 …ACC i+k Then ACC i For peaks, after detecting all peaks, return the peak sequence and threshold k;
[0012] S4. Count the number of steps taken based on the peak sequence.
[0013] Furthermore, step S2 also includes:
[0014] S21. Fill the end of the acceleration signal segment to be detected with a data segment, the value of which is the value of the last data segment of the acceleration signal.
[0015] S22. Perform moving average and bandpass filtering on the acceleration signal.
[0016] Furthermore, in step S21, the data preceding the signal segment to be detected is spliced into the signal segment to be detected.
[0017] Furthermore, step S3 also includes
[0018] S33. If the statistical peak is 0, then no steps are counted;
[0019] If the number of peaks is 1 or 2, a fixed window threshold ka is used for peak detection, the number of peaks is counted, and then the process proceeds to the next step, where k... a The value is an empirical value, and k a Less than the current adaptive window threshold k;
[0020] If there are more than two peaks, proceed directly to the next step;
[0021] S34. Calculate ACC p-k To ACC p+k The standard deviation of the segment is peak_std, where p is the peak index and k is the adaptive threshold of the peak detection algorithm. When counting peaks, only peaks exceeding the set threshold (threshold = 30) are counted.
[0022] Furthermore, in step S4, the average value of the inter-peak period is first calculated. When calculating the average value of the inter-peak period, the maximum inter-peak period value is removed and the average value of the remaining inter-peak periods is calculated. A threshold for the inter-peak period is set. If the average value of the inter-peak period is greater than the threshold for the inter-peak period, then the number of steps = the number of peaks * 2; otherwise, the number of steps = the number of peaks.
[0023] Furthermore, in step S4, step counting is only performed when the number of peaks selected from each data segment is greater than the number of steps taken during the normal walking frequency in that time period; otherwise, step counting is not performed.
[0024] On the other hand, a computer-readable medium is provided having instructions stored thereon that can be executed by a processor, which, when executed by the processor, cause the processor to perform the step counting method based on a wearable device as described above.
[0025] In another aspect, a wearable device is provided, wherein the wearable device is equipped with a processor, the processor being used to process the above-mentioned step counting method based on the wearable device.
[0026] Furthermore, the wearable device is a wristband or a watch.
[0027] The beneficial effects of this invention are as follows:
[0028] Peak detection is achieved by setting an adaptive detection window. The threshold k of the adaptive detection window is automatically adjusted according to the characteristics of each input signal segment. k is determined by counting the number of sampling points that are larger than both the kth number on the left and the kth number on the right at different thresholds k. The k corresponding to the largest number of sampling points is the optimal k, which can adapt to the characteristics of each input signal segment to the greatest extent. After determining the threshold k, sampling points that are larger than both the kth number on the left and the kth number on the right are selected as peaks. The advantage of the adaptive detection window is that, compared with previous peak detection methods such as the bubble method, it can eliminate small interference peaks with short intervals between them and moving peaks, and has stronger anti-interference ability. Moreover, each signal segment corresponds to a different threshold, ensuring that the peaks selected for each signal segment are most likely to be moving peaks. When using the adaptive window to detect peaks, a data segment is added before and after each signal segment to prevent missed peaks in the preceding and following windows from causing step loss and avoiding cumulative errors. When counting steps based on peaks, the decision to count steps is made based on the experience of the number of steps taken by a person in a fixed time period during normal walking, further eliminating interference peaks and improving step counting accuracy. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 The diagram shows the ACC signal before and after the moving average processing in the step counting method of the present invention.
[0031] Figure 2The diagram shows the ACC signal before and after bandpass filtering in the step counting method of this invention.
[0032] Figure 3 The image shows the peak signal detected by the adaptive window detection method listed in the embodiments of the present invention.
[0033] Figure 4 This is a graph of the ACC signal detected by the adaptive window detection method in the step counting method of the present invention.
[0034] Figure 5 A comparison diagram of peak filtering before and after setting the peak threshold in the step counting method of the present invention;
[0035] Figure 6 This is an ACC signal segment intercepted when the step counting method of the present invention detects the peak using an adaptive threshold.
[0036] Figure 7 The step counting method of the present invention uses an adaptive threshold to detect missed peaks and then uses a fixed threshold to detect peaks to extract the ACC signal segment.
[0037] Figure 8 This is a segment of the ACC signal captured during continuous step counting in the step counting method of the present invention. Detailed Implementation
[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. For example, terms such as “length,” “width,” “upper,” “lower,” “left,” “right,” “front,” “rear,” “vertical,” “horizontal,” “top,” “bottom,” “inner,” and “outer” indicate orientations or positions based on the orientations or positions shown in the accompanying drawings and are for ease of description only, and should not be construed as limiting the technical solution.
[0039] The terms "comprising" and "having," and any variations thereof, used in the specification, claims, and accompanying drawings of this invention are intended to cover non-exclusive inclusion; the terms "first," "second," etc., used in the specification, claims, and accompanying drawings are used to distinguish different objects, not to describe a particular order. "A plurality of" means two or more, unless otherwise explicitly specified.
[0040] In the description and claims of this invention and the foregoing drawings, when an element is referred to as "fixed to," "mounted to," "disposed on," or "connected to" another element, it can be located directly or indirectly on that other element. For example, when an element is referred to as "connected to" another element, it can be directly or indirectly connected to that other element.
[0041] Furthermore, the reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0042] Example
[0043] This embodiment provides a step counting method based on wearable devices, as detailed below:
[0044] Step S1: Collect triaxial acceleration signals using a triaxial accelerometer mounted on the wearable device, calculate the resultant acceleration, and transmit the acceleration signals (ACC signals) to the processor in 5-second intervals.
[0045] The second step, S2, involves preprocessing the acceleration signal to obtain a smoothed signal. During preprocessing, a moving average with a window length of 10 is first applied to the ACC signal. This moving average smooths out the original ACC signal, which is often riddled with glitches. Figure 1 The image shows a comparison of the ACC signal before and after the moving average. Subsequently, a bandpass filter is applied to the ACC signal. Specifically, a 4th-order Butterworth filter can be used to filter the ACC signal after the moving average, with a cutoff frequency of [0.5, 3]. This is determined based on the range of walking steps per second. Figure 2 This is a comparison chart of the signals before and after bandpass filtering;
[0046] The third step, S3, involves detecting the peak of the ACC signal. Peak detection mainly includes two steps. Due to the inherent error of the accelerometer and the different arm swing patterns, the incoming signal segments are not always regular or similar. Therefore, this embodiment uses an adaptive window for peak detection, with different window thresholds for different signal segments. First, in S31, an adaptive detection window is set, and the adaptive window threshold k is determined. The threshold k ranges from 1 to half the signal length. The number of sampling points that are larger than both the kth number on the left and the kth number on the right is counted at different threshold k. The k corresponding to the largest number of sampling points is the optimal k, and this k value is the window threshold of the adaptive detection window. Second, in S32, the ACC acceleration signal is traversed through the adaptive detection window. i=1:n , where n is the signal length, such as ACC i >ACC i-k …ACC i-1 And ACC i >ACC i+1 …ACC i+k Then ACC i The algorithm detects all peaks and returns the peak sequence and threshold k. The idea behind this peak detection is that S31 makes a preliminary judgment on the signal quality of the peaks when confirming the adaptive window. Theoretically, for a relatively neat ACC signal segment without much interference, when k=1, the number of sampling points larger than both the first number on the left and the first number on the right is maximized. In this case, k is the optimal adaptive window threshold, and the signal segment belongs to a signal segment with good quality. Peaks detected using k=1 as the window threshold are all moving peaks. However, sometimes when the signal quality is not ideal, it may... There will be a situation where the maximum number of sampling points is greater than both the kth number on the left and the kth number on the right when k > 1. In this case, the signal quality is not ideal, and there may be interference peaks in the signal segment. When selecting a k value that meets the filtering rule of threshold k for peak detection, interference peaks can be eliminated. The idea here is that if the point to be detected is a peak point, then within the window threshold, if this point is greater than the first point on the left, then it should be greater than the second point on the left. Otherwise, the entire signal segment will present uneven levels. These uneven peaks cannot be peaks generated by motion, but are interference peaks. The adaptive window detection method can eliminate such interference peaks.
[0047] To facilitate understanding, a specific example is provided here for further illustration:
[0048] Suppose a signal has 14 sampling points, and the sampling point array is [1,2,3,4,1,2,1,2,3,4,3,2,1,1]. Figure 3As shown, an adaptive window is set, and the window threshold is determined: k=1, num=3; k=2, num=3; k=3, num=4, where num represents the number of sampling points larger than both the k-th number on the left and the k-th number on the right. It can be seen that if the signal is relatively regular, the value of num should be maximum when k=1. However, when the adaptive window threshold is set to k=3, the value of num is actually larger, proving that the signal segment is not actually regular and contains interference. Therefore, k=3 is chosen as the window threshold for peak detection. During peak detection, sampling points larger than the three consecutive sampling points on the left and the three consecutive sampling points on the right are selected as peaks, successfully eliminating low-lying interference peaks between two moving peaks. Figure 3 The points marked with red stars represent the peaks detected using this method. Those skilled in the art should note that this array and... Figure 3 This scenario is a hypothetical one for the purpose of illustrating the specific implementation effect of this embodiment and is not an actual ACC signal collected by the accelerometer.
[0049] In one preferred embodiment, in step S2, a data segment is filled at the end of the acceleration signal segment to be detected. The filled value is the value of the last data point of the acceleration signal. Additionally, the data from the previous 5 seconds of the signal segment to be detected is spliced to the signal segment. When peaks appear near the beginning and end of each signal segment, the adaptive detection window may not detect peaks near the ends of the signal segment because the value of k exceeds the signal length from the first / last peak to the beginning / end of the signal, resulting in insufficient detection of k peaks. Figure 4 The peaks at both ends of the signal segment shown were not detected. Missing 1-2 peaks each time will lead to cumulative errors in step counting over a long period of time. To ensure that the peaks at both ends are not missed, the signal before the signal to be detected is spliced at the front end of the signal segment to be detected, and a data segment is filled at the back end. After the peaks are detected, the data filled at the back end can be deleted. In principle, the length of the spliced and supplemented signal should be sufficient to fit a complete adaptive window when the first / last peak is detected. In this embodiment, the signal 5 seconds before the signal to be detected is spliced at the front end of the signal segment to be detected, and a data segment of length 50 is added at the back end.
[0050] In one preferred embodiment, if a detection peak appears within 5 seconds of the signal segment to be detected but the number of detected peaks is small, it may be due to the subject's arm swinging with minimal amplitude during a few steps within 5 seconds, resulting in missed detections. In this case, the threshold k of the adaptive window can be reduced to detect those potentially missed peaks. Therefore, the following processing strategy is adopted for different situations: After step S32, in step S33, the number of peaks is counted. If the counted number of peaks is 0, no steps are counted. If the counted number of peaks is 1 or 2, a fixed window threshold k is used. a Perform peak detection with a fixed window threshold ka The value is an empirical value, determined by comparing the collected signal detection with the actual number of steps taken. In this embodiment, k is taken as k. a If the number of peaks is 12, count the number of peaks again and then proceed to the next step S34. If there are more than 2 peaks, proceed directly to the next step S34.
[0051] S34. Calculate ACC p-k To ACC p+k The standard deviation of the segment is `peak_std`, where `p` is the peak index and `k` is the adaptive threshold of the peak detection algorithm. When counting peaks, only peaks exceeding the set threshold (threshold = 30) are counted. This step is used to filter very flat and low peaks. Because the adaptive window detects peaks within a limited window length when using the threshold `k`, low but similarly regular peaks will still be detected, such as... Figure 5 The threshold detected by the adaptive window has been used to identify all peaks in the graph. However, some low, flat, but equally regular peaks are clearly not generated by motion. Setting a peak threshold can exclude these peaks. The remaining motion peaks (runpeaks) after exclusion are as follows: Figure 5 As shown;
[0052] Furthermore, in actual walking experiments, it was found that a single standard deviation threshold cannot fully cover real-world situations. Some people have very small arm swing amplitudes when walking, resulting in low motion peaks. However, unlike interference, these low peaks are continuous and regular. For such cases, a method to adjust the standard deviation threshold can be provided for further remediation. For example, in this embodiment, when the number of selected motion peaks is greater than two, a threshold is adaptively recalculated within the window, and peaks are re-selected based on this threshold. The formula for calculating the new threshold is:
[0053] windows_threshold=min(threshold,mean(peak_std_valid)*0.5)
[0054] Here, mean(peak_std_valid) is the mean of peak_std corresponding to the motion peaks filtered using the threshold (take half of the standard deviation).
[0055] Furthermore, sometimes a slightly lower peak may appear between two peaks. In this case, using an adaptive threshold k might cause the peak to be identified as an interference peak and thus undetectable. In such situations, a fixed threshold k can also be used. a Perform peak detection, such as Figure 6 For signal segments where peak detection is performed using an adaptive threshold k, such as Figure 7To use k a The signal segment for peak detection.
[0056] After peak detection is completed, step S4 counts steps based on the selected peaks. In a preferred embodiment, the average peak interval is calculated before counting steps. Since the peak selection stage removes some peaks that are not considered movement peaks, resulting in a large peak interval, and this peak interval is not a true step interval feature, the maximum peak interval is removed before calculating the average of the remaining peak intervals. A peak interval threshold is set. If the average peak interval is greater than the peak interval threshold, then the step count = peak count * 2; otherwise, the step count = peak count. This strategy considers that the time for a person to swing their arms while walking has a normal range. If the peak interval exceeds this arm swing time, it is considered that the peak detection step may have missed or excluded peaks that were originally generated by normal arm swings. In this case, the peak count * 2 strategy is used as step counting compensation to improve step counting accuracy.
[0057] Furthermore, considering that a person's walking frequency has a fixed range, the number of steps a person takes within a fixed time period exists within a normal range. For example, in this embodiment, the number of steps every 5 seconds cannot be less than 3. Therefore, when the number of motion peaks selected from each data segment is greater than 3, steps are counted. When the number of motion peaks is less than 3, it is determined that the subject is just waving his arms irregularly and is not walking, so steps are not counted. This strategy can be adjusted according to the length of the input signal segment.
[0058] Using the step counting method described in the above embodiment, for each continuously input ACC signal segment, the number of steps updated each time is accumulated to achieve continuous step counting, such as... Figure 8 As shown in the figure, the marked areas are the selected motion peaks. Step counting is performed based on this motion peak detection method, which has a strong anti-interference ability for signal segments with a large number of M-shaped peaks.
[0059] Furthermore, this embodiment provides a computer storage medium storing instructions executable by a processor. When executed by the processor, the instructions cause the processor to perform the step counting method disclosed in the above embodiment.
[0060] Furthermore, this embodiment also provides a wearable device, which is equipped with a processor for processing the step counting method disclosed in the above embodiment. The wearable device can be a bracelet, smartwatch, or the like worn on the wrist.
[0061] The above embodiments are preferred implementations of the present invention. In addition, the present invention can be implemented in other ways. Any obvious substitutions without departing from the concept of the present technical solution are within the protection scope of the present invention.
Claims
1. A step counting method based on a wearable device, characterized in that, Includes the following steps: S1. Acceleration signals are collected via an accelerometer and transmitted at fixed time intervals; S2. Preprocess the acceleration signal to obtain a smooth acceleration signal; Step S2 further includes: S21. Fill the end of the acceleration signal segment to be detected with a data segment, the value of which is the value of the last data of the acceleration signal; or concatenate the data before the signal segment to be detected to the signal segment to be detected. S22. Perform moving average and bandpass filtering on the acceleration signal; S3. Detect the peak of the acceleration signal; Step S3 further includes: S31. Set an adaptive detection window for the entire acquired signal, determine the window threshold k of the adaptive detection window, the threshold k ranges from 1 to half the signal length, count the number of sampling points that are larger than both the kth number on the left and the kth number on the right when different threshold k are used, the k corresponding to the largest number of sampling points is the optimal k, and the optimal k is the window threshold of the adaptive detection window. S32. Traverse and detect acceleration signals through an adaptive detection window. , where n is the signal length, such as and ,but For peaks, after detecting all peaks, return the peak sequence and threshold k; S33. If the statistical peak is 0, then no steps are counted; If the statistical peak is 1 or 2, then a fixed window threshold k is used. a Perform peak detection, count the number of peaks, and then proceed to the next step, where k a The value is an empirical value, and k a Less than the current adaptive window threshold k; If there are more than two peaks, proceed directly to the next step; S34. Calculation arrive Standard deviation of segment Where p is the peak index and k is the adaptive threshold of the peak detection algorithm; when counting peaks, only peaks exceeding the set threshold are counted; when the number of selected peaks is greater than 2, an adaptive threshold is recalculated within the window, and peaks are re-selected based on this threshold. The formula for calculating the new threshold is: windows_threshold=min(threshold,mean(peak_std_valid)*0.5 ) Here, mean(peak_std_valid) is the mean of peak_std corresponding to the motion peaks filtered using the threshold; peaks are counted based on the new threshold windows_threshold. S4. Count the number of steps based on the peak sequence. Specifically, first calculate the average value of the interpeak intervals. When calculating the average value of the interpeak intervals, remove the maximum interpeak interval value and then calculate the average value of the remaining interpeak intervals. Set an interpeak interval threshold. If the average value of the interpeak intervals is greater than the interpeak interval threshold, then the number of steps = the number of peaks * 2; otherwise, the number of steps = the number of peaks.
2. The step counting method based on a wearable device according to claim 1, characterized in that, In step S4, step counting is performed only when the number of peaks selected from each data segment is greater than the number of steps taken during the normal walking frequency in that time period; otherwise, step counting is not performed.
3. A computer-readable medium having stored thereon instructions executable by a processor, the instructions, when executed by the processor, causing the processor to perform the step counting method based on a wearable device as described in any one of claims 1-2.
4. A wearable device, characterized in that: The wearable device is equipped with a processor for processing the step counting method based on the wearable device as described in any one of claims 1-2.
5. The wearable device according to claim 4, characterized in that: The wearable devices are wristbands and watches.
