我想使用Leap Motion来获取我的食指尖端位置(3D位置X,Y,Z),我怎么能在跳跃运动中做到这一点?
这是我只检测食指,但有一个错误:
def on_frame(self, controller):
# Get the most recent frame and report some basic information
frame = controller.frame()
finger = Finger.TYPE_INDEX
print('Type : '+finger.type())
time.sleep(3)
我是一个跳跃动作初学者,我希望你指导我如何做到这一点,如果有任何例子或代码?
谢谢 :)
1 回答
首先,看看documentation for the Leap Motion Python API . 然后检查SDK示例文件夹中的Sample.py程序 . Sample.py提供了一个示例,用于获取API提供的所有可用信息 .
对于您上面的具体问题,
Finger.TYPE_INDEX
为您提供了食指的枚举或名称;它没有给你一个表示食指的物体的实例 - 那里有's an index finger for each of your hands and there can be multiple hands in the Leap device'的视野 - 所以它应该返回哪个食指?您可以从
frame.fingers()
获取所有被跟踪手指的列表以及hand.fingers()
中特定手的被跟踪手指列表 . 从这些列表中,您可以使用名称(即Finger.TYPE_INDEX
或TYPE_THUMB
)过滤特定类型的手指 .