SlideShare a Scribd company logo
1 of 24
Download to read offline
Leap Motion
 1st Review


Tsukasa SUGIURA
@UnaNancyOwen
12[mm]
                  LED




USB 3.0 micro-B
Youtube – Leap Motion (Leap Visualizer)
     http://youtu.be/cxlpjSUrOa0
■システムの設定
C:¥Program Files¥
                                     環境変数
                    LeapSDK               変数                    変数値
                                     LEAPMOTION_DIR    C:¥Program Files¥LeapSDK¥
                          include
                                                      ;%LEAPMOTION_DIR%lib¥x86
                                          Path
                          lib                         ;%LEAPMOTION_DIR%lib¥x64



■プロジェクトの設定(C++)
インクルード ディレクトリ                             ライブラリ ディレクトリ
                                                 $(LEAPMOTION_DIR)lib¥x86
      $(LEAPMOTION_DIR)include
                                                 $(LEAPMOTION_DIR)lib¥x64
依存ファイル
    構成                  ライブラリ
   Debug                 Leapd.lib
   Release               Leap.lib
■基本的なプログラムの構成
ヘッダファイルのインクルード
// Include Header
#include <Leap.h>
Leap::Listenerクラスを継承するサブクラスの定義
// 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 onExit( const Leap::Controller& );
                     virtual void onFrame( const Leap::Controller& );
};
コールバック関数の実装
void Listener::onInit( const Leap::Controller& controller ){ /* 実装 */ }
void Listener::onConnect( const Leap::Controller& controller ){ /* 実装 */ }
void Listener::onDisconnect( const Leap::Controller& controller ){ /* 実装 */ }
void Listener::onFrame( const Leap::Controller& controller ){ /* 実装 */ }
void Listener::onExit( const Leap::Controller& controller ){ /* 実装 */ }
メイン関数の実装
// Main
int _tmain( int argc, _TCHAR* 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;
}
class Leap::Listener

virtual void onInit( const Leap::Controller& )

インスタンス化されたときに呼び出される

virtual void onConnect( const Leap::Controller& )

コントローラーに接続(Leap::Controller::addListener())されたときに呼び出される

virtual void onDisConnect( const Leap::Controller& )

Leap Motionが外されたときに呼び出される

virtual void onFrame( const Leap::Controller& )

Leap Motionのフレームが更新されたときに呼び出される

virtual void onExit( const Leap::Controller& )

コントローラーと切断(Leap::Controller::removeListener())され、
インスタンスが破棄されたときに呼び出される
class Leap::Controller

bool addLitener( Leap::Listener &listener )

Leap::Listenerを接続する

bool removeListener( Leap::Listener &listener )

Leap::Listenerを切断する

Leap::Frame frame( int history = 0 ) const

フレーム情報(Leap::Frame)

Leap::ScreenList calibratedScreens() const

キャリブレーションしたスクリーン情報のリスト(Leap::ScreenList)

void enableGesture( Leap::Gesture::Type type, bool enable = true ) const

Leap::Gesture::Typeのジェスチャー検出を有効にする
class Leap::ScreenList

Leap::Screen operator[]( int index ) const

indexのスクリーン情報(Leap::Screen)を取得する

   Class Leap::Screen

int widthPixels() const

スクリーンの幅 [pixel]

int heightPixels() const

スクリーンの高さ [pixel]
Leap::Vector intersect( const Leap::Pointable &pointable, bool normalize
                                                  , float clampRatio = 1.0f ) const
Leap::Pointable(指など)とスクリーンの交点

bool isValid() const

スクリーン情報の有効性
class Leap::Frame

Leap::HandList hands() const

手情報のリスト(Leap::HandList)

Leap::GestureList gestures() const

ジェスチャー情報のリスト(Leap::GestureList)
class Leap::HandList

Leap::Hand operator[]( int index ) const

indexの手情報(Leap::Hand)を取得する

bool empty() const

手情報のリストが空

    Class Leap::Hand

Leap::PointableList pointables() const

ポインター情報のリスト(Leap::PointableList)

Leap::FingerList fingers() const

指情報のリスト(Leap::FingerList)
class Leap::FingerList

Leap::Finger operator[]( int index ) const

indexの指情報(Leap::Finger)を取得する

bool empty() const

指情報のリストが空

  class Leap::Finger : Leap::Pointable

Leap::Vector tipPosition() const

Leap Motion原点からの指先端のミリメートル位置(x, y, z) [mm]

Leap::Vector tipVelocity() const

指先端のミリメートル位置の秒変化率(速度) [mm/s]
class Leap::GestureList

Leap::Gesture operator[]( int index ) const

indexのジェスチャー情報(Leap::Gesture)を取得する

int count() const

リストに入っているジェスチャー情報の数

bool empty() const

ジェスチャー情報のリストが空

   class Leap::Gesture

Leap::Type type() const

検出されたジェスチャーの種類
class Leap::Gesture

Leap::Type type() const

検出されたジェスチャーの種類(Leap::Gesture::Type)

Leap::State state () const

ジェスチャーの状態(Leap::Gesture::State)
enum Leap::Gesture::Type

TYPE_SWIPE

スワイプ(指で直線運動するジェスチャー)

TYPE_CIRCLE

サークル(指で円運動するジェスチャー)

TYPE_SCREEN_TAP

スクリーンタップ(指で前向きにタッピングするジェスチャー)

TYPE_KEY_TAP

キータップ(指で下向きにタッピングするジェスチャー)
enum Leap::Gesture::State

STATE_START

ジェスチャーの開始状態

STATE_UPDATE

ジェスチャーの途中状態

STATE_STOP

ジェスチャーの修了状態
class Leap::SwipeGesture : Leap::Gesture

Leap::Vector position() const

ジェスチャーした位置(x, y, z) [mm]

Leap::Vector direction() const

ジェスチャーの方向

float speed() const

スワイプの速度 [mm/s]

Leap::Vector startPosition() const

スワイプの開始位置(x, y, z)
class Leap::CircleGesture : Leap::Gesture

Leap::Vector position() const

ジェスチャーした位置(x, y, z) [mm]

Leap::Vector direction() const

ジェスチャーの方向(::angleTo)

float radius() const

サークルの半径 [mm]

float progress() const

サークルの回転数

Leap::Vector center () const

サークルの中心位置(x, y, z)
class Leap::KeyTapGesture : Leap::Gesture

Leap::Vector position() const

ジェスチャーした位置(x, y, z) [mm]

Leap::Vector direction() const

ジェスチャーの方向

 class Leap::ScreenTapGesture : Leap::Gesture

Leap::Vector position() const

ジェスチャーした位置(x, y, z) [mm]

Leap::Vector direction() const

ジェスチャーの方向
■例:指でマウスポインタを操作する
// onFrame
void Listener::onFrame( const Leap::Controller& controller ){

   // Get first calibrated Screen
   const Leap::ScreenList screenList = controller.calibratedScreens();
   if( screenList.empty() ){
        return;
   }
   const Leap::Screen screen = screenList[0];

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

   // Get HandList
   const Leap::HandList handList = frame.hands();
   if( !handList.empty() ){
        // Get first Hand
        const Leap::Hand hand = handList[0];
// Get first Finger pointable
        const Leap::PointableList pointableList = hand.pointables();
        if( pointableList.empty() ){
             return;
        }
        const Leap::Pointable pointable = pointableList[0];

        // Get intersection between screen and ray projecting from finger
        // normalize true : intersect.x 0…1, intersect.y 0…1
        const Leap::Vector intersect = screen.intersect( pointable, true, 1.0f );
        if( !intersect.isValid() ){
             return;
        }

        // Set Mouse Pointer
        unsigned int x = screen.widthPixels() * intersect.x;
        unsigned int y = screen.heightPixels() * ( 1.0f - intersect.y );
        SetCursorPos( x, y ); // SetCursorPos() defined in #include <windows.h>
    }
}
■例:ジェスチャー(スワイプ)で左右キーを操作する
// onConnect
void Listener::onConnect( const Leap::Controller& controller ){

    // Enable detect Gesture
    controller.enableGesture( Leap::Gesture::TYPE_SWIPE );

}

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

    // Get Gesture
    const Leap::GestureList gestureList = frame.gestures();
    for( int count = 0; count < gestureList.count(); ++count ){
        Leap::Gesture gesture = gestureList[count];

       // Switch Gesture type
       switch( gesture.type() ){

          // Case of Swipe Gesture
          case Leap::Gesture::TYPE_SWIPE:
Leap::SwipeGesture swipe = gesture;

// horizontal swipe
// Swipe is horizon if diff is positive, vertical if diff is negative.
float diff = std::abs( swipe.direction().x ) - std::abs( swipe.direction().y );
if( diff > 0.0f ){
     // swipe left ( <- )
     if( swipe.direction().x > 0.0f ){
          // Check Gesture State Start
          if( swipe.state() == Leap::Gesture::STATE_START ){
               keybd_event( VK_LEFT, 0, 0, 0 );
               keybd_event( VK_LEFT, 0, KEYEVENTF_KEYUP, 0 );
          }
     }

   // swipe right ( -> )
   else{
       // Check Gesture State Start
       if( swipe.state() == Leap::Gesture::STATE_START ){
            keybd_event( VK_RIGHT, 0, 0, 0 );
            keybd_event( VK_RIGHT, 0, KEYEVENTF_KEYUP, 0 );
       }
   }
}
               break;

            default:
               break;
        }
    }
}

More Related Content

Viewers also liked

A tiny device with a huge idea ''Leap Motion''
A tiny device with a huge idea ''Leap Motion''A tiny device with a huge idea ''Leap Motion''
A tiny device with a huge idea ''Leap Motion''Sazzad Saad
 
LeapMotionとpythonで遊ぶ
LeapMotionとpythonで遊ぶLeapMotionとpythonで遊ぶ
LeapMotionとpythonで遊ぶmonochrojazz
 
Introduction to Kinect v2
Introduction to Kinect v2Introduction to Kinect v2
Introduction to Kinect v2Tsukasa Sugiura
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialTsukasa Sugiura
 
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」Tsukasa Sugiura
 
JavascriptでLeap Motion事始め
JavascriptでLeap Motion事始めJavascriptでLeap Motion事始め
JavascriptでLeap Motion事始めKenta Kowaki
 
基礎からのベイズ統計学 2章 勉強会資料
基礎からのベイズ統計学 2章 勉強会資料基礎からのベイズ統計学 2章 勉強会資料
基礎からのベイズ統計学 2章 勉強会資料at grandpa
 
基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理
基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理
基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理Ken'ichi Matsui
 
統計学の基礎の基礎
統計学の基礎の基礎統計学の基礎の基礎
統計学の基礎の基礎Ken'ichi Matsui
 
ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016
ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016
ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016Yota Ishida
 
リクルートにおける画像解析事例紹介
リクルートにおける画像解析事例紹介リクルートにおける画像解析事例紹介
リクルートにおける画像解析事例紹介Recruit Technologies
 

Viewers also liked (12)

A tiny device with a huge idea ''Leap Motion''
A tiny device with a huge idea ''Leap Motion''A tiny device with a huge idea ''Leap Motion''
A tiny device with a huge idea ''Leap Motion''
 
LeapMotionとpythonで遊ぶ
LeapMotionとpythonで遊ぶLeapMotionとpythonで遊ぶ
LeapMotionとpythonで遊ぶ
 
Introduction to Kinect v2
Introduction to Kinect v2Introduction to Kinect v2
Introduction to Kinect v2
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and Tutorial
 
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
第38回 名古屋CV・PRML勉強会 「Kinect v2本の紹介とPCLの概要」
 
JavascriptでLeap Motion事始め
JavascriptでLeap Motion事始めJavascriptでLeap Motion事始め
JavascriptでLeap Motion事始め
 
Leap motion
Leap motionLeap motion
Leap motion
 
基礎からのベイズ統計学 2章 勉強会資料
基礎からのベイズ統計学 2章 勉強会資料基礎からのベイズ統計学 2章 勉強会資料
基礎からのベイズ統計学 2章 勉強会資料
 
基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理
基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理
基礎からのベイズ統計学 輪読会資料 第1章 確率に関するベイズの定理
 
統計学の基礎の基礎
統計学の基礎の基礎統計学の基礎の基礎
統計学の基礎の基礎
 
ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016
ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016
ディープラーニングでおそ松さんの6つ子は見分けられるのか? FIT2016
 
リクルートにおける画像解析事例紹介
リクルートにおける画像解析事例紹介リクルートにおける画像解析事例紹介
リクルートにおける画像解析事例紹介
 

Similar to Leap Motion - 1st Review

Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.Yuki Higuchi
 
Guide for Swift and Viewer app
Guide for Swift and Viewer appGuide for Swift and Viewer app
Guide for Swift and Viewer appShintaro Kaneko
 
みんな大好き! Hello, World
みんな大好き! Hello, Worldみんな大好き! Hello, World
みんな大好き! Hello, WorldNaohiro Aota
 
Swift 2.0 で変わったところ「後編」 #cswift
Swift 2.0 で変わったところ「後編」 #cswiftSwift 2.0 で変わったところ「後編」 #cswift
Swift 2.0 で変わったところ「後編」 #cswiftTomohiro Kumagai
 
Composable Callbacks & Listeners
Composable Callbacks & ListenersComposable Callbacks & Listeners
Composable Callbacks & ListenersTaisuke Oe
 
Continuation with Boost.Context
Continuation with Boost.ContextContinuation with Boost.Context
Continuation with Boost.ContextAkira Takahashi
 
JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤Yuichi Sakuraba
 
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)Fujio Kojima
 
From Swing to JavaFX - SwingからJavaFXへのマイグレーションガイド
From Swing to JavaFX  - SwingからJavaFXへのマイグレーションガイドFrom Swing to JavaFX  - SwingからJavaFXへのマイグレーションガイド
From Swing to JavaFX - SwingからJavaFXへのマイグレーションガイドYuichi Sakuraba
 
デバドラを書いてみよう!
デバドラを書いてみよう!デバドラを書いてみよう!
デバドラを書いてみよう!Masami Ichikawa
 
何が変わった JavaFX 2.0
何が変わった JavaFX 2.0何が変わった JavaFX 2.0
何が変わった JavaFX 2.0Yuichi Sakuraba
 
Active Directoryデータの "大きい整数"
Active Directoryデータの "大きい整数"Active Directoryデータの "大きい整数"
Active Directoryデータの "大きい整数"Michio Koyama
 
Hive undocumented feature
Hive undocumented featureHive undocumented feature
Hive undocumented featuretamtam180
 
20130924 Picomon CRH勉強会
20130924 Picomon CRH勉強会20130924 Picomon CRH勉強会
20130924 Picomon CRH勉強会Yukihiro Kitazawa
 
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGLMedia Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGLAtsushi Tadokoro
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門uranishi
 

Similar to Leap Motion - 1st Review (20)

Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.Android Lecture #03 @PRO&BSC Inc.
Android Lecture #03 @PRO&BSC Inc.
 
VerilatorとSystemC
VerilatorとSystemCVerilatorとSystemC
VerilatorとSystemC
 
Guide for Swift and Viewer app
Guide for Swift and Viewer appGuide for Swift and Viewer app
Guide for Swift and Viewer app
 
みんな大好き! Hello, World
みんな大好き! Hello, Worldみんな大好き! Hello, World
みんな大好き! Hello, World
 
Swift 2.0 で変わったところ「後編」 #cswift
Swift 2.0 で変わったところ「後編」 #cswiftSwift 2.0 で変わったところ「後編」 #cswift
Swift 2.0 で変わったところ「後編」 #cswift
 
Composable Callbacks & Listeners
Composable Callbacks & ListenersComposable Callbacks & Listeners
Composable Callbacks & Listeners
 
Continuation with Boost.Context
Continuation with Boost.ContextContinuation with Boost.Context
Continuation with Boost.Context
 
OSC京都2011
OSC京都2011OSC京都2011
OSC京都2011
 
JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤JavaFX 2.0 - リッチクライアントのためのUI基盤
JavaFX 2.0 - リッチクライアントのためのUI基盤
 
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)「Windows 8 ストア アプリ開発 tips」  hokuriku.net vol.11 (2013年1月26日)
「Windows 8 ストア アプリ開発 tips」 hokuriku.net vol.11 (2013年1月26日)
 
From Swing to JavaFX - SwingからJavaFXへのマイグレーションガイド
From Swing to JavaFX  - SwingからJavaFXへのマイグレーションガイドFrom Swing to JavaFX  - SwingからJavaFXへのマイグレーションガイド
From Swing to JavaFX - SwingからJavaFXへのマイグレーションガイド
 
emc++ chapter32
emc++ chapter32emc++ chapter32
emc++ chapter32
 
Flashup 8
Flashup 8Flashup 8
Flashup 8
 
デバドラを書いてみよう!
デバドラを書いてみよう!デバドラを書いてみよう!
デバドラを書いてみよう!
 
何が変わった JavaFX 2.0
何が変わった JavaFX 2.0何が変わった JavaFX 2.0
何が変わった JavaFX 2.0
 
Active Directoryデータの "大きい整数"
Active Directoryデータの "大きい整数"Active Directoryデータの "大きい整数"
Active Directoryデータの "大きい整数"
 
Hive undocumented feature
Hive undocumented featureHive undocumented feature
Hive undocumented feature
 
20130924 Picomon CRH勉強会
20130924 Picomon CRH勉強会20130924 Picomon CRH勉強会
20130924 Picomon CRH勉強会
 
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGLMedia Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
Media Art II 2013 第7回 : openFrameworks 3Dグラフィクス、OpenGL
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門
 

Recently uploaded

Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Yuma Ohgami
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNetToru Tamaki
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものですiPride Co., Ltd.
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Danieldanielhu54
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A surveyToru Tamaki
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)Hiroki Ichikura
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略Ryo Sasaki
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムsugiuralab
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdftaisei2219
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...Toru Tamaki
 

Recently uploaded (10)

Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
Open Source UN-Conference 2024 Kawagoe - 独自OS「DaisyOS GB」の紹介
 
論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet論文紹介:Automated Classification of Model Errors on ImageNet
論文紹介:Automated Classification of Model Errors on ImageNet
 
SOPを理解する 2024/04/19 の勉強会で発表されたものです
SOPを理解する       2024/04/19 の勉強会で発表されたものですSOPを理解する       2024/04/19 の勉強会で発表されたものです
SOPを理解する 2024/04/19 の勉強会で発表されたものです
 
Postman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By DanielPostman LT Fukuoka_Quick Prototype_By Daniel
Postman LT Fukuoka_Quick Prototype_By Daniel
 
論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey論文紹介:Semantic segmentation using Vision Transformers: A survey
論文紹介:Semantic segmentation using Vision Transformers: A survey
 
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
【早稲田AI研究会 講義資料】3DスキャンとTextTo3Dのツールを知ろう!(Vol.1)
 
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
[DevOpsDays Tokyo 2024] 〜デジタルとアナログのはざまに〜 スマートビルディング爆速開発を支える 自動化テスト戦略
 
スマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システムスマートフォンを用いた新生児あやし動作の教示システム
スマートフォンを用いた新生児あやし動作の教示システム
 
TSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdfTSAL operation mechanism and circuit diagram.pdf
TSAL operation mechanism and circuit diagram.pdf
 
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
論文紹介:Content-Aware Token Sharing for Efficient Semantic Segmentation With Vis...
 

Leap Motion - 1st Review

  • 1. Leap Motion 1st Review Tsukasa SUGIURA @UnaNancyOwen
  • 2. 12[mm] LED USB 3.0 micro-B
  • 3. Youtube – Leap Motion (Leap Visualizer) http://youtu.be/cxlpjSUrOa0
  • 4. ■システムの設定 C:¥Program Files¥ 環境変数 LeapSDK 変数 変数値 LEAPMOTION_DIR C:¥Program Files¥LeapSDK¥ include ;%LEAPMOTION_DIR%lib¥x86 Path lib ;%LEAPMOTION_DIR%lib¥x64 ■プロジェクトの設定(C++) インクルード ディレクトリ ライブラリ ディレクトリ $(LEAPMOTION_DIR)lib¥x86 $(LEAPMOTION_DIR)include $(LEAPMOTION_DIR)lib¥x64 依存ファイル 構成 ライブラリ Debug Leapd.lib Release Leap.lib
  • 5. ■基本的なプログラムの構成 ヘッダファイルのインクルード // Include Header #include <Leap.h> Leap::Listenerクラスを継承するサブクラスの定義 // 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 onExit( const Leap::Controller& ); virtual void onFrame( const Leap::Controller& ); }; コールバック関数の実装 void Listener::onInit( const Leap::Controller& controller ){ /* 実装 */ } void Listener::onConnect( const Leap::Controller& controller ){ /* 実装 */ } void Listener::onDisconnect( const Leap::Controller& controller ){ /* 実装 */ } void Listener::onFrame( const Leap::Controller& controller ){ /* 実装 */ } void Listener::onExit( const Leap::Controller& controller ){ /* 実装 */ }
  • 6. メイン関数の実装 // Main int _tmain( int argc, _TCHAR* 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; }
  • 7. class Leap::Listener virtual void onInit( const Leap::Controller& ) インスタンス化されたときに呼び出される virtual void onConnect( const Leap::Controller& ) コントローラーに接続(Leap::Controller::addListener())されたときに呼び出される virtual void onDisConnect( const Leap::Controller& ) Leap Motionが外されたときに呼び出される virtual void onFrame( const Leap::Controller& ) Leap Motionのフレームが更新されたときに呼び出される virtual void onExit( const Leap::Controller& ) コントローラーと切断(Leap::Controller::removeListener())され、 インスタンスが破棄されたときに呼び出される
  • 8. class Leap::Controller bool addLitener( Leap::Listener &listener ) Leap::Listenerを接続する bool removeListener( Leap::Listener &listener ) Leap::Listenerを切断する Leap::Frame frame( int history = 0 ) const フレーム情報(Leap::Frame) Leap::ScreenList calibratedScreens() const キャリブレーションしたスクリーン情報のリスト(Leap::ScreenList) void enableGesture( Leap::Gesture::Type type, bool enable = true ) const Leap::Gesture::Typeのジェスチャー検出を有効にする
  • 9. class Leap::ScreenList Leap::Screen operator[]( int index ) const indexのスクリーン情報(Leap::Screen)を取得する Class Leap::Screen int widthPixels() const スクリーンの幅 [pixel] int heightPixels() const スクリーンの高さ [pixel] Leap::Vector intersect( const Leap::Pointable &pointable, bool normalize , float clampRatio = 1.0f ) const Leap::Pointable(指など)とスクリーンの交点 bool isValid() const スクリーン情報の有効性
  • 10. class Leap::Frame Leap::HandList hands() const 手情報のリスト(Leap::HandList) Leap::GestureList gestures() const ジェスチャー情報のリスト(Leap::GestureList)
  • 11. class Leap::HandList Leap::Hand operator[]( int index ) const indexの手情報(Leap::Hand)を取得する bool empty() const 手情報のリストが空 Class Leap::Hand Leap::PointableList pointables() const ポインター情報のリスト(Leap::PointableList) Leap::FingerList fingers() const 指情報のリスト(Leap::FingerList)
  • 12. class Leap::FingerList Leap::Finger operator[]( int index ) const indexの指情報(Leap::Finger)を取得する bool empty() const 指情報のリストが空 class Leap::Finger : Leap::Pointable Leap::Vector tipPosition() const Leap Motion原点からの指先端のミリメートル位置(x, y, z) [mm] Leap::Vector tipVelocity() const 指先端のミリメートル位置の秒変化率(速度) [mm/s]
  • 13. class Leap::GestureList Leap::Gesture operator[]( int index ) const indexのジェスチャー情報(Leap::Gesture)を取得する int count() const リストに入っているジェスチャー情報の数 bool empty() const ジェスチャー情報のリストが空 class Leap::Gesture Leap::Type type() const 検出されたジェスチャーの種類
  • 14. class Leap::Gesture Leap::Type type() const 検出されたジェスチャーの種類(Leap::Gesture::Type) Leap::State state () const ジェスチャーの状態(Leap::Gesture::State)
  • 17. class Leap::SwipeGesture : Leap::Gesture Leap::Vector position() const ジェスチャーした位置(x, y, z) [mm] Leap::Vector direction() const ジェスチャーの方向 float speed() const スワイプの速度 [mm/s] Leap::Vector startPosition() const スワイプの開始位置(x, y, z)
  • 18. class Leap::CircleGesture : Leap::Gesture Leap::Vector position() const ジェスチャーした位置(x, y, z) [mm] Leap::Vector direction() const ジェスチャーの方向(::angleTo) float radius() const サークルの半径 [mm] float progress() const サークルの回転数 Leap::Vector center () const サークルの中心位置(x, y, z)
  • 19. class Leap::KeyTapGesture : Leap::Gesture Leap::Vector position() const ジェスチャーした位置(x, y, z) [mm] Leap::Vector direction() const ジェスチャーの方向 class Leap::ScreenTapGesture : Leap::Gesture Leap::Vector position() const ジェスチャーした位置(x, y, z) [mm] Leap::Vector direction() const ジェスチャーの方向
  • 20. ■例:指でマウスポインタを操作する // onFrame void Listener::onFrame( const Leap::Controller& controller ){ // Get first calibrated Screen const Leap::ScreenList screenList = controller.calibratedScreens(); if( screenList.empty() ){ return; } const Leap::Screen screen = screenList[0]; // Get Frame const Leap::Frame frame = controller.frame(); // Get HandList const Leap::HandList handList = frame.hands(); if( !handList.empty() ){ // Get first Hand const Leap::Hand hand = handList[0];
  • 21. // Get first Finger pointable const Leap::PointableList pointableList = hand.pointables(); if( pointableList.empty() ){ return; } const Leap::Pointable pointable = pointableList[0]; // Get intersection between screen and ray projecting from finger // normalize true : intersect.x 0…1, intersect.y 0…1 const Leap::Vector intersect = screen.intersect( pointable, true, 1.0f ); if( !intersect.isValid() ){ return; } // Set Mouse Pointer unsigned int x = screen.widthPixels() * intersect.x; unsigned int y = screen.heightPixels() * ( 1.0f - intersect.y ); SetCursorPos( x, y ); // SetCursorPos() defined in #include <windows.h> } }
  • 22. ■例:ジェスチャー(スワイプ)で左右キーを操作する // onConnect void Listener::onConnect( const Leap::Controller& controller ){ // Enable detect Gesture controller.enableGesture( Leap::Gesture::TYPE_SWIPE ); } // onFrame void Listener::onFrame( const Leap::Controller& controller ){ // Get Gesture const Leap::GestureList gestureList = frame.gestures(); for( int count = 0; count < gestureList.count(); ++count ){ Leap::Gesture gesture = gestureList[count]; // Switch Gesture type switch( gesture.type() ){ // Case of Swipe Gesture case Leap::Gesture::TYPE_SWIPE:
  • 23. Leap::SwipeGesture swipe = gesture; // horizontal swipe // Swipe is horizon if diff is positive, vertical if diff is negative. float diff = std::abs( swipe.direction().x ) - std::abs( swipe.direction().y ); if( diff > 0.0f ){ // swipe left ( <- ) if( swipe.direction().x > 0.0f ){ // Check Gesture State Start if( swipe.state() == Leap::Gesture::STATE_START ){ keybd_event( VK_LEFT, 0, 0, 0 ); keybd_event( VK_LEFT, 0, KEYEVENTF_KEYUP, 0 ); } } // swipe right ( -> ) else{ // Check Gesture State Start if( swipe.state() == Leap::Gesture::STATE_START ){ keybd_event( VK_RIGHT, 0, 0, 0 ); keybd_event( VK_RIGHT, 0, KEYEVENTF_KEYUP, 0 ); } }
  • 24. } break; default: break; } } }