手掌张开
特征:
- 手指关节点远离手掌根部,手指之间的距离较大。
算法:
- 计算每根手指(包括拇指)的指尖(T4、I4、M4、R4、P4)与手腕(Wrist)之间的距离。
- 如果所有这些距离都大于一个阈值,则判断为手掌张开。
def is_open_hand(hand_landmarks, wrist_idx=0, threshold=100):
wrist = hand_landmarks[wrist_idx]
is_open = True
for i in [4, 8, 12, 16, 20]: # Thumb, Index, Middle, Ring, Pinky finger tips
fingertip = hand_landmarks[i]
distance = np.linalg.norm(np.array(fingertip) - np.array(wrist))
if distance < threshold:
is_open = False
break
return is_open