A method for air gesture recognition based on quaternion

Through the quaternion-based air gesture recognition method, IMU and neural network technology are used to solve the problems of limited application scenarios and low recognition rate of the three-dimensional gesture recognition method, achieving higher recognition accuracy and lower computing cost. Suitable for a variety of application scenarios.

CN113869255BActive Publication Date: 2024-09-24JILIN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111168785.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-30
Publication Date
2024-09-24
Estimated Expiration
2041-09-30

AI Technical Summary

Technical Problem

Existing 3D gesture recognition methods have problems with limited application scenarios and low recognition rates. In particular, computer vision-based methods are expensive, complex to calculate, and cannot work in dark environments, while sensor-based methods are susceptible to hand shake. , the recognition error is large.

Method used

An air gesture recognition method based on quaternions is adopted. The quaternion sequence of gestures is obtained through IMU, data preprocessing and model construction are performed, LSTM neural network and attention layer are used to extract features, and small batch algorithm, zenout algorithm and adam algorithm are combined for optimization. Neural network to realize gesture recognition.

Benefits of technology

It reduces the computational cost, reduces the complexity of data preprocessing, improves the recognition accuracy and gesture recognition rate, avoids overfitting and computational overhead, adapts to the learning rate of different parameters, and enhances the robustness and rapid convergence ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113869255B
    Figure CN113869255B
Patent Text Reader

Abstract

The present invention relates to a method for identifying pen gestures in the air based on quaternions, and belongs to the technical field of human-computer interaction. Perform a prescribed pen gesture action, obtain a quaternion sequence corresponding to the pen gesture, perform data preprocessing, construct an air pen gesture recognition model, divide the training set and the verification set, input the training set as a training sample into the air pen gesture recognition model, output the training result, input the quaternion sequence as a test set into the air pen gesture recognition model to classify the quaternion sequence, and realize pen gesture recognition. The advantage is that the data input dimension is reduced, the calculation cost is reduced, and while reducing the complexity of data preprocessing, the error caused by acceleration data drift is also reduced, and the pen gesture recognition rate can be further improved, so that the model can adapt to unstable objective functions, maintain a high recognition rate even when the sample is small, and avoid the occurrence of overfitting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of human-computer interaction, and in particular relates to an air gesture recognition method based on quaternions. Background Art

[0002] In recent years, with the continuous development of science and technology, human-computer interaction technology has provided great convenience for our daily life. The naturalness of the operation of HCI (Human-Computer Interface) devices or technologies has become one of the main considerations when selecting such devices. Therefore, it is necessary for researchers to develop HCI technologies that users can interact naturally, which can naturally convert users' intentions into corresponding commands without the need for users to learn or adapt. Among them, gesture interaction is the most common and natural way of interaction in daily life. At present, research on two-dimensional pen-based interaction paradigms, interface design and specific interaction technologies has made certain progress. However, in the three-dimensional gesture recognition method, due to the high degree of freedom of three-dimensional gestures and the complexity of recognition algorithms, the current three-dimensional gesture recognition method needs to be further improved. At present, there are many three-dimensional gesture interaction methods at home and abroad, and the common ones are three-dimensional gesture recognition methods based on computer vision and three-dimensional gesture recognition methods based on sensors.

[0003] The three-dimensional gesture recognition method based on computer vision information uses an imaging device to capture the motion trajectory, and on this basis, collects the original data of the gesture information and extracts features. The use of imaging devices greatly increases the application cost; secondly, in order to achieve a higher recognition rate, the calculation will inevitably be more complicated, which increases the calculation cost; and in actual application, due to the limitations of line of sight (LOS) and brightness, the camera-based system cannot work in dark places, which limits the actual application scenarios. In the sensor-based three-dimensional gesture recognition method, the pen movement is captured by embedding sensors. This method mostly uses accelerometers to obtain data, and accelerometers are easily affected by the user's hand shaking, resulting in large errors in trajectory estimation, and this problem has not yet been effectively solved. Summary of the invention

[0004] The present invention provides a quaternion-based mid-air gesture recognition method to solve the problems of limited application scenarios and low recognition rate in current three-dimensional gesture recognition methods.

[0005] The technical solution adopted by the present invention comprises the following steps:

[0006] Step M1: Perform a specified gesture action and obtain the quaternion sequence corresponding to the gesture through the IMU (Inertial measurement unit);

[0007] Step M2: preprocessing the quaternion sequence corresponding to the gesture;

[0008] Step M3: constructing a quaternion-based mid-air gesture recognition model;

[0009] Step M4: dividing the quaternion sequence containing multiple gesture labels into a training set and a validation set, inputting the training set as a training sample into the in-air gesture recognition model, and using a mini-batch algorithm, a Zenout algorithm, and an Adam algorithm to optimize the neural network, train the gesture recognition network model, and output the training results;

[0010] Step M5: input the quaternion sequence as a test set into the mid-air gesture recognition model, and use the trained mid-air gesture recognition model to classify the quaternion sequence to achieve gesture recognition.

[0011] Preferably, the step M1 comprises:

[0012] Step M1.1: The experimenter holds the electronic pen equipped with IMU and performs the specified gesture. Then, he presses the button to start the collection. The experimental data starts to be recorded and transmitted to the host computer. Through the feedback of trajectory morphology, the gestures that meet the requirements are screened. In order to increase the diversity of experimental data, the gesture data are collected by multiple experimenters.

[0013] Preferably, the step M2 comprises:

[0014] Step M2.1: Perform coordinate transformation on the quaternion sequence corresponding to the stroke. Since there is no requirement on the starting position of the stroke action, coordinate transformation is required so that the quaternion sequence corresponding to the stroke is only related to the quaternion of the first sampling point at the beginning of the stroke, so that the change trend of the quaternion after the coordinate system transformation will not change due to different initial positions.

[0015] Suppose the quaternion sequence corresponding to the gesture is [Q1,Q2,...,Q t ],Q1(p 01 ,p 11 ,p 21 ,p 31 ) is the quaternion of the first sampling point, Q t (p 0t ,p 1t ,p 2t ,p 3t ) is the quaternion of the t-th sampling point, and the quaternion Q of the t-th sampling point t Transformed into the sensor coordinate system Q′ relative to the initial posture of the IMU t , the calculation formula is as follows:

[0016] Q t =Q1ΘQ′ t

[0017]

[0018] in Q1 * is the conjugate of the quaternion of the first sampling point, and the quaternion obtained by IMU is a unit quaternion, so its norm is 1, and the above formula can be simplified to

[0019]

[0020] After the coordinate transformation is completed, the quaternion sequence corresponding to the gesture represents the posture sequence of the IMU relative to the initial posture, so Q′ can be t is 1, indicating that the first sampling point has not rotated relative to the initial posture. In this way, the quaternion sequence corresponding to the gesture after the coordinate system transformation can be expressed as [Q1′,Q2′,...,Q t ′];

[0021] Step M2.2: One-hot encode the labels of the quaternion sequence corresponding to the gestures, and convert the digital labels of N gestures into one-hot labels, for example, gesture label 1 corresponds to [1, 0, ..., 0], with a length of N. And so on.

[0022] Preferably, the quaternion-based mid-air gesture recognition model in step M3 is composed of a gesture feature extraction layer, an attention layer, and an output layer;

[0023] The gesture feature extraction layer is composed of a single-layer LSTM neural network, which uses the quaternion sequence corresponding to the gesture after data preprocessing as input data to extract time-varying features, and the number of neurons in the single-layer LSTM neural network is a preset number;

[0024] The attention layer selects key sampling points in the quaternion sequence by weighting on a time scale, and finds out important features in gesture recognition for recognition;

[0025] Assume that the network outputs F feature vectors h i , then the calculation method of the transformed eigenvector h′ is as follows:

[0026]

[0027] s t =f(W t h t +b t )

[0028]

[0029] where h i is the eigenvector before adjustment, h′ is the eigenvector after adjustment, α t is the weight coefficient, W t is the weight, b t is the bias, and f is the activation function. t represents the eigenvector h at time t t The energy value determined;

[0030] The output layer is a softmax layer, which can convert multi-classification values ​​into relative probabilities. The input of the output layer is the output of the attention layer, where the softmax function is as follows:

[0031]

[0032] where h i ′ is the output vector of the previous softmax layer, i represents the category index, and the total number of categories is N, S i It represents the i-th element h of the output vector i The ratio of the sum of the exponentials of all output vectors; the output layer outputs an N-dimensional vector, which represents the probability that the gesture sequence corresponds to N types of gestures;

[0033] The loss function of the output layer uses the cross entropy loss function. The cross entropy can measure the difference between the true distribution and the predicted distribution. The cross entropy loss function is often used for multi-classification problems. The cross entropy loss function needs to input the output vector of softmax and the true category, as described in the following formula:

[0034]

[0035] where y i is the true label of the gesture action corresponding to the quaternion sequence, S i is the output vector of softmax, that is, the probability value of the i-th action category, and n is the total number of gesture action categories.

[0036] The quaternion sequence corresponding to the preprocessed strokes is input into the stroke feature extraction layer, and the time series feature vector sequence obtained through the stroke feature extraction layer is input into the self-attention layer. Then, the output of the neural network is obtained through the output layer. The output of the output layer is an N-dimensional vector. The N-dimensional vectors represent the probabilities of the N strokes in the quaternion sequence corresponding to the strokes. The one with the highest probability is the final category of the network output.

[0037] Preferably, the step M4 includes dividing the quaternion sequence of multiple gesture labels into a training set and a validation set, and dividing the training set and the validation set according to the ratio of m:n, where m>n; m,n∈N*, and is random. The training set is input as a training sample into the quaternion-based air gesture recognition model, and the zenout algorithm, small batch algorithm, and adam algorithm are used to optimize the neural network, train the gesture recognition network model, and output the training results;

[0038] The Zenout algorithm refers to randomly keeping the values ​​of neurons in some hidden layers at the previous moment, or updating them as usual, so as to increase the robustness of the model and prevent overfitting.

[0039] The mini-batch algorithm refers to inputting multiple samples at a time and performing parallel operations to make the loss function converge quickly. Sequences with similar lengths are integrated into a matrix, and then batch operations are performed on quaternion sequences corresponding to strokes with similar lengths.

[0040] The adam algorithm refers to an algorithm that combines the momentum method and RMSprops, and dynamically adjusts the learning rate of each parameter using the first-order moment estimation and the second-order moment estimation of the gradient.

[0041] Preferably, step M5 includes inputting the quaternion sequence corresponding to the pen gestures as the test set into the trained in-air pen gesture recognition model, using the trained in-air pen gesture recognition model to test the pen gesture recognition accuracy, so that the model performs optimally on the test set and completes the pen gesture recognition.

[0042] The present invention has the following advantages:

[0043] (1) The present invention establishes an aerial gesture recognition model based on quaternions, which reduces the data input dimension and the computational cost. At the same time, compared with acceleration data, the quaternion data extracted from the IMU reduces the complexity of data preprocessing and also reduces the error caused by acceleration data drift.

[0044] (2) The gesture feature extraction layer of the quaternion-based mid-air gesture recognition model established by the present invention uses the LSTM layer to extract the time-varying features of the quaternion sequence corresponding to the gestures, and achieves higher prediction accuracy compared to the traditional mid-air gesture recognition model using machine learning algorithms. At the same time, the use of a single-layer LSTM avoids the exponential growth of time and memory overhead caused by too many LSTM layers. At the same time, the introduction of the attention layer can further improve the gesture recognition rate.

[0045] (3) The use of the Adam algorithm during model training allows the model to adapt to unstable objective functions and generate adaptive learning rates for different parameters, so that the model training usually requires no adjustment or only very little fine-tuning. The use of the Zenout algorithm allows the model to maintain a high recognition rate even with small samples, avoiding the occurrence of overfitting. The introduction of the mini-batch algorithm allows the model to run in parallel, converge quickly, and reduce computational overhead. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1A It is a schematic diagram of the internal structure of the electronic pen;

[0047] Figure 1B is a schematic diagram of the receiver;

[0048] Figure 2 is a flow chart of the quaternion-based mid-air gesture recognition method of the present invention;

[0049] Figure 3 This is a diagram of a mid-air gesture recognition model based on quaternions;

[0050] Figure 4 This is the LSTM network structure diagram. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation methods described herein are only used to explain the present invention and are not used to limit the present invention.

[0052] On the contrary, the present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention as defined by the claims. Further, in order to make the public have a better understanding of the present invention, some specific details are described in detail in the detailed description of the present invention below. Those skilled in the art can fully understand the present invention without the description of these details.

[0053] In order to achieve the purpose of reducing calculation cost and improving recognition rate by gesture interaction, the present invention provides a three-dimensional gesture recognition method based on quaternion.

[0054] The electronic pen used in this method is equipped with a 9-axis IMU module (9-axisIMU), an integrated microprocessor (MCU), and a wireless transmission module (RF). The receiver is then placed on a computer to receive data and complete data collection. Figure 1A , Figure 1B shown.

[0055] In this method, the experimenter performs a pen gesture to complete the collection of pen gesture data. The collected quaternion sequence is transformed into coordinates and divided into a training set and a validation set. The training set is input into the constructed LSTM-based air pen gesture recognition model, and the optimization algorithm is used to train the neural network to achieve the optimal result on the test set to complete the pen gesture recognition.

[0056] Reference Figure 2 .

[0057] The method comprises the following steps:

[0058] Step M1: Perform a specified gesture and obtain the quaternion sequence corresponding to the gesture through the IMU;

[0059] Step M2: preprocessing the quaternion sequence corresponding to the gesture;

[0060] Step M3: constructing a quaternion-based mid-air gesture recognition model;

[0061] Step M4: dividing the quaternion sequence containing multiple gesture labels into a training set and a validation set, inputting the training set as a training sample into the in-air gesture recognition model, and using a mini-batch algorithm, a Zenout algorithm, and an Adam algorithm to optimize the neural network, train the gesture recognition network model, and output the training results;

[0062] Step M5: inputting the quaternion sequence as a test set into the mid-air gesture recognition model, and classifying the quaternion sequence using the trained mid-air gesture recognition model to achieve gesture recognition;

[0063] Preferably, the step M1 comprises:

[0064] Step M1.1: The experimenter holds the electronic pen equipped with IMU and performs the specified pen gesture. Then, he presses the button to start the collection. The experimental data starts to be recorded and transmitted to the host computer. Through the feedback of trajectory morphology, the pen gestures that meet the requirements are screened. In order to increase the diversity of experimental data, the pen gesture data are collected by multiple experimenters.

[0065] Preferably, the step M2 comprises:

[0066] Step M2.1: Perform coordinate transformation on the quaternion sequence corresponding to the stroke. Since there is no requirement on the starting position of the stroke action, coordinate transformation is required so that the quaternion sequence corresponding to the stroke is only related to the quaternion of the first sampling point at the beginning of the stroke, so that the change trend of the quaternion after the coordinate system transformation will not change due to different initial positions.

[0067] Suppose the quaternion sequence corresponding to the gesture is [Q1,Q2,...,Q t ],Q1(p 01 ,p11 ,p 21 ,p 31 ) is the quaternion of the first sampling point. Q t (p 0t ,p 1t ,p 2t ,p 3t ) is the quaternion of the tth sampling point. t Transformed into the sensor coordinate system Q′ relative to the initial posture of the IMU t , the calculation formula is as follows:

[0068] Q t =Q1ΘQ′ t

[0069]

[0070] in Q1 * is the conjugate of the quaternion of the first sampling point, and the quaternion obtained by IMU is a unit quaternion, so its norm is 1, and the above formula can be simplified to

[0071]

[0072] After the coordinate transformation is completed, the quaternion sequence corresponding to the gesture represents the posture sequence of the IMU relative to the initial posture, so Q′ can be t is 1, indicating that the first sampling point has not rotated relative to the initial posture. In this way, the quaternion sequence corresponding to the gesture after the coordinate system transformation can be expressed as [Q1′,Q2′,...,Q t ′];

[0073] Step M2.2: One-hot encode the labels of the quaternion sequence corresponding to the gestures, and convert the digital labels of N gestures into one-hot labels. For example, gesture label 1 corresponds to [1, 0, ..., 0], with a length of N, and so on.

[0074] Preferably, the quaternion-based mid-air gesture recognition model in step M3 is composed of a gesture feature extraction layer, an attention layer, and an output layer; Figure 3 shown.

[0075] The quaternion sequence [Q1′,Q2′,...,Q t ′] is input into the gesture feature extraction layer, and the output of the gesture feature extraction layer is obtained [h1,h2,...,h t], the temporal feature vector sequence obtained by the gesture feature extraction layer is input into the self-attention layer, then the feature output of the self-attention layer at time t is represented as [h1′,h2′,...,h t ′], and then pass through the output layer to get the output y of the neural network t ′, the output layer outputs an N-dimensional vector, which represents the probability of N types of strokes in the quaternion sequence corresponding to the strokes, and the one with the highest probability is the final category output by the network.

[0076] The gesture feature extraction layer is composed of a single-layer LSTM neural network, which uses the quaternion sequence corresponding to the gesture after data preprocessing as input data to extract time-varying features, and the number of neurons in the single-layer LSTM neural network is preset; Figure 4 shown.

[0077] Figure C t-1 is the cell state at the previous moment, h t-1 is the hidden state at the previous moment, C t is the current cell state, is the current hidden state, Q t is the current input, Q t+1 is the next moment input, C t+1 is the cell state at the next moment, h t+1 is the hidden state at the next moment, σ is the sigmoid function, and tanh is the hyperbolic tangent function.

[0078] The attention layer refers to the attention layer, which generates a weight vector, and focuses on the important hidden states in gesture recognition by weighting the hidden states of the time scale;

[0079] Assume that the network outputs F feature vectors h i , then the calculation method of the transformed eigenvector h′ is as follows:

[0080]

[0081] s t =f(W t h t +b t )

[0082]

[0083] where h i is the eigenvector before adjustment, h′ is the eigenvector after adjustment, α t is the weight coefficient. t is the weight, b t is the bias, and f is the activation function.t represents the eigenvector h at time t t The energy value determined;

[0084] The output layer is a softmax layer, which can convert multi-classification values ​​into relative probabilities. The input of the output layer is the output of the attention layer. The softmax function is as follows:

[0085]

[0086] Where h′ is the output vector of the previous softmax layer, i represents the category index, and the total number of categories is N, S i It represents the i-th element h of the output vector i The output layer outputs an N-dimensional vector, which represents the probability that the stroke sequence corresponds to N strokes.

[0087] The loss function corresponding to softmax is the cross entropy loss function. The cross entropy can measure the difference between the true distribution and the predicted distribution. The cross entropy loss function is often used for multi-classification problems. The cross entropy loss function needs to input the output vector of softmax and the true category, as described in the following formula:

[0088]

[0089] where y i is the true label of the gesture action corresponding to the quaternion sequence, S i is the output vector of softmax, that is, the probability value of the i-th action category, and n is the total number of gesture action categories;

[0090] Preferably, the step M4 includes dividing the quaternion sequence of multiple gesture labels into a training set and a validation set, and dividing the training set and the validation set according to a ratio of m:n, where m>n; m,n∈N * , and has randomness, inputs the training set as training samples into the quaternion-based air gesture recognition model, and uses Zenout algorithm, small batch algorithm, and Adam algorithm to optimize the neural network, train the gesture recognition network model, and output the training results;

[0091] The Zenout algorithm randomly keeps the values ​​of neurons in some hidden layers at the previous moment, that is, in the hidden state of LSTM, h t and memory unit C t The value of is randomly either kept at its previous value or updated as usual to increase the robustness of the model and prevent overfitting.

[0092] The mini-batch algorithm refers to inputting multiple samples at a time and performing parallel operations to make the loss function converge quickly. Sequences with similar lengths are integrated into a matrix, and the short data is padded at the beginning with the first quaternion and at the end with the last quaternion. Then, the quaternion sequences corresponding to strokes with similar lengths are batch-operated;

[0093] The adam algorithm refers to an algorithm that combines the momentum method and RMSprops, and uses the first-order moment estimation and second-order moment estimation of the gradient to dynamically adjust the learning rate of each parameter;

[0094] Suppose that K samples {x (1) ,...,x (K)}, the corresponding target is y (i) ;

[0095] First, calculate the gradient, update the biased first-order moment estimate, and the biased second-order moment estimate, then:

[0096]

[0097] m t =μ*m t-1 +(1-μ)*g t

[0098] n t =υ*n t-1 +(1-υ)*g t 2

[0099] Where g is the gradient of the neural network; μ, υ are the exponential decay rates of the moment estimates; m t is the first-order moment estimate of the gradient; n t is a second-order estimate of the gradient;

[0100] Next, correct the deviation of the first-order moment and the second-order moment:

[0101]

[0102]

[0103] in, It is for m t , n t Correction.

[0104] Then use the corrected first-order moment and second-order moment to solve the parameter update amount to update the parameters:

[0105]

[0106] θ=θ+△θ

[0107] Among them, ε is the step size and η is the learning rate;

[0108] After the air gesture recognition model is established, each training will complete an iterative update of the network parameters. First, the initial hidden state and initial cell state are initialized, the quaternion sequence and target tensor corresponding to the gesture are input, and the model is built through forward propagation, so that the model has the ability to reason and calculate. Backward propagation uses the Zenout algorithm on all parameters, and the Adam algorithm uses gradient descent to calculate the loss function, update the weights, and observe the loss function during the training process. When the loss function reaches the minimum, the learning rate is reduced to continue training;

[0109] Preferably, step M5 includes taking the quaternion sequence corresponding to the test set gestures as input to the in-air gesture recognition model, using the trained in-air gesture recognition model, testing the gesture recognition accuracy, and completing multiple iterations to optimize the model performance on the test set.

[0110] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for air gesture recognition based on quaternions, It is characterized in that The following steps are involved: Step M1: Perform a prescribed pen gesture and obtain the quaternion sequence corresponding to the pen gesture through the IMU. The experimenter holds the electronic pen equipped with the IMU and performs the prescribed pen gesture to complete the collection of the quaternion sequence corresponding to the pen gesture; Step M2: preprocessing the quaternion sequence corresponding to the gesture; Step M2.1: coordinate transformation is performed on the obtained quaternion sequence corresponding to the stroke, so that the quaternion sequence corresponding to the stroke is only related to the quaternion of the first sampling point at the beginning of the stroke, and the change trend of the quaternion after the coordinate system transformation is completed will not change due to different initial positions; Suppose the quaternion sequence corresponding to the gesture is [Q 1 ,Q 2 ,...,Q t ],Q 1 (p 01 ,p 11 ,p 21 ,p 31 ) is the quaternion of the first sampling point, Q t (p 0t ,p 1t ,p 2t ,p 3t ) is the quaternion of the t-th sampling point, and the quaternion Q of the t-th sampling point t Transformed into the sensor coordinate system Q' relative to the initial posture of the IMU t , the calculation formula is as follows: Q t =Q 1 QQ' t in Q 1 * is the conjugate of the quaternion of the first sampling point, and the quaternion obtained by IMU is a unit quaternion, so its norm is 1, and the above formula can be simplified to After the coordinate transformation is completed, the quaternion sequence corresponding to the gesture represents the posture sequence of the IMU relative to the initial posture, so Q' t is 1, indicating that the first sampling point has not rotated relative to the initial posture. In this way, the quaternion sequence corresponding to the gesture after the coordinate system transformation can be expressed as [Q 1 ',Q 2 ',...,Q t ']; Step M2.2: One-hot encode the labels of the quaternion sequence corresponding to the gestures, and convert the digital labels of N gestures into one-hot labels; Step M3: constructing a quaternion-based mid-air gesture recognition model; the quaternion-based mid-air gesture recognition model is composed of a gesture feature extraction layer, an attention layer, and an output layer; The gesture feature extraction layer is composed of a single-layer LSTM neural network, which uses the quaternion sequence corresponding to the gesture after data preprocessing as input data to extract time-varying features; The attention layer refers to the attention layer, which generates a weight vector, and focuses on the important hidden states in gesture recognition by weighting the hidden states of the time scale; Assume that the network outputs F feature vectors h z , the calculation method of the transformed eigenvector h' is as follows: s t =f(W t h t +b t ) where z=1…t…F, h' is the adjusted eigenvector, h t is the eigenvector at time t, α t is the weight coefficient, F is the number of eigenvectors; W t is the weight, b t is the bias, f is the activation function, s t Indicates that at the tth moment, the eigenvector h t The energy value determined; The output layer is a softmax layer, which can convert multi-classification values ​​into relative probabilities. The input of the output layer is the output of the attention layer. The softmax function is as follows: Where h' is the output vector of the previous softmax layer, i represents the category index, and the total number of categories is N, S i It represents the i-th element e i The output layer outputs an N-dimensional vector, which represents the probability that the stroke sequence corresponds to N strokes. The loss function corresponding to softmax is the cross entropy loss function. The cross entropy can measure the difference between the true distribution and the predicted distribution. The cross entropy loss function is often used for multi-classification problems. The cross entropy loss function needs to input the output vector of softmax and the true category, as described in the following formula: where y i is the true label of the gesture action corresponding to the quaternion sequence, S i is the output vector of softmax, that is, the probability value of the i-th action category, and N is the total number of gesture action categories; Step M4: dividing the quaternion sequence containing multiple gesture labels into a training set and a validation set, inputting the training set as a training sample into the mid-air gesture recognition model, and using a mini-batch algorithm, a Zenout algorithm, and an Adam algorithm to optimize the neural network, train the mid-air gesture recognition network model, and output the training results; The quaternion sequence containing multiple gesture labels is divided into a training set and a validation set, and the training set and the validation set are divided according to the ratio of m:n, where m>n; m,n∈N * , and has randomness, inputs the training set as training samples into the quaternion-based air gesture recognition model, and uses Zenout algorithm, small batch algorithm, and Adam algorithm to optimize the neural network, train the gesture recognition network model, and output the training results; Step M5: input the quaternion sequence as a test set into the mid-air gesture recognition model, and use the trained mid-air gesture recognition model to classify the quaternion sequence to achieve gesture recognition.

2. The method for air gesture recognition based on quaternion according to claim 1, Features: The step M5 uses the quaternion sequence corresponding to the test set gestures as the input to the in-air gesture recognition model, uses the trained in-air gesture recognition model to test the gesture recognition accuracy, and completes multiple iterations to make the model perform optimally on the test set.