A method for quickly recognizing a gesture based on a greedy heuristic algorithm
Patent Information
- Application Number
- CN202410936084.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2044-07-12
AI Technical Summary
[0019]针对现有技术的不足,本发明提供了一种基于贪心启发式算法快速识别手势的方法,解决了现有技术在数据、计算资源、开发周期、模型透明度和实时性方面的挑战的问题
[0089]与现有技术相比,本发明提供了一种基于贪心启发式算法快速识别手势的方法,具备以下有益效果:
Smart Images

Figure CN118968611B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of gesture recognition, specifically a method for fast gesture recognition based on a greedy heuristic algorithm. Background Technology
[0002] Gesture recognition technology enables an intuitive human-computer interaction method, controlling computers or other smart devices by analyzing and understanding user gestures. This technology greatly enriches the diversity of user interfaces, particularly in mobile devices, virtual reality environments, interactive games, and smart home systems. Although traditional gesture recognition methods rely on accurate feature extraction and powerful classification algorithms, they still face challenges such as improving accuracy, supporting a wider range of gestures, and achieving real-time, latency-free feedback.
[0003] Existing technical solutions primarily rely on neural networks to recognize gestures, employing deep learning methods to automatically identify complex gestures. This process typically includes the following steps:
[0004] 1. Data Preparation: Collect a comprehensive gesture dataset, including diverse gesture images or paths and corresponding category labels. Ensure the dataset covers a wide range of gesture types and user variations.
[0005] 2. Data preprocessing: Perform necessary preprocessing operations on the collected data, such as image normalization, filtering, and enhancement, to improve the efficiency and accuracy of neural network learning.
[0006] 3. Network Design: Construct a neural network architecture suitable for gesture recognition tasks. Commonly used network models include Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs), as well as their derivatives. These models can effectively extract gesture features.
[0007] 4. Network Training: Train the neural network using the prepared dataset. During training, adjust the network parameters using the backpropagation algorithm, enabling the network to learn the key features that distinguish different gestures.
[0008] 5. Network Evaluation: The performance of the trained neural network is evaluated using an independent test set. Metrics such as accuracy, recall, and F1 score are used to measure the recognition performance.
[0009] 6. Real-time recognition: The trained neural network is integrated into practical applications for real-time gesture recognition. During application, the network processes the input gesture data in real time and outputs the predicted gesture category.
[0010] The advantage of neural network methods lies in their excellent feature extraction capabilities and adaptability; the network can automatically recognize patterns in complex gestures. However, this method typically requires a large amount of labeled data and significant computational resources for effective training, and may face certain challenges in recognizing gesture categories with small sample sizes or specific scenarios.
[0011] In summary, the main drawbacks of existing technologies include:
[0012] 1. High data requirements: Neural network gesture recognition technology requires a large amount of labeled data to train the model, which places high demands on data collection and preprocessing.
[0013] 2. High computational resource consumption: Deep learning models typically require significant computational resources, including high-performance GPUs and large amounts of memory, which is a limitation on resource-constrained devices.
[0014] 3. Long training and tuning time: Training and tuning neural network models may take a long time, which affects the development cycle and iteration speed.
[0015] 4. Model complexity and opacity: The black-box nature of deep learning models makes it difficult to understand and explain the model's decision-making process.
[0016] 5. Real-time performance challenges: Although existing technologies can handle complex gestures, the inference speed of the model may become a bottleneck in scenarios that require real-time feedback.
[0017] To address the aforementioned shortcomings, we propose a method for fast gesture recognition based on a greedy heuristic algorithm. Summary of the Invention
[0018] (a) Technical problems to be solved
[0019] To address the shortcomings of existing technologies, this invention provides a method for fast gesture recognition based on a greedy heuristic algorithm, which solves the challenges of existing technologies in terms of data, computing resources, development cycle, model transparency, and real-time performance.
[0020] (II) Technical Solution
[0021] To achieve the above-mentioned objectives, the present invention provides the following technical solution: a method for fast gesture recognition based on a greedy heuristic algorithm, comprising the following steps:
[0022] Step 1: Collect a set of points representing the user's gesture trajectory;
[0023] Step 2: Resample the given set of points;
[0024] Step 3: Normalize the sampled point set so that all points are uniformly scaled to a predetermined range;
[0025] Step 4: Translate the scaled point set to the origin of the coordinate system;
[0026] Step 5: Use a greedy algorithm to perform gesture matching, and select the best match by calculating the matching distance between the candidate point set and the template point set.
[0027] Preferably, the second step includes the following:
[0028] Calculate the total path length of consecutive points:
[0029]
[0030] Where d(pi,pi+1) is the Euclidean distance between point pi and point pi+1, and N is the number of points in the original point set;
[0031] Calculate the interval length I:
[0032]
[0033] Where n is the number of points after resampling;
[0034] For each pair of consecutive points, if the cumulative distance D+d between the two points is greater than or equal to the interval length I, then insert a new point q between these two points. The coordinates (qx, qy) of the new point are obtained by linear interpolation between the two points, using the following formula:
[0035]
[0036] Where D is the cumulative distance from the previous resampled point to the current point pi−1, and d is the distance between point pi−1 and point pi;
[0037] If a new point is inserted, the cumulative distance D is reset to 0; otherwise, D is updated to D+d.
[0038] If the last point is not added due to rounding error, add the last point of the original point set to the resampled point set.
[0039] Preferably, the third step includes the following:
[0040] Finding the minimum bounding box containing all points is achieved by calculating the minimum and maximum X and Y coordinates of all points in the point set:
[0041]
[0042] Where i iterates over all points;
[0043] Determine the scaling size:
[0044]
[0045] For each point pi in the point set, calculate its new coordinates (qx, qy) within the normalized square;
[0046]
[0047] Construct a new set of points, where each point has the same stroke ID.
[0048] Preferably, the fourth step includes the following:
[0049] Calculate the centroid:
[0050]
[0051] Where N is the total number of points in the point set;
[0052] Calculate the new coordinates;
[0053]
[0054] Construct a new set of points.
[0055] Preferably, the fifth step includes the following:
[0056] S1: Initialize the best matching variables: Let the index u of the best matching template be initially -1, and the best matching score b be initially positive infinity;
[0057] S2: Traverse the template point set set: For each point set Pi in the point set template set set, where i=0,1,...,n−1, and n is the number of all template point sets;
[0058] S3: Calculate the matching distance di between the candidate point set C and the template point set Pi:
[0059]
[0060] S4: If di is less than the current best matching score b, then update b to di, and update the index u of the best matching template to the index i of the current template;
[0061] If no matching template is found (i.e., u=−1), the result of no match is returned; otherwise, the name of the best matching template and the matching score are returned, which is calculated based on the value of b.
[0062]
[0063] Constructing a result object: If u = −1, it indicates no match; otherwise, it contains the name and score of the best matching template.
[0064]
[0065] Where C is the candidate point set, Pu is the best matching point set template, u is the index of the best matching template, b is the minimum matching distance, and score is the matching score calculated based on b.
[0066] Preferably, the Match calculation is as follows:
[0067] (4) Define the greedy matching parameter: Let e be a parameter between 0 and 1, used to determine the step size step. step is a power function based on the length of the point set, calculated as follows:
[0068]
[0069] (5) Initialize the minimum distance: Set the minimum distance min to positive infinity initially;
[0070] (6) Traverse the point set: Starting from index i=0, traverse the point set points with step size step, and perform the following steps:
[0071] a. Calculate the distance d1 between the point set points[i] and the point set P.Points:
[0072]
[0073] b. Calculate the distance d2 between the point set P.Points[i] and the point set points:
[0074]
[0075] c. Update the minimum distance min to the smaller of d1 and d2;
[0076] (4) Return the minimum distance: the final calculated minimum distance min;
[0077] Here, min is the operator for finding the minimum value, and PointsDistance calculates the sum of the minimum weighted distances between two point sets.
[0078] Preferably, the PointsDistance calculation process is as follows:
[0079] (1) Initialize the matching array: Create a boolean array matched with a length equal to the length of pts1, and initialize all elements to false;
[0080] Calculate the weighted distance sum: Initialize the sum `sum` to 0. Then, iterate from the starting point `start` until you return to `start`:
[0081]
[0082] Where wi is the weight, defined as:
[0083]
[0084] And Unmatched is the set of all points in pts2 that have not yet been matched;
[0085] Returns the weighted distance sum: When the iteration returns to the starting point start, it returns the sum.
[0086] The Distance function calculates the Euclidean distance between two points:
[0087] .
[0088] (III) Beneficial Effects
[0089] Compared with existing technologies, this invention provides a method for fast gesture recognition based on a greedy heuristic algorithm, which has the following advantages:
[0090] 1. The method for fast gesture recognition based on a greedy heuristic algorithm, compared with neural network methods which require a large amount of labeled data, represents gestures as a set of points, reducing the dependence on a large amount of training data and reducing the workload of data collection and labeling.
[0091] 2. The method for fast gesture recognition based on the greedy heuristic algorithm uses the greedy heuristic algorithm for point set matching. Its complexity is relatively low, and it can run with low computing resources without requiring significant computing resources and a large amount of memory.
[0092] 3. The method for fast gesture recognition based on a greedy heuristic algorithm can accelerate the development and iteration speed of gesture recognition systems and reduce the development cycle due to the simplicity and ease of implementation of the algorithm.
[0093] 4. Compared with the black-box nature of deep learning models, the method of this invention, which is based on a greedy heuristic algorithm for fast gesture recognition, adopts a greedy heuristic algorithm, making the decision-making process more transparent and easier to understand, debug and optimize.
[0094] 5. This method for fast gesture recognition based on a greedy heuristic algorithm uses accumulated Euclidean distances for rapid matching, which helps to achieve high-speed gesture recognition and meet the needs of real-time interaction. Attached Figure Description
[0095] Figure 1 This is a schematic diagram of the process of the present invention. Detailed Implementation
[0096] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0097] Please see Figure 1 A method for fast gesture recognition based on a greedy heuristic algorithm includes the following steps:
[0098] I. Pretreatment
[0099] (1) The given point set is resampled to adjust the number of points to the specified 32, while preserving the original shape features as much as possible. The specific process is as follows:
[0100] 1. Calculate the total path length: First, we calculate the total path length L of the point set by summing the Euclidean distances between consecutive points:
[0101]
[0102] Where d(pi,pi+1) is the Euclidean distance between point pi and point pi+1, and N is the number of points in the original point set.
[0103] 2. Calculate the interval length: Next, calculate the equal interval length I, which is the total path length divided by the number of points after resampling minus one (because the starting point of the path is already included):
[0104]
[0105] Where n is the number of points after resampling.
[0106] 3. Point Interpolation: Iterate through each pair of consecutive points. If the cumulative distance D+d between two points is greater than or equal to the interval length I, then insert a new point q between these two points. The coordinates (qx, qy) of the new point are obtained by linear interpolation between the two points, using the following mathematical formula:
[0107]
[0108] Where D is the cumulative distance from the previous resampled point to the current point pi−1, and d is the distance between point pi−1 and point pi.
[0109] 4. Update cumulative distance: If a new point is inserted, the cumulative distance D is reset to 0; otherwise, D is updated to D+d.
[0110] 5. Handling boundary cases: Finally, if the last point is not added due to rounding error, add the last point of the original point set to the resampled point set.
[0111] (2) Normalize the sampled point set so that all points are uniformly scaled to a predetermined range, usually within a unit square. This eliminates differences in gesture size, allowing the recognition algorithm to focus on the shape of the gesture rather than its size.
[0112] 1. Calculate the bounding box: First, we need to find the minimum bounding box that contains all the points. This is done by calculating the minimum and maximum X and Y coordinates of all points in the point set:
[0113]
[0114] Where i traverses all points.
[0115] 2. Determine the scaling size: Next, we determine the scaling size, which is the maximum of the width and height of the bounding box:
[0116]
[0117] 3. Scaling Points: Then, for each point pi in the point set, we calculate its new coordinates (qx, qy) within the normalized square. This is done by subtracting the minimum coordinates and dividing by the scaling dimension:
[0118]
[0119] 4. Construct a new point set: Finally, we use the newly calculated coordinates (qx, qy) to construct a new point set, where each point has the same stroke ID.
[0120] Through the above steps, the points in the sampled point set are converted into normalized coordinates, so that all gestures are scaled to the same size range.
[0121] (3) Translate the scaled point set to the origin of the coordinate system. This eliminates differences in gesture position, allowing the recognition algorithm to focus on the shape of the gesture rather than its location.
[0122] 1. Calculating the centroid: First, we need to calculate the centroid (center point) of the point set. This is done by averaging the X and Y coordinates of all points:
[0123]
[0124] Where N is the total number of points in the point set.
[0125] 2. Calculate the new coordinates: Next, for each point pi in the point set, we calculate its new coordinates (qx, qy) relative to the centroid translated to the origin (0, 0):
[0126]
[0127] Constructing a new point set: Finally, we use the newly calculated coordinates (qx, qy) to construct a new point set, where each point has the same stroke ID.
[0128] II. Gesture Matching
[0129] Define the candidate point set: Let C be the input point set, given by the parameter points.
[0130] Initialize the best matching variables: Let the index u of the best matching template be initially -1, and the best matching score b be initially positive infinity.
[0131] Traverse the template point set: For each point set Pi in the template point set, where i = 0, 1, ..., n−1, and n is the number of all template point sets, perform the following steps:
[0132] a. Calculate the matching distance di between the candidate point set C and the template point set Pi:
[0133]
[0134] b. If di is less than the current best matching score b, then update b to di, and update the index u of the best matching template to the index i of the current template.
[0135] Return result: If no matching template is found (i.e., u=−1), return "No match"; otherwise, return the name of the best matching template and the matching score. The matching score is calculated based on the value of b, as follows:
[0136]
[0137] Constructing a result object: If u = −1, it indicates no match; otherwise, it contains the name and score of the best matching template.
[0138]
[0139] Where C is the candidate point set, Pu is the best matching point set template, u is the index of the best matching template, b is the minimum matching distance, and score is the matching score calculated based on b.
[0140] Match is calculated as follows:
[0141] (7) Define the greedy matching parameter: Let e be a parameter between 0 and 1, used to determine the step size step. step is a power function based on the length of the point set, calculated as follows:
[0142]
[0143] (8) Initialize minimum distance: Set the minimum distance min to positive infinity initially.
[0144] (9) Traverse the point set: Starting from index i=0, traverse the point set points with step size step, and perform the following steps:
[0145] a. Calculate the distance d1 between the point set points[i] and the point set P.Points:
[0146]
[0147] b. Calculate the distance d2 between the point set P.Points[i] and the point set points:
[0148]
[0149] c. Update the minimum distance min to the smaller of d1 and d2.
[0150] (4) Return the minimum distance: the final calculated minimum distance min.
[0151] Here, `min` is the operator that takes the minimum value. `PointsDistance` calculates the minimum weighted sum of distances between two sets of points. This is a greedy algorithm because it selects the minimum available distance at each step. This process is very efficient because it reduces computation while maintaining robustness to shape changes.
[0152] The calculation process for PointsDistance is as follows:
[0153] (2) Initialize the matching array: Create a boolean array matched with a length equal to the length of pts1, and initialize all elements to false.
[0154] Calculate the weighted distance sum: Initialize the sum `sum` to 0. Then, iterate from the starting point `start` until you return to `start`:
[0155]
[0156] Where wi is the weight, defined as:
[0157]
[0158] And Unmatched is the set of all points in pts2 that have not yet been matched.
[0159] Returns the weighted distance sum: When the iteration returns to the starting point start, it returns the sum sum.
[0160] The Distance function calculates the Euclidean distance between two points:
[0161] .
[0162] In summary, the advantages of this invention include reduced data requirements, lower computational resource consumption, shorter development cycles, increased model transparency, and improved real-time performance. These advantages make the gesture recognition method of this invention more efficient and feasible in practical applications.
[0163] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for fast gesture recognition based on a greedy heuristic algorithm, characterized in that, Includes the following steps: Step 1: Collect a set of points representing the user's gesture trajectory; Step 2: Resample the given set of points; Step 3: Normalize the sampled point set so that all points are uniformly scaled to a predetermined range; Step 4: Translate the scaled point set to the origin of the coordinate system; Step 5: Use a greedy algorithm to perform gesture matching, and select the best match by calculating the matching distance between the candidate point set and the template point set; The second step includes the following: Calculate the total path length of consecutive points: ; Where d(pi,pi+1) is the Euclidean distance between point pi and point pi+1, and N is the number of points in the original point set; Calculate the interval length I: ; Where n is the number of points after resampling; For each pair of consecutive points, if the cumulative distance D+d between the two points is greater than or equal to the interval length I, then insert a new point q between these two points. The coordinates (qx, qy) of the new point are obtained by linear interpolation between the two points, using the following formula: ; Where D is the cumulative distance from the previous resampled point to the current point pi−1, and d is the distance between point pi−1 and point pi; If a new point is inserted, the cumulative distance D is reset to 0; otherwise, D is updated to D+d. If the last point is not added due to rounding error, add the last point of the original point set to the resampled point set; The third step includes the following: Finding the minimum bounding box containing all points is achieved by calculating the minimum and maximum X and Y coordinates of all points in the point set: ; Where i iterates over all points; Determine the scaling size: ; For each point pi in the point set, calculate its new coordinates (qx, qy) within the normalized square; ; Construct a new set of points, where each point has the same stroke ID; The fourth step includes the following: Calculate the centroid: ; Where N is the total number of points in the point set; Calculate the new coordinates; ; Construct a new set of points; The fifth step includes the following: S1: Initialize the best matching variables: Let the index u of the best matching template be initially -1, and the best matching score b be initially positive infinity; S2: Traverse the template point set set: For each point set Pi in the point set template set set, where i=0,1,...,n−1, and n is the number of all template point sets; S3: Calculate the matching distance di between the candidate point set C and the template point set Pi: ; S4: If di is less than the current best matching score b, then update b to di, and update the index u of the best matching template to the index i of the current template; If no matching template is found (i.e., u=−1), the result of no match is returned; otherwise, the name of the best matching template and the matching score are returned, which is calculated based on the value of b. ; Constructing a result object: If u = −1, it indicates no match; otherwise, it contains the name and score of the best matching template. ; Where C is the candidate point set, Pu is the best matching point set template, u is the index of the best matching template, b is the minimum matching distance, and score is the matching score calculated based on b. Match is calculated as follows: (1) Define the greedy matching parameter: Let e be a parameter between 0 and 1, used to determine the step size step; step is a power function based on the length of the point set, calculated as follows: ; (2) Initialize the minimum distance: Set the minimum distance min to positive infinity initially; (3) Traverse the point set: Starting from index i=0, traverse the point set points with step size step, and perform the following steps: a. Calculate the distance d1 between the point set points[i] and the point set P.Points: ; b. Calculate the distance d2 between the point set P.Points[i] and the point set points: ; c. Update the minimum distance min to the smaller of d1 and d2; (4) Return the minimum distance: the final calculated minimum distance min; Here, min is the operator for finding the minimum value, and PointsDistance calculates the sum of the minimum weighted distances between two point sets.
2. The method for fast gesture recognition based on a greedy heuristic algorithm according to claim 1, characterized in that: The calculation process for PointsDistance is as follows: (1) Initialize the matching array: Create a boolean array matched with a length equal to the length of pts1, and initialize all elements to false; Calculate the weighted distance sum: Initialize the sum `sum` to 0; then, iterate from the starting point `start` until you return to `start`: ; Where wi is the weight, defined as: ; And Unmatched is the set of all points in pts2 that have not yet been matched; Returns the weighted distance sum: When the iteration returns to the starting point start, it returns the sum sum; The Distance function calculates the Euclidean distance between two points: 。
Citation Information
Patent Citations
Method for identifying single gesture through track matching based on cosine similarity
CN117975568A
Customer path tracking method and system
WO2020088136A1