Hi ,
I compiled the following sample .py with ubuntu
import libraries
import Leap, sys
import API
from Leap import Hand , Vector , Matrix , Frame, CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture , Listener
create a listener class
class SampleListener(Leap.Listener):
def on_init(self, controller):
print "Initialized"
def on_connect(self, controller):
print "Connected"
# Enable gestures
controller.enable_gesture(Leap.Gesture.TYPE_CIRCLE);
controller.enable_gesture(Leap.Gesture.TYPE_KEY_TAP);
controller.enable_gesture(Leap.Gesture.TYPE_SCREEN_TAP);
controller.enable_gesture(Leap.Gesture.TYPE_SWIPE);
def on_disconnect(self, controller):
# Note: not dispatched when running in a debugger.
print "Disconnected"
def on_exit(self, controller):
print "Exited"
def on_frame(self, controller):
# Get the most recent frame and report some basic information
frame = controller.frame()
if not frame.hands.is_empty:
# Get the first hand
hands = frame.hands[0]
#create basis object
#if not hands.basis.is_empty:
basis = hands.basis
if not basis.x_basis.is_empty and not basis.y_basis.is_empty:
x_basis = basis.x_basis
y_basis = basis.y_basis
vectorX = Leap.Vector(x_basis)
vectorY = Leap.Vector(y_basis)
#extract the coordinates
x = this_vectorX.x
y = this_vectorY.y
if y > 0 :
print " direction forward"
if y < 0 :
print "direction backward"
if x > 0 :
print " direction right"
if x < 0 :
print "direction left"
def state_string(self, state):
if state == Leap.Gesture.STATE_START:
return "STATE_START"
if state == Leap.Gesture.STATE_UPDATE:
return "STATE_UPDATE"
if state == Leap.Gesture.STATE_STOP:
return "STATE_STOP"
if state == Leap.Gesture.STATE_INVALID:
return "STATE_INVALID"
def main():
# Create a sample listener and controller
listener = SampleListener()
controller = Leap.Controller()
# Have the sample listener receive events from the controller
controller.add_listener(listener)
# Keep this process running until Enter is pressed
print "Press Enter to quit..."
sys.stdin.readline()
# Remove the sample listener when done
controller.remove_listener(listener)
if name == "main":
main()
The compilation gives no errors , but while execution i get the following message :
File "/home/enova6/LeapDeveloperKit/LeapSDK/python/Leap.py", line 340, in
getattr = lambda self, name: swiggetattr(self, Hand, name)
File "/home/enova6/LeapDeveloperKit/LeapSDK/python/Leap.py", line 57, in swiggetattr
raise AttributeError(name)
AttributeError: basis
Traceback (most recent call last):
File "handDirection.py", line 36, in on_frame
basis = hands.basis
File "/home/enova6/LeapDeveloperKit/LeapSDK/python/Leap.py", line 340, in
getattr = lambda self, name: swiggetattr(self, Hand, name)
File "/home/enova6/LeapDeveloperKit/LeapSDK/python/Leap.py", line 57, in swiggetattr
raise AttributeError(name)
i can't understand where does itt come from and how van i fix it ???