Mediapipe Hands Landmark提取
我的目标是从媒体管道中提取手印地标,以培训LSTM网络并识别不同的动作。
使用整体解决方案,这很容易,因为可以通过相应的功能检索左或右手的所有地标。
def extract_keypoints(results):
lh = np.array([[res.x, res.y, res.z] for res in results.left_hand_landmarks.landmark]).flatten() if results.left_hand_landmarks else np.zeros(21*3)
rh = np.array([[res.x, res.y, res.z] for res in results.right_hand_landmarks.landmark]).flatten() if results.right_hand_landmarks else np.zeros(21*3)
return np.concatenate([ lh, rh])
但是,在从Egoperspective和整体解决方案拍摄时,我会遇到手部检测问题。因此,我必须切换到MediaPipe Hands解决方案。 有了MediaPipe Hands,只有功能Multi_hand_landmarks,这只能给我一只手的地标。
if results.multi_hand_landmarks:
print(results.multi_handedness)
for hand_landmarks in results.multi_hand_landmarks:
print('hand_landmarks:', hand_landmarks)
for hand_landmarks in results.multi_hand_landmarks:
mp_drawing.draw_landmarks(image,hand_landmarks,mp_hands.HAND_CONNECTIONS,mp_drawing_styles.get_default_hand_landmarks_style(),mp_drawing_styles.get_default_hand_connections_style())
结果,我得到了这样的东西,每只手总共21个地标只需20次。
Hand_landmarks:Landmark {x:0.85794444885253906 y:0.9040373563766648 Z:2.08246397903622E-09}
是否总是在一只手之间交替出现,如果有两只手,则始终交替出现。
My goal is to extract the hand landmarks from media pipe for each hand to train an LSTM network with and to recognize different actions.
With the Holistic solution, this is quite easy, since all landmarks of the left or right hand can be retrieved via the respective function.
def extract_keypoints(results):
lh = np.array([[res.x, res.y, res.z] for res in results.left_hand_landmarks.landmark]).flatten() if results.left_hand_landmarks else np.zeros(21*3)
rh = np.array([[res.x, res.y, res.z] for res in results.right_hand_landmarks.landmark]).flatten() if results.right_hand_landmarks else np.zeros(21*3)
return np.concatenate([ lh, rh])
However, I get problems with hand detection when shooting from egoperspective and the holistic solution. So I have to switch to the mediapipe hands solution.
With mediapipe hands there is only the function MULTI_HAND_LANDMARKS, which only gives me the landmarks of one hand.
if results.multi_hand_landmarks:
print(results.multi_handedness)
for hand_landmarks in results.multi_hand_landmarks:
print('hand_landmarks:', hand_landmarks)
for hand_landmarks in results.multi_hand_landmarks:
mp_drawing.draw_landmarks(image,hand_landmarks,mp_hands.HAND_CONNECTIONS,mp_drawing_styles.get_default_hand_landmarks_style(),mp_drawing_styles.get_default_hand_connections_style())
As a result I get something like this, only 20 more times for the total of 21 landmarks per hand.
hand_landmarks: landmark { x: 0.8579444885253906 y: 0.904037356376648 z: 2.08246397903622e-09 }
Does the handlandmark output always alternate between one hand and the other if there are two hands in the picture?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您初始化
手
时,您必须设置max_num_hands = 2
,喜欢:然后
results.multi_hand_landmarks
是一个带有两个元素的列表,每个元素都在其中元素包含一只手的地标When you initialise
Hands
you have to setmax_num_hands=2
, like so:and then
results.multi_hand_landmarks
is a list with two elements, where each element contains the landmarks of one hand