•  


GitHub - Kazuhito00/hand-gesture-recognition-using-mediapipe: MediaPipe(Python版)を用いて手の姿勢推定を行い、?出したキ?ポイントを用いて、簡易なMLPでハンドサインとフィンガ?ジェスチャ?を認識するサンプルプログラムです。(Estimate hand pose using MediaPipe(Python version). This is a sample program that recognizes hand signs and finger gestures with a simple MLP using the detected key points.)
Skip to content

MediaPipe(Python版)を用いて手の姿勢推定を行い、?出したキ?ポイントを用いて、簡易なMLPでハンドサインとフィンガ?ジェスチャ?を認識するサンプルプログラムです。(Estimate hand pose using MediaPipe(Python version). This is a sample program that recognizes hand signs and finger gestures with a simple MLP using the detected key points.)

License

Notifications You must be signed in to change notification settings

Kazuhito00/hand-gesture-recognition-using-mediapipe

Repository files navigation

[Japanese/ English ]

Note
キ?ポイント分類について、モデルを集めたリポジトリを作成しました。
Kazuhito00/hand-keypoint-classification-model-zoo

hand-gesture-recognition-using-mediapipe

MediaPipe(Python版)を用いて手の姿勢推定を行い、?出したキ?ポイントを用いて、
簡易なMLPでハンドサインとフィンガ?ジェスチャ?を認識するサンプルプログラムです。 mqlrf-s6x16

本リポジトリは以下の?容を含みます。

  • サンプルプログラム
  • ハンドサイン認識モデル(TFLite)
  • フィンガ?ジェスチャ?認識モデル(TFLite)
  • ハンドサイン認識用?習デ?タ、および、?習用ノ?トブック
  • フィンガ?ジェスチャ?認識用?習デ?タ、および、?習用ノ?トブック

Requirements

  • mediapipe 0.8.4
  • OpenCV 4.6.0.66 or Later
  • Tensorflow 2.9.0 or Later
  • protobuf <3.20,>=3.9.2
  • scikit-learn 1.0.2 or Later (?習時に混同行列を表示したい場合のみ)
  • matplotlib 3.5.1 or Later (?習時に混同行列を表示したい場合のみ)

Demo

Webカメラを使ったデモの?行方法は以下です。

python app.py

DockerとWebカメラを使ったデモの?行方法は以下です。

docker build -t hand_gesture 
.


xhost +local: 
&&
 \
docker run --rm -it \
--device /dev/video0:/dev/video0 \
-v 
`
pwd
`
:/home/user/workdir \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
-e DISPLAY=
$DISPLAY
 \
hand_gesture:latest

python app.py

デモ?行時には、以下のオプションが指定可能です。

  • --device
    カメラデバイス番?の指定 (デフォルト:0)
  • --width
    カメラキャプチャ時の?幅 (デフォルト:960)
  • --height
    カメラキャプチャ時の?幅 (デフォルト:540)
  • --use_static_image_mode
    MediaPipeの推論にstatic_image_modeを利用するか否か (デフォルト:未指定)
  • --min_detection_confidence
    ?出信?値の?値 (デフォルト:0.5)
  • --min_tracking_confidence
    トラッキング信?値の?値 (デフォルト:0.5)

Directory

│  app.py
│  keypoint_classification.ipynb
│  point_history_classification.ipynb
│
├─model
│  ├─keypoint_classifier
│  │  │  keypoint.csv
│  │  │  keypoint_classifier.hdf5
│  │  │  keypoint_classifier.py
│  │  │  keypoint_classifier.tflite
│  │  └─ keypoint_classifier_label.csv
│  │
│  └─point_history_classifier
│      │  point_history.csv
│      │  point_history_classifier.hdf5
│      │  point_history_classifier.py
│      │  point_history_classifier.tflite
│      └─ point_history_classifier_label.csv
│
└─utils
    └─cvfpscalc.py

app.py

推論用のサンプルプログラムです。
また、ハンドサイン認識用の?習デ?タ(キ?ポイント)、
フィンガ?ジェスチャ?認識用の?習デ?タ(人差指の座標履?)を?集することもできます。

keypoint_classification.ipynb

ハンドサイン認識用のモデル訓練用スクリプトです。

point_history_classification.ipynb

フィンガ?ジェスチャ?認識用のモデル訓練用スクリプトです。

model/keypoint_classifier

ハンドサイン認識に?わるファイルを格納するディレクトリです。
以下のファイルが格納されます。

  • ?習用デ?タ(keypoint.csv)
  • ?習?モデル(keypoint_classifier.tflite)
  • ラベルデ?タ(keypoint_classifier_label.csv)
  • 推論用クラス(keypoint_classifier.py)

model/point_history_classifier

フィンガ?ジェスチャ?認識に?わるファイルを格納するディレクトリです。
以下のファイルが格納されます。

  • ?習用デ?タ(point_history.csv)
  • ?習?モデル(point_history_classifier.tflite)
  • ラベルデ?タ(point_history_classifier_label.csv)
  • 推論用クラス(point_history_classifier.py)

utils/cvfpscalc.py

FPS計測用のモジュ?ルです。

Training

ハンドサイン認識、フィンガ?ジェスチャ?認識は、
?習デ?タの追加、?更、モデルの再トレ?ニングが出?ます。

ハンドサイン認識トレ?ニング方法

1.?習デ?タ?集

「k」を押すと、キ?ポイントの保存するモ?ドになります(「MODE:Logging Key Point」と表示される)


「0」~「9」を押すと「model/keypoint_classifier/keypoint.csv」に以下のようにキ?ポイントが追記されます。
1列目:押下した?字(クラスIDとして使用)、2列目以降:キ?ポイント座標


キ?ポイント座標は以下の前?理を④まで?施したものを保存します。


初期?態では、パ?(クラスID:0)、グ?(クラスID:1)、指差し(クラスID:2)の3種類の?習デ?タが入っています。
必要に?じて3以降を追加したり、csvの?存デ?タを削除して、?習デ?タを用意してください。
  

2.モデル訓練

keypoint_classification.ipynb 」をJupyter Notebookで開いて上から順に?行してください。
?習デ?タのクラス?を?更する場合は「NUM_CLASSES = 3」の値を?更し、
「model/keypoint_classifier/keypoint_classifier_label.csv」のラベルを適宜修正してください。

X.モデル構造

keypoint_classification.ipynb 」で用意しているモデルのイメ?ジは以下です。

フィンガ?ジェスチャ?認識トレ?ニング方法

1.?習デ?タ?集

「h」を押すと、指先座標の履?を保存するモ?ドになります(「MODE:Logging Point History」と表示される)


「0」~「9」を押すと「model/point_history_classifier/point_history.csv」に以下のようにキ?ポイントが追記されます。
1列目:押下した?字(クラスIDとして使用)、2列目以降:座標履?


キ?ポイント座標は以下の前?理を④まで?施したものを保存します。


初期?態では、?止(クラスID:0)、時計回り(クラスID:1)、反時計回り(クラスID:2)、移動(クラスID:4)の
4種類の?習デ?タが入っています。
必要に?じて5以降を追加したり、csvの?存デ?タを削除して、?習デ?タを用意してください。
   

2.モデル訓練

point_history_classification.ipynb 」をJupyter Notebookで開いて上から順に?行してください。
?習デ?タのクラス?を?更する場合は「NUM_CLASSES = 4」の値を?更し、
「model/point_history_classifier/point_history_classifier_label.csv」のラベルを適宜修正してください。

X.モデル構造

point_history_classification.ipynb 」で用意しているモデルのイメ?ジは以下です。
「LSTM」を用いたモデルは以下です。
使用する際には「use_lstm = False」を「True」に?更してください(要tf-nightly(2020/12/16時点))

Application example

以下に?用事例を紹介します。

Reference

Author

高橋かずひと( https://twitter.com/KzhtTkhs )

License

hand-gesture-recognition-using-mediapipe is under Apache v2 license .

About

MediaPipe(Python版)を用いて手の姿勢推定を行い、?出したキ?ポイントを用いて、簡易なMLPでハンドサインとフィンガ?ジェスチャ?を認識するサンプルプログラムです。(Estimate hand pose using MediaPipe(Python version). This is a sample program that recognizes hand signs and finger gestures with a simple MLP using the detected key points.)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본