Professional Documents
Culture Documents
Leap Motion Developer Portal
Leap Motion Developer Portal
12/28/12 12:36 AM
DEVELOPER
News Resources
Community
Contact
IIICTECH
Search
Resources
Understanding the Python
Sample Application
DOWNLOAD
SDK
DOWNLOADS
Latest SDK
DOCUMENTATION
Overview
API Reference
UX Guidelines
Release Notes
for SDK
Leap Visualizer
Leap
Application
Setting up a
Java project
Setting up a
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 1 of 21
Topics:
Overview
Creating a Controller object
Subclassing the Listener class
Getting a Frame of data
Running the sample
12/28/12 12:36 AM
Unity project
LANGUAGE
TUTORIALS
C++
C#
Java
Python
JavaScript
Leap_SDK/sample/Sample.py
Python sample application
Leap_SDK/lib/Leap.py Leap
Python API class definitions
Leap_SDK/lib/x86/_LeapPython.pyd
32-bit Leap Python library for
Windows
Leap_SDK/lib/x64/_LeapPython.pyd
64-bit Leap Python library for
Windows
Leap_SDK/lib/_LeapPython.so
Leap Python library for Mac
Leap_SDK/lib/x86/Leap.dll 32bit Leap library for Windows
Leap_SDK/lib/x64/Leap.dll 64https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 2 of 21
12/28/12 12:36 AM
Overview
In a nutshell, the Leap motion tracking
device detects and tracks hands and
fingers placed within its field of view. The
Leap captures this data one frame at a
time. Your applications can use the Leap
API to access this data.
The sample application demonstrates how
to use the Leap API to listen for frame
events dispatched by the Leap and how to
access the hand and finger data in each
frame. The application is a small
command-line program that prints
information about detected hands and
fingers to standard output. The application
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 3 of 21
12/28/12 12:36 AM
Page 4 of 21
12/28/12 12:36 AM
Page 5 of 21
12/28/12 12:36 AM
Page 6 of 21
12/28/12 12:36 AM
Page 7 of 21
12/28/12 12:36 AM
Page 8 of 21
12/28/12 12:36 AM
Page 9 of 21
12/28/12 12:36 AM
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 10 of 21
12/28/12 12:36 AM
pos /= numFingers
print "Hand has", numFingers,
"fingers with average tip position
", pos
Page 11 of 21
12/28/12 12:36 AM
O_DEG,
normal.roll() * Leap.RAD_TO_DE
G,
direction.yaw() * Leap.RAD_TO_
DEG)
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 12 of 21
12/28/12 12:36 AM
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 13 of 21
12/28/12 12:36 AM
7 comments
Python developer on Mac here. Has
anybody tested this on a machine besides
the one that compiled the SWiG bindings?
Because it looks pretty broken from where
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 14 of 21
12/28/12 12:36 AM
I stand.
zoidberg:sandbox matt$ ls -l
total 4000
-rw-r--r--@ 1 matt staff
21386
Nov 29 20:43 Leap.py
-rw-r--r-- 1 matt staff
46560
Dec 19 14:49 Leap.pyc
-rw-r--r--@ 1 matt staff
3309
Dec 19 14:49 Sample.py
-rwxr-xr-x@ 1 matt staff
648888
Nov 29 20:43 _LeapPython.so
-rwxr-xr-x@ 1 matt staff 1318056
Nov 29 20:43 libLeap.dylib
zoidberg:sandbox matt$ python Samp
le.py
Fatal Python error: Interpreter no
t initialized (version mismatch?)
Abort trap: 6
zoidberg:sandbox matt$ which pytho
n
/usr/local/bin/python
zoidberg:sandbox matt$ python --ve
rsion
Python 2.7.3
Page 15 of 21
12/28/12 12:36 AM
and locations:
/ Library/
/Frameworks/
/Python.framewo
rk/
/Versions/
/2.7/
/Python
/ usr/
/lib/
/libstdc++
++.6.dylib
/ usr/
/lib/
/libSystem.B.dylib
/ usr/
/lib/
/libgcc_s.1.dylib
Page 16 of 21
12/28/12 12:36 AM
But no dice:
zoidberg:sandbox matt$ /Library/Fr
ameworks/Python.framework/Versions
/2.7/Python Sample.py
Fatal Python error: Interpreter no
t initialized (version mismatch?)
Abort trap: 6
Page 17 of 21
12/28/12 12:36 AM
Page 18 of 21
12/28/12 12:36 AM
Page 19 of 21
12/28/12 12:36 AM
PUBLISH COMMENT
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 20 of 21
12/28/12 12:36 AM
Privacy Policy
SDK Agreement
Copyright
2012, Leap Motion, Inc
https://developer.leapmotion.com/documentation/guide/Sample_Python_Tutorial
Page 21 of 21