在window7下,在pycharm中,编写python程序,和leapmotion交互
2017-12-11 14:39
429 查看
在window7下,在pycharm中,编写python程序,和leapmotion交互
相关参考连接:https://github.com/changkun/LeapDocCN/blob/master/python/devguide/Sample_Tutorial.md#%E8%AE%BE%E7%BD%AE%E6%96%87%E4%BB%B6
找到Leapmotion的SDK,将lib下的leap.py复制到pycharm工程中
将lib中的X64下面的leapPython.pyd和leap.dll复制到pycharm工程下
在day01目录下,新建test01.py文件
#coding=utf-8 import Leap import sys from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture class SampleListener(Leap.Listener): def on_connect(self, controller): #在你的应用程序中使用手势之前,你必须确保你要用的每一个手势都能够被识别。 #你需要使用 Controller 类中的 enableGesture() 方法使你想用的手势被识别到。 controller.enable_gesture(Leap.Gesture.TYPE_SWIPE); print "Connected" def on_frame(self, controller): frame = controller.frame() print "Frame id: %d, timestamp: %d, hands: %d, fingers: %d, tools: %d, gestures: %d" \ % ( frame.id, frame.timestamp, len(frame.hands), len(frame.fingers), len(frame.tools), len(frame.gestures())) 4000 def main(): # 创建 listener 和 controller listener = SampleListener() controller = Leap.Controller() # 对 controller 添加 listener 事件 controller.add_listener(listener) # 结束时移除 listener print "Press Enter to quit..." try: sys.stdin.readline() except KeyboardInterrupt: pass finally: # Remove the sample listener when done controller.remove_listener(listener) if __name__ == "__main__": main()
将lepamotion_Project工程设置为资源根,将day01设置为来源根
开启leapmotion,运行test01.py程序,结果如下:
相关文章推荐
- Windows 上面搭建 Spark + Pycharm/idea scala/python 本地编写Spark程序,测试通过后再提交到Linux集群上
- pycharm编辑器编写Python程序
- python 交互程序编写
- python编写简单程序访问A8系统
- 将Python代码嵌入C++程序进行编写的实例
- 蛙蛙推荐:如何编写高质量的python程序
- 【python系列】Python启动外部程序,以及进程间交互
- 编写高质量代码 改善Python程序的91个建议
- 为编写网络爬虫程序安装Python3.5
- 用Python编写运行Hello World程序
- 用Python编写MapReduce的WordCount实例程序
- python基础31[visualstudio2010来编写python程序]
- python编写微信远程控制电脑的程序
- python学习备忘之编写一个信用卡程序
- 利用Python编写一个程序 统计当前目录下的每个文件类型的文件数目
- 编写更好Python程序的5个技巧
- [2]Python学习笔记---开发Python程序的Pycharm
- Python学习疑问 ----Pycharm新文件开头自动编写
- (python)编写程序,生成包涵20个随机数的列表,然后将前10升序排列,后10降序排列
- 一个用python编写的GIS程序-simple GIS