这是我使用python的第一个leap Motion应用程序。 这是我的代码:
import Leap,sys,thread,time
from Leap import CircleGesture,KeyTapGesture,ScreenTapGesture,SwipeGesture,\
Listener
class LeapMotionListener(Leap,Listener):
finger_name = ['a','b','c','d','e']
bone_name = ['a1','b1','c1','d1']
state_name =['s1','s2','s3','s4']
def on_init(self, controller):
print('initialized')
def on_connect(self, controller):
print('connected')
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):
print('disconnected')
def on_exit(self, controller):
print('Exited')
def on_frame(self, controller):
pass
def main(self):
listener = LeapMotionListener()
controller = Leap.Controller()
controller.add_listener(listener)
print('press enter to quit')
try:
sys.stdin.readline()
except KeyboardInterrupt:
pass
finally:
controller.remove_listener(listener)
if __name__ == "__main__":
LeapMotionListener.main()
但是我收到了这个错误:
追踪(最近一次通话): 文件" C:\ Users \ Qutaiba \ workspace \ 3D_Painter \ src \ aa.py",第1行,in import Leap,sys,thread,time 文件" C:\ Users \ Qutaiba \ workspace \ 3D_Painter \ src \ Leap.py",第28行,in LeapPython = swig_import_helper() 文件" C:\ Users \ Qutaiba \ workspace \ 3D_Painter \ src \ Leap.py",第24行,在swig_import_helper中 _mod = imp.load_module(' LeapPython',fp,路径名,描述) ImportError:DLL加载失败:%1不是有效的Win32应用程序。
我试过python 2.7和3.4并且显示相同的错误! 我读到我应该安装win32api,我安装它但没有改变.. 有人可以帮忙吗?