tags: python Depth study artificial intelligence
MediaPipe is a multimedia machine learning model for developing and open source by Google Research, which can directly call its API to complete target detection, face detection, and key point detection. This article introduces 21 key points for their hands (Win10, Python Version)
MediaPipe official website: https://github.com/google/mediapipe
MediaPipe Description Document
Install MediaPipe
pip install mediapipe
Create a hand detection model
import cv2
import mediapipe as mp
mp_drawing = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands
hands = mp_hands.Hands(
static_image_mode=True,
max_num_hands=2,
min_detection_confidence=0.75,
min_tracking_confidence=0.5)
hands = mp_hands.Hands(
static_image_mode=False,
max_num_hands=2,
min_detection_confidence=0.75,
min_tracking_confidence=0.5)
HANDS is a function of detecting the key point of the hand, 4 of which can be selected
1. STATIC_IMAGE_MODE: The default is false, if set to false, it is to treat the input as a video stream. After the hand is detected, the opponent has added a target track (target detection + tracking), no need to call another test until you lose your hand Tracking. If set to True, the hand detection will run (target detection) on each input image, which is ideal for processing a batch of static, possibly related. (If the image is detected, it is necessary to set it into true)
2, MAX_NUM_HANDS: The maximum number of hands can be detected, the default is 2
3, min_detection_confidence: The minimum confidence value of the hand detection is greater than this value is considered to be successful detection. Default is 0.5
4, min_tracking_confidence: The minimum confidence value of the target trace model, which is greater than this value will be considered successfully tracked, and the default is 0.5, if static_image_mode is set to TRUE, ignore this operation.
Result output
results = hands.process(frame)
print(results.multi_handedness)
print(results.multi_hand_landmarks)
Results.Multi_Handedness: Including Label and Score, Label is a string "left" or "right", score is confidence
Results.multi_hand_landmarks: The location information of 21 key points, including x, y, z where x, y is normalized. Z represents the depth of the landmark, with the depth of the wrist, the smaller the value, the closer the landmark, the closer to the camera (I don't know what I mean for the time being)

Video detection
import cv2
import mediapipe as mp
mp_drawing = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands
hands = mp_hands.Hands(
static_image_mode=False,
max_num_hands=2,
min_detection_confidence=0.75,
min_tracking_confidence=0.75)
cap = cv2.VideoCapture(0)
while True:
ret,frame = cap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Because the camera is mirror, turn the camera horizontally
#
frame= cv2.flip(frame,1)
results = hands.process(frame)
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
if results.multi_handedness:
for hand_label in results.multi_handedness:
print(hand_label)
if results.multi_hand_landmarks:
for hand_landmarks in results.multi_hand_landmarks:
print('hand_landmarks:' hand_landmarks)
#
mp_drawing.draw_landmarks(
frame, hand_landmarks, mp_hands.HAND_CONNECTIONS)
cv2.imshow('MediaPipe Hands', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
result

Last articleWe introduced the basics of MediaPipe Holistic, learned that MediaPipe Holistic is separately used.MediaPipe Pose,MediaPipe Face MeshwithMediaPipe HandsThe gestures, facial and hand-bound ...
Python + MediaPipe + OpenCV Implement Hand Recognition First, what is MedIapi? Second, use steps Introduced 2. Main code 3. Recognition First, what is MedIapi? MediaPipe official website Second, use s...
You are good, today I share with you how to use it.MediaPipeComplete the key to real-time detection tracking. Place the picture first,15 generation FPS value。 Import kit MediaPipe is an application fr...
A review: human skeleton key point detection has been very mature, paper reference Cao Zhe Great God, can know the way of its bottom-up paper, and the detection of the human skeleton key points. way a...
MediaPipe three-dimensional real time body key detection and tracking Introduction to MEDIAPIPE 2.MediaPipe gesture detector 3. MEDIAPIPE image posture detection 4.MediaPipe camera real-time posture d...
MediaPipe 3D real -time real -time human key point detection and tracking 1.Mediapipe action count 2. Action count 2.1 push -ups 2.2 Tingled body upward 2.3 Sitting up on your back 2.3 Squatting 1.Med...
Reference link: 1) Description documentation:https://google.github.io/mediapipe 2) GitHub code link:https://github.com/google/mediapipe 3) Python Environment Configuration Documentation:https://google...
MEDIAPIPE + OpenCV implementation gesture detection Article catalog MEDIAPIPE + OpenCV implementation gesture detection I. Introduction Second, environmental configuration software: environment: Third...
1. Summary MediaPipe Face Test is a super fast face detection solution with 6 Landmarks and multiplayer face support. It is based on BlazeFace, which is a lightweight and good face -to -face detector,...
Article Directory Download the source code Install Bazelisk Set environment variables Compile and run the face_mesh sample CPU Compile and run face_mesh sample GPU Compiled into a dynamic library of 3...