This application claims the priority benefit of Taiwan application serial no. 103106314, filed on Feb. 25, 2014. The entirety of the above-mentioned patent application is hereby incorporated by reference herein and made a part of this specification.
1. Technical Field
The invention relates to a method for counting steps and an electronic apparatus using the same. Particularly, the invention relates to a method for counting steps according to signals detected by a microelectromechanical system (MEMS) sensor and an electronic apparatus using the same.
2. Related Art
A step counter is a device capable of counting steps of a user when the user walks or runs. Conventionally, the step counter has many methods for counting steps. Among these methods, a most direct one is to place an object having a weight in the step counter, and measure a bounce rate of the object according to, for example, an electrical method or a mechanical method.
However, the step counter is generally designed in a larger size in order to accommodate the above object and measuring components. If the step counter is deigned in a smaller size, the method for counting steps adopted by the step counter has to be modified to a method for counting the steps according to signals detected by a microelectromechanical system (MEMS) sensor. The MEMS sensor is, for example, a detecting device such as an accelerometer, a magnetometer, a gyroscope, etc.
The invention is directed to a method for counting steps and an electronic apparatus using the same, by which a step counting result is accurately generated according to signals detected by a microelectromechanical system (MEMS) sensor.
The invention provides a method for counting steps, which is adapted to an electronic apparatus, and the method includes following steps. An orientation and a plurality of first three-axis acceleration values of the electronic apparatus are obtained. A specific ratio of an acceleration of gravity is removed from each of the first three-axis acceleration values according to the orientation to generate a plurality of second three-axis acceleration values. A plurality of inner product values and a plurality of outer product values are calculated according to the second three-axis acceleration values. It is determined whether a user of the electronic apparatus is in a walking status according to the second three-axis acceleration values. If yes, the inner product values are set as reference values, and if not, the outer product values are set as the reference values. A number of steps corresponding to the second three-axis acceleration values is calculated according to the reference values.
The invention provides an electronic apparatus including a detection unit, a storage unit and a processing unit. The detection unit detects an orientation and a plurality of first three-axis acceleration values of the electronic apparatus. The storage unit stores a plurality of modules. The processing unit is coupled to the detection unit and the storage unit, and accesses the modules to execute the following steps. The orientation and a plurality of first three-axis acceleration values of the electronic apparatus are obtained. A specific ratio of acceleration of gravity is removed from each of the first three-axis acceleration values according to the orientation to generate a plurality of second three-axis acceleration values. A plurality of inner product values and a plurality of outer product values are calculated according to the second three-axis acceleration values. It is determined whether a user of the electronic apparatus is in a walking status according to the second three-axis acceleration values. If yes, the inner product values are set as reference values, and if not, the outer product values are set as the reference values. A number of steps corresponding to the second three-axis acceleration values is calculated according to the reference values.
According to the above descriptions, by calculating the number of walking or running steps according to the inner product values and the outer product values, the method for counting steps of the invention can be used to accurately generate the step counting result.
In order to make the aforementioned and other features and advantages of the invention comprehensible, several exemplary embodiments accompanied with figures are described in detail below.
The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.
The detection unit 110 is, for example, an accelerometer, a magnetometer, a gyroscope, etc., or combination thereof, though the invention is not limited thereto. The detection unit 110 can detect an orientation and a plurality of first three-axis acceleration values of the electronic apparatus 100. The orientation is, for example, an azimuth angle of the electronic apparatus 100 in a three-dimensional space. The first three-axis acceleration values are, for example, a plurality of three-axis acceleration sampling values of the electronic apparatus captured by the detection unit 110 at different time points, though the invention is not limited thereto. The first three-axis acceleration values can be respectively represented by an X-axis acceleration component, a Y-axis acceleration component and a Z-axis acceleration component. According to another aspect, when a user carries the electronic apparatus 100 to conduct activities such as walking or running, etc., the detection unit 110 can detect a moving status (i.e., the orientation and the first three-axis acceleration values) of the electronic apparatus 100 generated due to the activity of the user.
The storage unit 120 is, for example, a fixed or movable random access memory (RAM) of any type, a read-only memory (ROM), a flash memory, a hard disk or other similar devices or a combination of the devices, which is not limited by the invention.
The processing unit 130 is coupled to the detection unit 110 and the storage unit 120. The processing unit 130 is, for example, a single chip, a general-purpose processor, a special-purpose processor, a conventional processor, a digital signal processor, a plurality of microprocessors, one or a plurality of microprocessors combined with a digital signal processor core, a controller, a micro controller, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), any other type of integrated circuit, a state machine, a processor based on an advanced RISC machine (ARM) and similar products.
In the present embodiment, the processing unit 130 may access a plurality of modules stored in the storage unit 120 to execute various steps of the method for counting steps provided by the invention.
First, in step S210, the processing unit obtains the orientation and a plurality of the first three-axis acceleration values of the electronic apparatus 100 from the detection unit 110. Then, in step S220, the processing unit 130 removes a specific ratio of acceleration of gravity from each of the first three-axis acceleration values according to the orientation to generate a plurality of second three-axis acceleration values. The second three-axis acceleration values can be respectively represented by an X-axis acceleration component, a Y-axis acceleration component and a Z-axis acceleration component. The specific ratio can be 70%, though the invention is not limited thereto.
In other words, the processing unit 130 only removes a part of the acceleration of gravity from each of the first three-axis acceleration values, and does not completely remove the acceleration of gravity from each of the first three-axis acceleration values. A reason thereof is that if the acceleration of gravity is completely removed from each of the first three-axis acceleration values, each of the second three-axis acceleration values is rather close to a noise value to cause a wrong step counting result, and details thereof are described with reference of
Referring to
Referring to
Referring to
For example, it is assumed that an ith (i is a positive integer) second three-axis acceleration value is represented as (xi, yi, zi), where xi is the X-axis acceleration component of the ith second three-axis acceleration value, yi is the Y-axis acceleration component of the ith second three-axis acceleration value, and zi is the Z-axis acceleration component of the ith second three-axis acceleration value. Moreover, it is assumed that an (i-1)th second three-axis acceleration value is represented as (xi-1, yi-1, zi-1), where xi-1 is the X-axis acceleration component of the (i-1)th second three-axis acceleration value, yi-1 is the Y-axis acceleration component of the (i-1)th second three-axis acceleration value, and zi-1 is the Z-axis acceleration component of the (i-1)th second three-axis acceleration value. Based on (xi, yi, zi) and (xi-1, yi-1, zi-1), the processing unit 130 can calculate an ith inner product value and an ith outer product value. The ith inner product value is, for example,
and the ith outer product value is, for example, [(yizi-1−ziyi-1)2+(zixi-1−xizi-1)2+(xiyi-1−yixi-1)2]2, though the invention is not limited thereto.
Then, in step S240, the processing unit 130 determines whether the user of the electronic apparatus 100 is in a walking status according to the second three-axis acceleration values. In detail, the processing unit 130 can calculate a plurality of magnitude values corresponding to the second three-axis acceleration values. Taking the ith second three-axis acceleration value as an example, the magnitude value thereof is, for example, √{square root over ((xi2+yi2+zi2))}, though the invention is not limited thereto. Then, the processing unit 130 calculates an average of the magnitude values, and determines whether the average is higher than a first predetermined threshold value (for example, 0.2). If yes, the processing unit 130 determines that the user is in the walking status, and a step S250 is executed. If not, the processing unit 130 determines that the user is not in the walking status (i.e., the user is probably in a running status), and a step S260 is executed.
In detail, when the user walks while wearing, holding or carrying the electronic apparatus 100, since walking is a gentler activity compared with that of running, the average of the second three-axis acceleration values calculated by the processing unit 130 is smaller. Conversely, when the user runs while carrying the electronic apparatus 100, the processing unit 130, the average of the second three-axis acceleration values calculated by the processing unit 130 is greater. Therefore, the processing unit 130 can determine whether the user is in the walking status by determining whether the average of the second three-axis acceleration values is greater than the first predetermined threshold value.
In the step S250, the processing unit 130 sets the inner product values as reference values. On the other hand, in step S260, the processing unit 130 sets the outer product values as the reference values. After the steps S250 and S260, the processing unit 130 executes a step S270 to calculate a number of steps corresponding to the second three-axis acceleration values according to the reference values.
According to another aspect, when the processing unit 130 obtains each of the second three-axis acceleration values of the electronic apparatus 100, the processing unit 130 simultaneously calculates the inner product value and the outer product value corresponding to each of the second three-axis acceleration values. Then, when the processing unit 130 determines that the user is in the walking status, the processing unit 130 can calculate the number of steps according to each of the inner product values. When the processing unit 130 determines that the user is not in the walking status, the processing unit 130 can calculate the number of steps according to each of the outer product values.
In detail, when the user is in the walking status, the second three-axis acceleration values calculated by the processing unit 130 present a smaller fluctuation, and the second three-axis acceleration values have a smaller noise. In this case, if the processing unit 130 calculates the number of steps according to the outer product values corresponding to the second three-axis acceleration values, since information used for counting the number of steps is probably eliminated when the outer product values are calculated, a wrong number of steps is probably derived. However, if the number of steps is calculated according to the inner product values corresponding to the second three-axis acceleration values, the information used for counting the number of steps can be effectively retained, so as to produce an accurate step counting result.
In detail, a pattern presented by each of the second three-axis acceleration values in the chart 410, for example, corresponds to the walking status of the user. In this case, the chart 420 calculated by the processing unit 130 can still retain a pattern trend similar as that of the chart 410. Referring to the chart 430, since the information used for counting the number of steps is probably eliminated when the outer product values are calculated, a pattern trend of the chart 430 is quite different with that of the chart 410. Therefore, when the processing unit 130 determines that the user is in the walking status, the processing unit 130 calculates the number of steps according to the inner product values in the chart 420, so as to obtain an accurate step counting result.
On the other hand, when the user is in the running status, the second three-axis acceleration values calculated by the processing unit 130 present a larger fluctuation, and the second three-axis acceleration values have a larger noise. In this case, if the processing unit 130 still calculates the number of steps according to the inner product values corresponding to the second three-axis acceleration values, a wrong number of steps is probably derived due to excessive noise. However, if the number of steps is calculated according to the outer product values corresponding to the second three-axis acceleration values, the negative influence on determination of the number of steps caused by the noise can be effectively avoided, so as to produce the accurate step counting result.
In detail, a pattern presented by each of the second three-axis acceleration values in the chart 510, for example, corresponds to the running status of the user. In this case, the chart 530 calculated by the processing unit 130 can still retain a pattern trend similar as that of the chart 510. Referring to the chart 520, since the inner product values are influenced by excessive noise when the inner product values are calculated, a pattern trend thereof is quite different with that of the chart 510. Therefore, when the processing unit 130 determines that the user is not in the walking status (i.e., in the running status), the processing unit 130 calculates the number of steps according to the outer product values in the chart 530, so as to obtain an accurate step counting result.
In step S610, the processing unit 130 filters noises in the reference values. For example, the processing unit 130 perform is a moving average (MA) operation to each of the reference values to calculate a moving average of each of the reference values. In an embodiment, the MA operation is, for example, a weighted moving average (WMA) operation. Taking the WMA operation of 10 reference values as an example, the moving average corresponding to an ith reference value can be represented as:
Where d1i is the moving average corresponding to the ith reference value, di is the ith reference value. Those skilled in the art should understand that the MA operation method of the present embodiment is only an example, and the invention is not limited thereto.
Then, in step S620, the processing unit 130 calculates a plurality of slope values corresponding to the reference values. In an embodiment, the processing unit 130 differentiates each of the reference values to obtain the corresponding slope value. Therefore, the slope value corresponding to the ith reference value can be represented as:
d2i=Diff(d1i)=⅛[2d1i+d1i-1−d1i-3−2d1i-4]
Where, d2i, is the slope value corresponding to the ith reference value. Those skilled in the art should understand that the slope value calculation method of the present embodiment is only an example, and the invention is not limited thereto.
Then, in step S630, when plus and minus signs of two continuous slope values are different and a difference between the two continuous slope values is greater than a second predetermined threshold value (for example, 0.2), a counting value is accumulated, where the two continuous slope values are, for example, d2i and d2i-1 (where i is any positive integer).
Referring to
Referring to the chart 710, since the plus and minus signs of the two continuous slope values 711 and 712 are different and a difference between the two continuous slope values 711 and 712 is greater than the second predetermined threshold value (for example, 0.2), the processing unit 130 accumulates the counting value. Then, since the plus and minus signs of the two continuous slope values 713 and 714 are different and a difference between the two continuous slope values 713 and 714 is greater than the second predetermined threshold value (for example, 0.2), the processing unit 130 again accumulates the counting value.
However, although the plus and minus signs of the two continuous slope values 715 and 716 are different, since a difference between the two continuous slope values 715 and 716 is not greater than the second predetermined threshold value (for example, 0.2), the processing unit 130 does not accumulates the counting value. In this way, influence of the step counting result due to slight disturbance can be avoided.
Referring to
Referring to the chart 810, since the plus and minus signs of the two continuous slope values 811 and 812 are different and a difference between the two continuous slope values 811 and 812 is greater than the second predetermined threshold value (for example, 0.2), the processing unit 130 accumulates the counting value. Then, since the plus and minus signs of the two continuous slope values 813 and 814 are different and a difference between the two continuous slope values 813 and 814 is greater than the second predetermined threshold value (for example, 0.2), the processing unit 130 again accumulates the counting value.
Referring to
Moreover, in other embodiments, when the user is changed from the walking status to the running status, or is changed from the running status to the walking status, the processing unit 130 can further execute steps S650-S670 to accurately calculate the corresponding number of steps.
In the step S650, the processing unit 130 determines whether the average is between a first estimation value (for example, 0.2) and a second estimation value (for example, 0.5). If yes, the step S660 is executed, and if not, the step S670 is executed.
In the step S660, the processing unit 130 can multiply the number of steps by a specific parameter to update the number of steps. The specific parameter is, for example, represented as:
Where, αwalk is the first estimation value, αmotion is the second estimation value, ε is an error rate estimation value (for example, 0.3). In detail, when the average is between the first estimation value and the second estimation value, it represents that the user is changing from the walking status to the running status, or changing from the running status to the walking status, and the processing unit 130 can multiply the number of steps by the specific parameter to correct the number of steps. In this way, the electronic apparatus 100 can still produce the correct step counting result when the user is changing the motion status.
On the other hand, in the step S670, the processing unit 130 can maintain the number of steps. In detail, when the average is not between the first estimation value and the second estimation value, it represent that the user is walking or running. Therefore, the processing unit 130 does not multiply the number of steps by the specific parameter to correct the number of steps.
By respectively calculating the numbers of walking and running steps according to the inner product values and the outer product values, the method for counting steps of the invention can correctly generate the step counting result. Moreover, by adaptively multiplying the number of steps by the specific parameter, according to the method of the invention, the electronic apparatus 100 can still provide the correct step counting result when the user is changing the motion status.
Since a pattern of the chart 910 can be regarded as corresponding to the walking status, the processing unit 130 can adopt the inner product values of the chart 920 to implement follow-up operations, so as to generate the correct step counting result.
Since a pattern of the chart 1010 can be regarded as corresponding to the running status, the processing unit 130 can adopt the outer product values of the chart 1020 to implement follow-up operations, so as to generate the correct step counting result.
In summary, by calculating the number of walking or running steps according to the inner product values and the outer product values, the method for counting steps of the invention can be used to accurately generate the step counting result. Moreover, by adaptively multiplying the number of steps by the specific parameter, according to the method provided by the invention, the electronic apparatus can still provide the correct step counting result when the user is changing the motion status.
It will be apparent to those skilled in the art that various modifications and variations can be made to the structure of the invention without departing from the scope or spirit of the invention. In view of the foregoing, it is intended that the invention cover modifications and variations of this invention provided they fall within the scope of the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
103106314 | Feb 2014 | TW | national |