我将最新的python库用于Leap Motion。我简化了代码,以打印出用户所做的手势。但是我的问题是,有时会检测到多个手势。我正在使用的代码部分是:
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_CIRCLE:
circle = CircleGesture(gesture)
# Determine clock direction using the angle between the pointable and the circle normal
if circle.pointable.direction.angle_to(circle.normal) <= Leap.PI/2:
clockwiseness = "clockwise"
print("%s" %clockwiseness)
elif circle.pointable.direction.angle_to(circle.normal) > Leap.PI/2:
clockwiseness = "counterclockwise"
print("%s" %clockwiseness)
if gesture.type == Leap.Gesture.TYPE_SWIPE:
swipe = SwipeGesture(gesture)
if (swipe.direction.x >0 and math.fabs(swipe.direction.x)> math.fabs(swipe.direction.z)):
print("right swipe")
elif (swipe.direction.x <0 and math.fabs(swipe.direction.x)>math.fabs(swipe.direction.z)):
print("left swipe")
#Since the camera will be facing the user, the up and down motion will be characterized by the z co-ordinte
elif (swipe.direction.z<0 and math.fabs(swipe.direction.z)> math.fabs(swipe.direction.x)):
print("up swipe")
elif (swipe.direction.z>0 and math.fabs(swipe.direction.z)>math.fabs(swipe.direction.x)):
print("down swipe")
if gesture.type == Leap.Gesture.TYPE_KEY_TAP:
keytap = KeyTapGesture(gesture)
print("Screen Tap")
if gesture.type == Leap.Gesture.TYPE_SCREEN_TAP:
screentap = ScreenTapGesture(gesture)
print("Key Tap")
if (frame.hands.is_empty and frame.gestures().is_empty):
print("")
有时,我要滑动它以检测下一帧中的滑动手势和圆圈手势,所以输出结果是同时检测滑动手势和圆圈手势,而我只是尝试进行滑动手势。有没有一种方法可以在执行一个手势时禁用其他手势识别?例如,当我使用滑动手势时,请禁用圆圈和屏幕点击,反之亦然。我不了解Leap运动,现在已经尝试了几天的解决方案。我什至尝试过
controller.enable_gesture(Leap.Gesture.TYPE_CIRCLE,false)
看看是否可行,但是没有。任何建议和帮助将不胜感激。谢谢