Disclosure of Invention
The invention provides a mean value filtering device of triaxial acceleration data for motion detection, aiming at switching on and off a corresponding axial filtering function according to an idle axial direction of a training template when a triaxial acceleration sensor is used for data acquisition in motion detection, and performing mean value filtering on each axial data by using each buffer and each filter, so that high-frequency noise in a low-frequency motion signal is effectively filtered under the condition of low system resource consumption in the motion detection process, and the technical problems that the motion signal noise cannot be effectively filtered and the system resource consumption is high in the prior art are solved.
In order to achieve the above object, the present invention provides a mean filtering apparatus for three-axis acceleration data used for motion detection, including a motion template database, a filtering controller, an acceleration sensing data collector, an X-axis neighborhood data circular buffer, a Y-axis neighborhood data circular buffer, a Z-axis neighborhood data circular buffer, an X-axis data buffer, a Y-axis data buffer, a Z-axis data buffer, an X-axis mean filter, a Y-axis mean filter, and a Z-axis mean filter, wherein:
one or more training templates are stored in the motion template database, and the training templates contain corresponding idle axial data;
the filtering controller is used for acquiring the idle axial direction of the current training template from the motion template database and respectively sending an axial data filtering switch control instruction to the X-axis mean filter, the Y-axis mean filter and the Z-axis mean filter;
the acceleration sensing data acquisition unit is used for acquiring acceleration sampling point data of the three-axis acceleration sensor and respectively distributing acceleration components of an X axis, a Y axis and a Z axis of the sampling point data to the X axis mean filter, the Y axis mean filter and the Z axis mean filter;
the X-axis mean filter, the Y-axis mean filter and the Z-axis mean filter respectively start or close the filtering function of the X-axis mean filter, the Y-axis mean filter and the Z-axis mean filter according to the received axial data filtering switch control instruction, carry out mean filtering processing on corresponding axial acceleration components in the state that the filtering function is started, and store corresponding axial acceleration component values after the mean filtering processing into corresponding axial data buffers; and under the state that the filtering function is closed, directly storing the corresponding axial original acceleration component of the sampling point data into a corresponding axial data buffer;
the X-axis neighborhood data annular buffer, the Y-axis neighborhood data annular buffer and the Z-axis neighborhood data annular buffer are respectively used for caching neighborhood data sets of corresponding axial data of the current acceleration sensing sampling point during mean value filtering processing.
In an embodiment of the present invention, each axial mean filter performs mean filtering processing on a corresponding axial acceleration component, specifically:
updating, by the respective axial mean filter, a respective axial neighborhood ring buffer according to a respective axial acceleration component of the sample point data;
the corresponding axial mean filter obtains an updated corresponding axial neighborhood data set from the corresponding axial neighborhood ring buffer;
and carrying out mean calculation on the data in the corresponding axial neighborhood data set by the corresponding axial mean filter to obtain a mean value, and taking the obtained mean value as a corresponding axial acceleration component value after mean filtering processing.
In an embodiment of the present invention, the filtering controller is further configured to: and judging whether an external event interrupt instruction is received, if so, stopping data acquisition by the acceleration sensing data acquisition unit, or canceling the three-axis acceleration sensor and stopping mean value filtering.
In an embodiment of the present invention, the filtering controller is further configured to:
when a triaxial acceleration data filtering starting instruction is received, emptying an X-axis neighborhood data annular buffer, a Y-axis neighborhood data annular buffer and a Z-axis neighborhood data annular buffer, and emptying an X-axis data buffer, a Y-axis data buffer and a Z-axis data buffer.
In an embodiment of the present invention, the filtering controller is further configured to:
when the historical training template is not empty in the idle axial direction, comparing the idle axial direction of the current training template with the idle axial direction of the historical training template, if the idle axial direction of the current training template is the same as the idle axial direction of the historical training template, keeping the on-off state of the filtering function of each axial mean filter, and if the idle axial direction of the current training template is different from the idle axial direction of the historical training template, respectively sending corresponding data filtering switch control instructions to each axial mean filter in the sending axial direction according to the idle axial direction of the current training template so as to update the on;
and after the idle axial direction of the current training template is obtained every time, the idle axial direction of the current training template is saved as the idle axial direction of the historical training template.
In one embodiment of the invention, the mean is calculated as an arithmetic average, or a geometric average, or a harmonic average, or a weighted average, or a squared average, or an exponential average, or a median average.
In an embodiment of the present invention, the lengths of the X-axis neighborhood data circular buffer, the Y-axis neighborhood data circular buffer, and the Z-axis neighborhood data circular buffer are determined according to the current sampling frequency and the noise characteristics of the acceleration sensing data collector.
In an embodiment of the present invention, the length of the X-axis neighborhood data ring buffer, the Y-axis neighborhood data ring buffer, and the Z-axis neighborhood data ring buffer is 7.
In an embodiment of the present invention, the length of the X-axis data buffer, the Y-axis data buffer, and the Z-axis data buffer is greater than 200.
In one embodiment of the invention, the sampling frequency of the acceleration sensing data acquisition unit is 50-1000 HZ.
Generally, compared with the prior art, the technical scheme of the invention has the following beneficial effects:
(1) according to the mean filtering device for the triaxial acceleration data used for the motion detection, when the triaxial acceleration sensor is used for data acquisition in the motion detection, the filtering function of the corresponding axial direction is switched on and off according to the idle axial direction of the training template, and the mean filtering is performed on each axial data by using each buffer and each filter, so that the high-frequency noise in the low-frequency motion signal is effectively filtered under the condition of low system resource consumption in the motion detection process;
(2) according to the mean value filtering device for the triaxial acceleration data used for the motion detection, provided by the invention, the original triaxial acceleration data are cached by utilizing the neighborhood data annular buffer for subsequent mean value calculation, so that the copying of memory data does not need to be carried out in the mean value calculation process, the occupation of a minimum operation part can be obtained by utilizing the high-frequency noise in the average value smoothing signal, the filtering calculation speed is higher, and the system resource consumption is lower;
(3) according to the mean filtering device for the triaxial acceleration data used for motion detection, provided by the invention, the idle axial direction of the current training template is obtained, so that the filtering operation can be not carried out on the limb motion data in the idle axial direction (such as the horizontal or vertical direction), and the operation load of the device is greatly reduced, so that the device has smaller operation part occupation in the filtering of the limb motion acceleration data in the horizontal and vertical directions;
(4) according to the mean value filtering device for the three-axis acceleration data used for motion detection, when the inter-working operation motion detection is interrupted by the application of other smart phones, the acquisition or filtering operation of the three-axis acceleration sensor can be stopped or cancelled in time by stopping or cancelling the resources of the three-axis acceleration sensor device, so that the occupation of computing resources on the smart phones is reduced, the computing resources can be released at any time, the requirements of an operating system or other application programs on the computing resources are guaranteed, and the good experience of users is guaranteed.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Since the acceleration signal of the human limb movement is mainly a low-frequency signal, the acceleration sensor is required to have higher sensitivity. However, acceleration signals are polluted by high-frequency noise of the environment to different degrees in the processes of excitation, detection and transmission, and meanwhile, the high-frequency noise is introduced by the vibration of limbs, so that the acceleration signals of the motion of the human limbs need to be filtered and denoised.
In order to solve the above technical problem, as shown in fig. 1, the present invention provides an average filtering apparatus for three-axis acceleration data for motion detection, including:
motion template database, filtering controller, acceleration sensing data collector, X-axis neighborhood data circular buffer, Y-axis neighborhood data circular buffer, Z-axis neighborhood data circular buffer, X-axis data buffer, Y-axis data buffer, Z-axis data buffer, X-axis mean filter, Y-axis mean filter and Z-axis mean filter, wherein:
one or more training templates are stored in the motion template database, and the training templates contain corresponding idle axial data;
since the acceleration signals of the human limb movement are mainly processed by the hardware of the mobile handheld terminal, the acceleration signals need to be realized with low system resource occupation. Meanwhile, many regular motions in the horizontal and vertical directions exist in human limb motions, and the vertical direction acceleration sensing data of the motion plane in the motion types has small fluctuation. When the motion is detected, the standard degree of the motion can be judged only by using the fluctuation measurement result of the acceleration data in the direction, so that the data in the direction does not need to be filtered.
Therefore, in the filtering process, the filtering function of the idle axial direction can be closed; the idle axial direction refers to the axial direction with smaller wave and radiation in the motion process; in the gesture detection of the workshop operation, the collected actual motion gestures are compared with the pre-stored training templates to judge whether the motion gestures are standard or not. Here, the idle axes of each stage (which may be large or small, and may be set by the magnitude of change in the posture, for example) may be saved in the training template;
for example, when the upper limb moves horizontally, the fluctuation in the Z-axis direction is substantially zero, and only the data in the XY-axis direction needs to be obtained for attitude comparison, and at this time, the data in the Z-axis direction may not be filtered, but only the data in the XY-axis direction may be filtered; setting the Z axis as an idle axial direction in the training template of the action;
the specific implementation manner may be that the training module includes a three-dimensional vector [ X, Y, Z ], which is used to indicate whether the corresponding axis is idle, for example, 1 is used to indicate non-idle and 0 is used to indicate idle, or vice versa, and of course, other numbers or symbols may also be used to indicate idle or non-idle; for example, vector [1, 0, 1] indicates Y-axis idle;
the filtering controller is used for acquiring the idle axial direction of the current training template from the motion template database and respectively sending an axial data filtering switch control instruction to the X-axis mean filter, the Y-axis mean filter and the Z-axis mean filter;
in order to filter triaxial acceleration data, the device needs to cache original data acquired by a triaxial acceleration sensor, cache data in the calculation process and cache a filtering result. Therefore, in the device, each axial neighborhood data annular buffer is designed and used for storing acceleration components of an X axis, a Y axis and a Z axis of corresponding axial sampling point data, and the annular buffer is used for performing mean value calculation on current data and a plurality of historical data to realize filtering; and each axial data buffer is designed for storing the corresponding axial data result;
when new motion detection is started or the motion detection is resumed from a pause state, an instruction for starting triaxial acceleration data filtering can be issued through a motion detection application program, namely the instruction indicates that data acquisition needs to be started and mean filtering needs to be performed, at the moment, a filtering controller acquires an idle axial direction of a current training template from a motion template database, and sends axial data filtering switch control instructions to an X-axis mean filter, a Y-axis mean filter and a Z-axis mean filter according to the idle axial direction; for example, if the vector of the idle axial direction is [1, 0, 1], sending a control command of closing data filtering to the Y-axis mean filter to close the filtering function of the Y-axis mean filter;
the acceleration sensing data acquisition unit is used for acquiring acceleration sampling point data of the three-axis acceleration sensor and respectively distributing acceleration components of an X axis, a Y axis and a Z axis of the sampling point data to the X axis mean filter, the Y axis mean filter and the Z axis mean filter; if the three-axis acceleration sensor is started, directly acquiring data; if the three-axis acceleration sensor is not started, starting the three-axis acceleration sensor;
the X-axis mean filter, the Y-axis mean filter and the Z-axis mean filter respectively start or close the filtering function of the X-axis mean filter, the Y-axis mean filter and the Z-axis mean filter according to the received axial data filtering switch control instruction, carry out mean filtering processing on corresponding axial acceleration components in the state that the filtering function is started, and store corresponding axial acceleration component values after the mean filtering processing into corresponding axial data buffers; and under the state that the filtering function is closed, directly storing the corresponding axial original acceleration component of the sampling point data into a corresponding axial data buffer;
specifically, each axial mean filter performs mean filtering processing on a corresponding axial acceleration component, specifically:
updating, by the respective axial mean filter, a respective axial neighborhood ring buffer according to a respective axial acceleration component of the sample point data;
wherein the circular buffer is also called circular queue (circular queue), circular buffer (circular buffer), and ring buffer (ring buffer), which is a data structure for representing a fixed-size, head-to-tail buffer suitable for buffering data streams. The way data is updated is to overwrite the oldest data with the new data. Because only pointer operation is needed in the ring buffer, and the memory copy of data is not needed, the data storage speed is higher, and the consumption of system resources is lower;
the lengths of the X-axis neighborhood data circular buffer, the Y-axis neighborhood data circular buffer and the Z-axis neighborhood data circular buffer can be determined according to the current sampling frequency and the noise characteristic of the acceleration sensing data acquisition unit. The length of the neighborhood data circular buffer can be set to typically 3% to 9% of the current sampling frequency.
For example, the length may be set to 7% of the current sampling frequency, i.e., when the sampling frequency is 100HZ, the length of the circular buffer is set to 7.
In addition, if the noise frequency is high, the length of the ring buffer should be slightly longer; and the noise frequency is lower, the length of the ring buffer can be shorter;
the corresponding axial mean filter obtains an updated corresponding axial neighborhood data set from the corresponding axial neighborhood ring buffer;
carrying out mean calculation on the data in the corresponding axial neighborhood data set by the corresponding axial mean filter to obtain a mean value, and taking the obtained mean value as a corresponding axial acceleration component value after mean filtering processing;
specifically, the above average calculation may be an arithmetic average, a geometric average, a harmonic average, a weighted average, a square average, an exponential average, or a median average, and the following describes the calculation of each average:
arithmetic mean: arithmetic mean refers to the sum of all data in a set of data divided by the number of data. It is an index that reflects the trend in the data set. The sum of n numbers is divided by n, and the resulting quotient is called the arithmetic mean of the n numbers.
geometric averaging: the n observations, together with the n-th root of the product, are the geometric mean.
blending and averaging: harmonic means is the reciprocal of the mean of the numerical reciprocal, which is a variant of the weighted arithmetic mean, attached to the arithmetic mean, and cannot stand alone. And the calculation result is identical to the weighted arithmetic mean. The method is mainly used for solving the problem that in the case that the total unit number (frequency) cannot be mastered, only the variable value and the corresponding total mark amount of each group are needed, and the average number needs to be obtained.
weighted average: the weighted average is the average of data with different specific gravities, and the weighted average is calculated by calculating the original data according to a reasonable proportion, if n, x1Occurrence of f1Sub, x2Occurrence of f2Second, …, xkOccurrence of fkNext, then:
wherein f is
1+f
2+…+f
k=n,f
1、f
2、...、f
kAnd (5) weighting.
The average is a special case of a weighted average, i.e., the weights of the terms are equal, the weighted average is an arithmetic average.
Square average: the square mean is the arithmetic square root of the arithmetic mean of the squares of the n data.
and (4) index averaging: the construction principle of the index average is to perform arithmetic mean on the stock closing price and analyze the stock closing price according to the calculation result, so as to judge the future trend of price change.
Median average: median is the statistic of score mean, let X1,X1,…,XnIs a sample from the population, ordered from small to large as X(1),…,X(n)Then the median is defined as:
when n is an odd number: m is0.5=X(n+1)/2);
When n is an even number:
the X-axis neighborhood data annular buffer, the Y-axis neighborhood data annular buffer and the Z-axis neighborhood data annular buffer are respectively used for caching neighborhood data sets of corresponding axial data of the current acceleration sensing sampling point during mean value filtering processing.
Further, the lengths of the X-axis data buffer, the Y-axis data buffer and the Z-axis data buffer can be generally determined according to the sampling frequency of the three-axis acceleration sensor and the remaining operating memory capacity of the intelligent handheld device.
Each axial data buffer is used for storing a data result of filtering (or storing stored original data), and the data result is applied to subsequent motion detection;
if the sampling frequency is higher, the length of the data buffer can be set longer; if the sampling frequency is low, the length of the data buffer can be set to be slightly shorter; generally, the sampling frequency of the acceleration sensing data acquisition unit is 50-1000 HZ.
In addition, the length of the data cache is also related to the remaining operating memory capacity of the intelligent handheld device, and if the remaining operating memory capacity is larger, the length of the data cache can be set to be longer; if the remaining operation memory capacity is smaller, the length of the data buffer can be set shorter;
generally, to ensure that the data is sufficient for subsequent motion detection, the length of each axial data buffer should be greater than 200. For example, it may be set to 500.
Further, since there may be history data in each buffer, the history data in each buffer needs to be emptied before the filtering starts; the filter controller is therefore also configured to: when a triaxial acceleration data filtering starting instruction is received, emptying an X-axis neighborhood data annular buffer, a Y-axis neighborhood data annular buffer and a Z-axis neighborhood data annular buffer, and emptying an X-axis data buffer, a Y-axis data buffer and a Z-axis data buffer.
Further, in the case of processing acceleration sensing data with a smart phone, the inter-working motion detection may be interrupted by phone calls, short messages, and other smart phone traffic. In order to ensure that these service applications have sufficient handset resource usage to be well-sustained, it is necessary to immediately release or reduce the system resources occupied by the filtering preprocessing activity.
It is therefore desirable to determine whether the filtering process is interrupted by an external event, for example, when one or more of an incoming call request, a video or voice or text message, or any user interface operation behavior of the smart handheld device is received, or a switch is made to another application program interface, the triaxial acceleration data filtering is considered to be interrupted by an external event.
The filter controller is therefore also configured to: and judging whether an external event interrupt instruction is received, if so, stopping data acquisition by the acceleration sensing data acquisition unit, or canceling the three-axis acceleration sensor and stopping mean value filtering.
Further, due to the consistency of the motion, it is likely that the idle axes are the same for successive motions, so it is not necessary to update the on or off state of the filtering function of each axial filter at each filtering; if the idle axial direction of the training template is not changed, the on or off state of the filtering function of each axial filter is kept; if the idle axis of the training template changes, the on or off state of the filtering function of each axial filter needs to be updated.
In the invention, a storage variable can be set for storing the idle axial direction of the historical training template, namely after the idle axial direction of the current training template is obtained each time, the idle axial direction is stored in the storage variable to be used as the idle axial direction of the historical training template for idle axial comparison in the next filtering process; since the storage variable may also contain historical data, it needs to be flushed.
Therefore, the filtering controller is further configured to:
when the historical training template is not empty in the idle axial direction, comparing the idle axial direction of the current training template with the idle axial direction of the historical training template, if the idle axial direction of the current training template is the same as the idle axial direction of the historical training template, keeping the on-off state of the filtering function of each axial mean filter, and if the idle axial direction of the current training template is different from the idle axial direction of the historical training template, respectively sending corresponding data filtering switch control instructions to each axial mean filter in the sending axial direction according to the idle axial direction of the current training template so as to update the on;
and after the idle axial direction of the current training template is obtained every time, the idle axial direction of the current training template is saved as the idle axial direction of the historical training template.
According to the mean filtering device for the triaxial acceleration data used for the motion detection, when the triaxial acceleration sensor is used for data acquisition in the motion detection, the corresponding axial filtering function is switched on and off according to the idle axial direction of the training template, and the mean filtering is performed on each axial data by using each buffer and each filter, so that the high-frequency noise in the low-frequency motion signal is effectively filtered under the condition of low system resource consumption in the motion detection process, and the technical problems that the motion signal noise cannot be effectively filtered and the system resource consumption is high in the prior art are solved.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and that any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the present invention.