手掌握拳
特征:
- 手指关节点接近手掌根部(Wrist)。
- 手指各节的相对距离很小。
算法:
- 计算每根手指(除拇指)的指尖(例如:I4、M4、R4、P4)与手腕(Wrist)之间的距离。
- 如果所有这些距离都小于一个阈值,则判断为握拳。
参考代码如下:
def is_fist(hand_landmarks, wrist_idx=0, threshold=50):
wrist = hand_landmarks[wrist_idx]
is_fist = True
for i in [8, 12, 16, 20]: # Index, Middle, Ring, Pinky finger tips
fingertip = hand_landmarks[i]
distance = np.linalg.norm(np.array(fingertip) - np.array(wrist))
if distance > threshold:
is_fist = False
break
return is_fist