第22回名古屋cv・prml勉強会 「leap motion」

17
T sukasa SUGIURA @UnaNancyOwen

Upload: tsukasa-sugiura

Post on 28-Jan-2015

120 views

Category:

Technology


6 download

DESCRIPTION

2013/04/27 第22回 名古屋CV/PRML勉強会 「Leap Motion」 http://partake.in/events/f5d0c496-6428-4f8e-88f5-76b49f606b98 Ustream - セッション2 「LeapMotionの紹介」-2 http://ustre.am/:2al27 Togetter http://togetter.com/li/494350

TRANSCRIPT

Tsukasa SUGIURA

@UnaNancyOwen

12.7

[mm

]

USB 3.0 micro-B

LED

Leap Motion DEV BOARD v.06.5

Infrared Camera

Infrared LED

Leap Motion DEV BOARD v.04

Leap Motion

• Leap Motionは手,指,ツールを 高精度かつ高フレームレートで検出・追跡できるデバイス

– 精度は1/100mm,フレームレートは290fps

– 有効範囲はデバイスの上方25-600mm,150°の逆ピラミッド状

– 79.99USD + 送料

Hand, Finger, Tool

• Leap Motionで取得できる情報 – 位置

– 移動速度

– 回転角度

– 方向

などの様々な情報が取得可能

指先の方向 掌の方向

Gesture

• 様々なジェスチャーを認識可能

Swipe Circle

Key Tap Screen Tap

System Requirement

Hardware

• USB 2.0 or 3.0

OS

• Windows 7 or 8

• Mac OS 10.6 and higher

Language and Compiler

• C++

– Visual Studio 2008, 2010, 2012

– Xcode 3.0+, clang 3.0+ and gcc

• Objective-C

– Xcode 4.2+, clang 3.0+

• Unity Pro 4.0

• C#

– .NET Framework 3.5, 4.0

– Mono 2.10

• Java 6, 7

• Python 2.7.3

• JavaScript

• Linux Ubuntu 12.04 LTS, 12.10

Basic Flow

// Include Header

#include <Leap.h>

// Listener

class Listener : public Leap::Listener{

public:

virtual void onInit( const Leap::Controller& );

virtual void onConnect( const Leap::Controller& );

virtual void onDisconnect( const Leap::Controller& );

virtual void onFrame( const Leap::Controller& );

virtual void onExit( const Leap::Controller& );

};

void Listener::onInit( const Leap::Controller& controller ){ /* Processing */ }

void Listener::onConnect( const Leap::Controller& controller ){ /* Processing */ }

void Listener::onDisconnect( const Leap::Controller& controller ){ /* Processing */ }

void Listener::onFrame( const Leap::Controller& controller ){ /* Processing */ }

void Listener::onExit( const Leap::Controller& controller ){ /* Processing */ }

Basic Flow

// Main

int main( int argc, char *argv[] ){

// Create a listener and controller

Listener listener;

Leap::Controller controller;

// Have the listener receive events from the controller

controller.addListener( listener );

// Keep this process running until Enter is pressed

std::cout << "Press Enter to quit..." << std::endl;

std::cin.get();

// Remove the listener when done

controller.removeListener( listener );

return 0;

}

Calibration

Demo 1 : Leap Visualizer

Youtube :Leap Motion (Leap Visualizer)

http://youtu.be/cxlpjSUrOa0

Demo 2 : Google Earth

Youtube : Control the Google Earth with Leap Motion

http://youtu.be/cL3jCcQXmUc

Example

• PowerPointをジェスチャーで操作する

// onConnect

void Listener::onConnect( const Leap::Controller& controller )

{

// Enable Background App

controller.setPolicyFlags( Leap::Controller::POLICY_BACKGROUND_FRAMES );

// Enable detect Gesture

controller.enableGesture( Leap::Gesture::TYPE_SWIPE );

}

// onFrame

void Listener::onFrame( const Leap::Controller& controller )

{

// Get Frame from Controller

const Leap::Frame frame = controller.frame();

// Get Gesture from Frame

const Leap::GestureList gestureList = frame.gestures();

for( int count = 0; count < gestureList.count(); ++count ){

Leap::Gesture gesture = gestureList[count];

Example

// Switch Gesture Type

switch( gesture.type() ){

// Case of Swipe Gesture

case Leap::Gesture::TYPE_SWIPE:

Leap::SwipeGesture swipeGesture = gesture;

// Swipe direction is horizontal if diff is positive, vertical if diff is negative

float diff = std::abs( swipeGesture.direction().x ) - std::abs( swipeGesture.direction().y );

if( diff > 0.0f ){

// Swipe Left ( <- )

if( swipeGesture.direction().x > 0.0f ){

if( swipeGesture.state() == Leap::Gesture::STATE_START ){

keybd_event( VK_RIGHT, 0, 0, 0 );

keybd_event( VK_RIGHT, 0, KEYEVENTF_KEYUP, 0 );

}

}

// Swipe Right ( -> )

else{

if( swipeGesture.state() == Leap::Gesture::STATE_START ){

keybd_event( VK_LEFT, 0, 0, 0 );

keybd_event( VK_LEFT, 0, KEYEVENTF_KEYUP, 0 );

}

}

}

break;

Example

default:

break;

}

}

}

Summary

• 手,指,ツールを高精度かつ高フレームレートで 検出・追跡できるデバイス

• 様々なジェスチャーを認識できる

• とても安価(79.99USD + 送料)に入手できる

• 使い道は考える必要がある…

– 他のデバイスではなくLeap Motionを使う必然性