mediapipeで日本手話の数字を読み取ってみた
日本手話の数字を読み取ってみました。ご参考になれば幸いです。
↓youtubeで動作をご紹介
環境と結果概要
- mediapipe:v0.7.9(メイン機)、v0.7.10(サブ機)で動作確認
- Linux:GPUで動作確認、メイン機、Ubuntu18.04
- mac:cpuで動作確認、サブ機、Catalina10.15.7、MacBook Pro
- raspberry pi 4b:Ubuntuでやってみたが動作が遅くて断念
- windowsWSL:ライブカメラで動かせない仕様、bazelのビルドまでは問題なし
- android:動作が遅くて断念、他の方の投稿では問題なさそうなので機種によるか?
- ios:苦戦中、まだ動かせていない
参考にさせて頂いたページ・資料
- 【MediaPipe】投稿記事まとめ
- Simple Hand Gesture Recognition Code
- Google公式 ※bazelやopencvのバージョン、サポートしているGPUの確認など重要
機能概要
- 日本手話の数字の認識:1-9、10、20、30、40、50、60、70、80、90
各指を3値(open/midClose/Close)で判定、判定値の組み合わせでパターン認識 - 文字の配置:プログラム開始してからの経過時間と問題と答えを画面右上に表示
- 〇の表示:問題に対する回答が読み取った手型と一致しているときに画面に赤丸を表示
ソースコード
ソースコードは検証中のもののため、動作の保証等はできかねます。ご了承の上でご使用ください。利用条件などについては公式をご覧ください。
※ソースコードは編集ファイルのみ抜粋してアップロードしています
※mediapipe本体は公式をご利用ください
編集内容概要
- ファイル追加:hand-gesture~が手型認識、assignment~が問題表示など
hand-gesture-recognition/BUILD
hand-gesture-recognition/hand-gesture-recognition-calculator.cc
hand-gesture-recognition/assignment-presentation-calculator.cc
- ファイル編集:hand-gesture~やassignment~用のinput_stream/output_streamを追加
※元ファイルから「handedness」を表示上の都合で削りました
mediapipe/graphs/hand_tracking/subgraphs/BUILD
mediapipe/graphs/hand_tracking/subgraphs/hand_landmark_cpu.pbtxt
mediapipe/graphs/hand_tracking/subgraphs/renderer_cpu.pbtxt
mediapipe/graphs/hand_tracking/subgraphs/hand_landmark_gpu.pbtxt
mediapipe/graphs/hand_tracking/subgraphs/renderer_gpu.pbtxt
- ファイル編集:文字や〇表示のため編集
mediapipe/calculators/util/annotation_overlay_calculator.cc
mediapipe/util/annotation_renderer.cc
mediapipe/util/annotation_renderer.h
コマンド
CPUのビルドコマンド
bazel build -c opt mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu --define MEDIAPIPE_DISABLE_GPU=1
CPUの実行コマンド
GLOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/hand_tracking/hand_tracking_cpu --calculator_graph_config_file=mediapipe/graphs/hand_tracking/hand_tracking_desktop_live.pbtxt
GPUのビルドコマンド
bazel run --copt -DMESA_EGL_NO_X11_HEADERS --copt -DEGL_NO_X11 mediapipe/examples/desktop/hand_tracking:hand_tracking_gpu
GPUの実行コマンド
LOG_logtostderr=1 bazel-bin/mediapipe/examples/desktop/hand_tracking/hand_tracking_gpu --calculator_graph_config_file=mediapipe/graphs/hand_tracking/hand_tracking_mobile.pbtxt
結果
mediapipeすごいです。計算カードのようなプログラムは作れそうです。
課題
- 日本語の表示はopencvではNGっぽいので別で実装する必要がありそうです
- 70、80、90の判定が不安定です
※関節が見えない手型なのでmediapipeによる推定が不安定になります
※MLなどでパターンマッチングとは別処理にしないと精度が出ないかもしれません
※各手型が安定すれば12、81など、桁を区切った入力も可能になる見込みです