Google has come up with an open source, cross-platform, customizable machine learning solution toolkit for online streaming (as well as general video, images, etc.). For those of you who are interested, go to mediapipe.dev/

It provides recognition and tracking functions for gestures, body postures, faces, objects, and other programming languages, including toolkits for C++, Python, JavaScript, and solutions for iOS and Android platforms. Today we’ll look at how to use MediaPipe’s gesture recognition to write Python code that recognizes the numbers in a gesture: 0-5.

The preparatory work

Python3 needs to be installed on the PC. Python3.8.x is recommended. In addition to installing Opencv-Python, MediaPipe, and Numpy toolkits, you can use PIP to install:

Prepare 6 pictures, 6 pictures of hands.

Write a program

  1. This handUtil module has a HandDetector class that provides methods to detect gestures and retrieve gesture data. The code is as follows. See the code comment for detailed explanation:

  2. Write another fingercount.py code that calls the method provided by handUtil. Py’s HandDetector class to retrieve gesture data. Each gesture data consists of three digits: ID, x, and y, representing a point in the gesture and its X \y coordinate position. Below is the description of each ID pair in gesture recognition.

4, 8, 12, 16 and 20 represent the tips of thumb, index finger, middle finger, ring finger and little finger respectively. The complete code is as follows:

Running the code, we can see that we can recognize the numbers in the gesture and display the corresponding picture and number

How to obtain the source code:

① More than 3000 Python ebooks ②Python development environment installation tutorial ③Python400 set self-learning video ④ software development common vocabulary ⑤Python learning roadmap ⑤ project source code case sharing if you use it can be directly taken away in my QQ technical exchange group group number: 739021630 (technical exchange and resource sharing only, no advertising allowed) to take it for yourself click here to collect it