OK手势通常是拇指和食指形成一个圆圈,其余三指伸直或稍微弯曲。这种手势的判断主要依靠以下特征:
- 拇指和食指的指尖靠近。
- 其余三指伸直。
判断OK手势的步骤
- 计算拇指和食指指尖之间的距离。
- 确保其余三指的指尖远离手掌根部。
import numpy as np
def is_ok_sign(hand_landmarks, wrist_idx=0, thumb_tip_idx=4, index_tip_idx=8, threshold_thumb_index=30, threshold_fingers=60):
wrist = hand_landmarks[wrist_idx]
thumb_tip = hand_landmarks[thumb_tip_idx]
index_tip = hand_landmarks[index_tip_idx]
# 计算拇指和食指指尖之间的距离
distance_thumb_index = np.linalg.norm(np.array(thumb_tip) - np.array(index_tip))
if distance_thumb_index > threshold_thumb_index:
return False
# 确保其余三指(中指、无名指、小指)的指尖与手腕的距离大于一定阈值
is_ok = True
for i in [12, 16, 20]: # Middle, Ring, Pinky finger tips
fingertip = hand_landmarks[i]
distance = np.linalg.norm(np.array(fingertip) - np.array(w


1390

被折叠的 条评论
为什么被折叠?



