オープンソースでハンドトラッキング

ハンドトラッキングは、カメラやセンサーを使用して、手の位置、動き、形状を検出・追跡する技術です。手の動きを即時に検出してシステムを操作するリアルタイム処理だけでなく、後でデータを解析・利用する活用法も多く利用されています。

  • 3Dモデリングとアニメーション: 手の動きをキャプチャして後でアニメーションやCG制作
  • 医療・リハビリ: 記録した手の動きを解析して患者のリハビリ進捗を評価

例えば以下の画像、ドイツとオーストリアの大学の共同でハンドトラッキングを利用してゲーム形式でリハビリをする研究がなされています。

A Virtual Reality Serious Game for the Rehabilitation of Hand and Finger Function: Iterative Development and Suitability Study, University of Tuebingen, Germany, Institute for Teacher Education, University of Vienna, Austria. JMIR Serious Games
. 2024 Aug 27. https://pmc.ncbi.nlm.nih.gov/articles/PMC11387912/
目次

マーカーレス・トラッキング

以下の画像を分析します。
撮影時にトラッキング用のグローブなどを付けておらず、撮影後のメディアだけがある状態です。

Google Colabに Google Mediapipeをインストール

!pip install -q mediapipe

ハンドトラッキング用のモデルをダウンロードします。

!wget -q https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task

実行します。

import mediapipe as mp
from mediapipe.tasks import python
from mediapipe.tasks.python import vision

base_options = python.BaseOptions(model_asset_path='hand_landmarker.task')
options = vision.HandLandmarkerOptions(base_options=base_options,
                                       num_hands=2)
detector = vision.HandLandmarker.create_from_options(options)

image = mp.Image.create_from_file("/content/picture.jpg")

detection_result = detector.detect(image)
print(detection_result)

結果

HandLandmarkerResult(handedness=[[Category(index=0, score=0.9886330962181091, display_name='Right', category_name='Right')], [Category(index=1, score=0.9886988997459412, display_name='Left', category_name='Left')]], hand_landmarks=[[NormalizedLandmark(x=0.5614848732948303, y=0.7063897848129272, z=2.3229162593452202e-07, visibility=0.0, presence=0.0), NormalizedLandmark(x=0.592193603515625, y=0.6668698787689209, z=0.02681826241314411, visibility=0.0, presence=0.0), NormalizedLandmark(x=0.632768452167511, y=0.6400243043899536, z=0.02567029930651188, visibility=0.0, presence=0.0), NormalizedLandmark(x=0.6731904745101929, y=0.6315654516220093, z=0.017612889409065247, visibility=0.0, presence=0.0), 
~~~省略

結果をプロット

全身の分析とマージ

MediaPipeのポーズ分析とマージしてみます。
(手指まで含めたトラッキングを想定している方には「これが当たり前じゃないの」と思われてしまいそうですが…)

分析対象

ダンスをしている方の動画を分析します。

分析結果

フレームの前後関係を無視して、フレームごとに分析させています。
トラッキング出来てない瞬間もあります。

ハンドトラッキングするかどうか

例えば、用途によって高精度にハンドトラッキングをする必要はない場合もあると思います。

「手の形状が推測できればそれで良い」というような場合もあるでしょう。

 
 
  

当サイトの記事の一部はAIにより執筆されています。内容について最新の情報とは異なる場合も御座いますのでご留意くださいませ。最新の情報をご確認くださいますようお願い申し上げます。

よかったらシェアしてね!
目次