Hi,
I am really new to Leap Motion SDK and I have just been using python for a little over a year. I have the following code:
def leap_gestures(self,frame):
# Get gestures
for gesture in frame.gestures():
if gesture.type == Leap.Gesture.TYPE_CIRCLE and Leap.Gesture.STATE_STOP:
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 and circle.progress >0.8 :
clockwiseness = "clockwise"
print("%s" %clockwiseness)
elif circle.pointable.direction.angle_to(circle.normal) > Leap.PI/2 and circle.progress>0.8 :
clockwiseness = "counterclockwise"
print("%s" %clockwiseness)
if gesture.type == Leap.Gesture.TYPE_SWIPE and Leap.Gesture.STATE_START:
swipe = SwipeGesture(gesture)
if (swipe.direction.x >0 and math.fabs(swipe.direction.x)> math.fabs(swipe.direction.z)):
print("right swipe %d" %gesture.id)
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 and Leap.Gesture.STATE_STOP:
keytap = KeyTapGesture(gesture)
print("Key Tap")
if gesture.type == Leap.Gesture.TYPE_SCREEN_TAP and Leap.Gesture.STATE_STOP and detect==0:
detect=1
screentap = ScreenTapGesture(gesture)
print("Screen Tap")
if (frame.hands.is_empty and frame.gestures().is_empty):
print("")
The idea is to have this function identify what all gestures the user is doing. I do get the program to identify the direction of the swipe. But I am detecting multiple swipe in one gesture. I have gone through the forum and found similar questions but none of them seemed clear to me. Probably because I am really new in this. Also, I tried to get the pointables working but somehow that object is not recognized (I get an error when I trying printing swipe.pointable).
Could anyone help me out or point me in the right direction? I really appreciate some help