I bought a small gesture control device called Leap Motion and tried it with python. Since my environment is ubuntu 12.04, I will get the SDK for it from the developer site. (User registration required) When you unzip the downloaded file, there is a folder called LeapSDK in it, so the following files in lib in it will be the files necessary to run with python.
I used a module called VPython for 3D display. The following is the simple viewer created this time.
finger_viz.py
#!/usr/bin/python
#coding:utf-8
from visual import *
import Leap
scene = display(title='Leap Motion Example',
x = 0, y = 0, width = 600, height = 600,
center = (5, 0, 0), background = (0, 1, 1),
visible = True,
scale = (0.005, 0.005, 0.005),
autoscale = False)
balls = [sphere(radius=10, color=color.red, visible=False) for _ in range(10)]
controller = Leap.Controller()
while True:
rate(100)
f = controller.frame()
for idx, ball in enumerate(balls):
if idx < len(f.fingers):
ball.visible = True
ball.pos = (f.fingers[idx].tip_position.x,
f.fingers[idx].tip_position.y,
f.fingers[idx].tip_position.z)
else:
ball.visible = False
The actual display screen looks like this. It's pretty simple and only the fingertips are displayed. It's an interesting device, so it seems like it can be used for games, music, 3D modeling, and more.
Recommended Posts