Try using Leap Motion in Python

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. finger_viz.png It's an interesting device, so it seems like it can be used for games, music, 3D modeling, and more.

Recommended Posts

Try using Leap Motion in Python
Leap Motion in Python 3
Get Leap Motion data in Python.
Try using LevelDB in Python (plyvel)
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Try gRPC in Python
Try 9 slices in Python
Try using Tweepy [Python2.7]
Try using the BitFlyer Ligntning API in Python
How to run Leap Motion in non-Apple Python
Try using ChatWork API and Qiita API in Python
Try using the DropBox Core API in Python
[Python] Try using Tkinter's canvas
Try using Kubernetes Client -Python-
Try implementing Yubaba in Python 3
Translate using googletrans in Python
Using Python mode in Processing
Try to make it using GUI and PyQt in Python
Try using Spyder included in Anaconda
Precautions when using pit in Python
Try implementing extension method in python
Try python
Try using Pleasant's API (python / FastAPI)
Let's try Fizz Buzz in Python
Try to calculate Trace in Python
Try PLC register access in Python
Using global variables in python functions
Try building a neural network in Python without using a library
Let's see using input in python
Infinite product in Python (using functools)
Edit videos in Python using MoviePy
Try using Python argparse's action API
Try running a function written in Python using Fn Project
Handwriting recognition using KNN in Python
Depth-first search using stack in Python
When using regular expressions in Python
Try using Amazon DynamoDB from Python
GUI creation in python using tkinter 2
Build and try an OpenCV & Python environment in minutes using Docker
Try to log in to Netflix automatically using python on your PC
Try using FireBase Cloud Firestore in Python for the time being
Mouse operation using Windows API in Python
Notes using cChardet and python3-chardet in Python 3.3.1.
Try logging in to qiita with Python
GUI creation in python using tkinter part 1
Get Suica balance in Python (using libpafe)
Try mathematical formulas using Σ with python
(Bad) practice of using this in Python
Slowly hash passwords using bcrypt in Python
Using venv in Windows + Docker environment [Python]
Try using the HL band in order
Try working with binary data in Python
Try sending a SYN packet in Python
Try using Dialogflow (formerly API.AI) Python SDK #dialogflow
[FX] Hit oanda-API in Python using Docker
Tweet using the Twitter API in Python
[Python] [Windows] Serial communication in Python using DLL
Try using Python with Google Cloud Functions
I tried using Bayesian Optimization in Python
Try using Junos On-box Python # 2 Commit Script