LoginSignup
0
0

Leap Motionのハンドトラッキングでキーポイントを計測する

Last updated at Posted at 2024-02-01

1.この記事の内容

Leap Motionのハンドトラッキングでキーポイントを計測する手順を紹介します.

1-1.使用環境

項目 内容
OS Windows 11 Home
バージョン 23H2
OSビルド 22635.3130
プロセッサ Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz 2.90 GHz
RAM 32GB

2.背景

仕事でLeap Motionを扱う機会が生じそうで,10年以上ぶりくらいに掘り起こしました.
デバイスが長期間眠っていたので壊れていないか心配でしたが,無事動きましたので,記念に記事にしました.

3.環境構築手順

3-1. ハンドトラッキング用のソフトウェアのダウンロードとインストール

Gemini: Ultraleap Hand Tracking SoftwareからWindows PC版をダウンロードします.
本記事の執筆時点での最新バージョンのv5.17.1をインストールしました.

トラッキング動作撮影動画

LeapMotion.gif

3-2. Leap SDKのREADME.mdに従いビルド環境を構築

"C:\Program Files\Ultraleap\LeapSDK\README.md"に従い,必要なソフトウェアをインストールし,サンプルコードをビルドします.

3-2-1. Cmakeのインストール

Cmakeの公式からバイナリ形式のインストーラをダウンロードします.
本記事の執筆時点での最新バージョンのcmake-3.28.2-windows-x86_64.msiをインストールしました.

3-2-2. サンプルコードのビルド

PowerShellを起動し,README.mdに記載の「Building Samples」の通りにコマンドを実行すればビルドできます.
筆者は環境の都合で,REPOS_BUILD_ROOTを変更しました.

ビルドログ (ここをクリックして展開)
PS E:\work\LeapMotion> $env:BUILD_TYPE = 'Release'
PS E:\work\LeapMotion> mkdir build
PS E:\work\LeapMotion> $env:REPOS_BUILD_ROOT = './build'
PS E:\work\LeapMotion> $env:REPOS_INSTALL_ROOT = 'C:/Program Files'
PS E:\work\LeapMotion> cmake -S "C:/Program Files/Ultraleap/LeapSDK/samples" -B $env:REPOS_BUILD_ROOT/$env:BUILD_TYPE/LeapSDK/leapc_example `
>> -DCMAKE_INSTALL_PREFIX="$env:REPOS_INSTALL_ROOT/leapc_example" `
>> -DCMAKE_BUILD_TYPE="$env:BUILD_TYPE"
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.22635.
-- The C compiler identification is MSVC 19.27.29111.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (3.8s)
-- Generating done (0.1s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE


-- Build files have been written to: E:/work/LeapMotion/build/Release/LeapSDK/leapc_example
PS E:\work\LeapMotion> cmake --build $env:REPOS_BUILD_ROOT/$env:BUILD_TYPE/LeapSDK/leapc_example -j --config $env:BUILD_TYPE
.NET Framework 向け Microsoft (R) Build Engine バージョン 16.7.0+b89cb5fde
Copyright (C) Microsoft Corporation.All rights reserved.

  1>Checking Build System
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  ExampleConnection.c
  libExampleConnection.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\libExampleConnection.dir\Relea
  se\libExampleConnection.lib
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  CallbackSample.c
  CheckLicenseFlagSample.c
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt
  CallbackSample.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\CallbackSample.exe
  ImageSample.c
  MultiDeviceSample.c
  InterpolationSample.c
  CheckLicenseFlagSample.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\CheckLicenseFlagSamp
  le.exe
  leapc_main.c
  ImageSample.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\ImageSample.exe
  leapc_example.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\leapc_example.exe
  PollingSample.c
  MultiDeviceSample.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\MultiDeviceSample.exe
  InterpolationSample.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\InterpolationSample.exe
  PollingSample.vcxproj -> E:\work\LeapMotion\build\Release\LeapSDK\leapc_example\Release\PollingSample.exe
  Building Custom Rule C:/Program Files/Ultraleap/LeapSDK/samples/CMakeLists.txt

4.キーポイント計測手順

手の位置と各指の位置はLEAP_HAND構造体を参照することで計測できます.
LeapSDKのサンプルコードのひとつPollingSampleでは手の位置のみを標準出力できますが,これに変更を加えて各指の位置を出力できるようにしたプログラムをGitHubへ登録しました.

4-1. 実行例

> .\build\Release\LeapSDK\PollingSample\Release\PollingSample.exe
Connected.Using device LP42563219022.
Frame 13459 with 1 hands.
    Hand id 38 is a left hand with position (-64.797859, 246.707794, 16.992355).
        Thumb:
            id: 0
            bone[0]: base(-91.133659, 241.888748, 65.009972) -> end(-91.133659, 241.888748, 65.009972)
            bone[1]: base(-91.133659, 241.888748, 65.009972) -> end(-47.805874, 245.781494, 62.818459)
            bone[2]: base(-47.805874, 245.781494, 62.818459) -> end(-23.347898, 248.223099, 63.738838)
            bone[3]: base(-23.347898, 248.223099, 63.738838) -> end(-6.898701, 249.323471, 62.594326)
        Index:
            id: 1
            bone[0]: base(-93.676407, 256.183929, 55.762794) -> end(-33.224335, 256.246918, 17.892492)
            bone[1]: base(-33.224335, 256.246918, 17.892492) -> end(-6.530300, 259.876434, 3.138434)
            bone[2]: base(-6.530300, 259.876434, 3.138434) -> end(11.486284, 259.824463, -6.346276)
            bone[3]: base(11.486284, 259.824463, -6.346276) -> end(26.791714, 258.267883, -13.713239)
        Middle:
            id: 2
            bone[0]: base(-97.274658, 256.251221, 46.566147) -> end(-45.345188, 254.924454, 3.231632)
            bone[1]: base(-45.345188, 254.924454, 3.231632) -> end(-18.572144, 260.142975, -22.617420)
            bone[2]: base(-18.572144, 260.142975, -22.617420) -> end(0.879988, 260.475037, -40.649250)
            bone[3]: base(0.879988, 260.475037, -40.649250) -> end(14.427938, 259.129425, -52.440987)
        Ring:
            id: 3
            bone[0]: base(-103.941399, 252.238602, 36.288857) -> end(-63.646683, 249.508240, -9.074807)
            bone[1]: base(-63.646683, 249.508240, -9.074807) -> end(-44.577480, 253.953903, -41.609726)
            bone[2]: base(-44.577480, 253.953903, -41.609726) -> end(-32.333912, 253.372467, -59.863441)
            bone[3]: base(-32.333912, 253.372467, -59.863441) -> end(-22.510294, 251.388672, -73.698296)
        Pinky:
            id: 4
            bone[0]: base(-112.231941, 243.168259, 32.919994) -> end(-81.384964, 241.572708, -14.058838)
            bone[1]: base(-81.384964, 241.572708, -14.058838) -> end(-77.560463, 242.904572, -39.848782)
            bone[2]: base(-77.560463, 242.904572, -39.848782) -> end(-72.845955, 240.520020, -59.050701)
            bone[3]: base(-72.845955, 240.520020, -59.050701) -> end(-68.680664, 237.484360, -72.351753)

4-2. GitHub

4-3. 関連するAPI仕様

5.さいごに

Leap Motionを使って開発しようとしている方の参考になれば幸いです.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0