{"id":21476609,"url":"https://github.com/kazuhito00/hand-gesture-recognition-using-mediapipe","last_synced_at":"2025-04-12T14:57:45.011Z","repository":{"id":42687073,"uuid":"321675731","full_name":"Kazuhito00/hand-gesture-recognition-using-mediapipe","owner":"Kazuhito00","description":"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.）","archived":false,"fork":false,"pushed_at":"2023-04-05T00:51:50.000Z","size":1093,"stargazers_count":616,"open_issues_count":0,"forks_count":550,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-12T14:57:40.028Z","etag":null,"topics":["gesture","gesture-recognition","hand-pose-estimation","hands","mediapipe","python"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kazuhito00.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-15T13:26:23.000Z","updated_at":"2025-04-05T05:13:21.000Z","dependencies_parsed_at":"2024-01-13T16:29:23.488Z","dependency_job_id":"9931b67f-0411-4c14-8c5a-76e884076db7","html_url":"https://github.com/Kazuhito00/hand-gesture-recognition-using-mediapipe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kazuhito00%2Fhand-gesture-recognition-using-mediapipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kazuhito00%2Fhand-gesture-recognition-using-mediapipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kazuhito00%2Fhand-gesture-recognition-using-mediapipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kazuhito00%2Fhand-gesture-recognition-using-mediapipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kazuhito00","download_url":"https://codeload.github.com/Kazuhito00/hand-gesture-recognition-using-mediapipe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586249,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gesture","gesture-recognition","hand-pose-estimation","hands","mediapipe","python"],"created_at":"2024-11-23T11:09:35.637Z","updated_at":"2025-04-12T14:57:44.980Z","avatar_url":"https://github.com/Kazuhito00.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Japanese/[English](https://github.com/Kazuhito00/hand-gesture-recognition-using-mediapipe/blob/main/README_EN.md)]\n\n\u003e **Note**\n\u003e \u003cbr\u003eキーポイント分類について、モデルを集めたリポジトリを作成しました。\n\u003e \u003cbr\u003e→ [Kazuhito00/hand-keypoint-classification-model-zoo](https://github.com/Kazuhito00/hand-keypoint-classification-model-zoo)\n\n# hand-gesture-recognition-using-mediapipe\nMediaPipe(Python版)を用いて手の姿勢推定を行い、検出したキーポイントを用いて、\u003cbr\u003e簡易なMLPでハンドサインとフィンガージェスチャーを認識するサンプルプログラムです。\n![mqlrf-s6x16](https://user-images.githubusercontent.com/37477845/102222442-c452cd00-3f26-11eb-93ec-c387c98231be.gif)\n\n本リポジトリは以下の内容を含みます。\n* サンプルプログラム\n* ハンドサイン認識モデル(TFLite)\n* フィンガージェスチャー認識モデル(TFLite)\n* ハンドサイン認識用学習データ、および、学習用ノートブック\n* フィンガージェスチャー認識用学習データ、および、学習用ノートブック\n\n# Requirements\n* mediapipe 0.8.4\n* OpenCV 4.6.0.66 or Later\n* Tensorflow 2.9.0 or Later\n* protobuf \u003c3.20,\u003e=3.9.2\n* scikit-learn 1.0.2 or Later (学習時に混同行列を表示したい場合のみ)\n* matplotlib 3.5.1 or Later (学習時に混同行列を表示したい場合のみ)\n\n# Demo\nWebカメラを使ったデモの実行方法は以下です。\n```bash\npython app.py\n```\n\nDockerとWebカメラを使ったデモの実行方法は以下です。\n```bash\ndocker build -t hand_gesture .\n\nxhost +local: \u0026\u0026 \\\ndocker run --rm -it \\\n--device /dev/video0:/dev/video0 \\\n-v `pwd`:/home/user/workdir \\\n-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \\\n-e DISPLAY=$DISPLAY \\\nhand_gesture:latest\n\npython app.py\n```\n\nデモ実行時には、以下のオプションが指定可能です。\n* --device\u003cbr\u003eカメラデバイス番号の指定 (デフォルト：0)\n* --width\u003cbr\u003eカメラキャプチャ時の横幅 (デフォルト：960)\n* --height\u003cbr\u003eカメラキャプチャ時の縦幅 (デフォルト：540)\n* --use_static_image_mode\u003cbr\u003eMediaPipeの推論にstatic_image_modeを利用するか否か (デフォルト：未指定)\n* --min_detection_confidence\u003cbr\u003e\n検出信頼値の閾値 (デフォルト：0.5)\n* --min_tracking_confidence\u003cbr\u003e\nトラッキング信頼値の閾値 (デフォルト：0.5)\n\n# Directory\n\u003cpre\u003e\n│  app.py\n│  keypoint_classification.ipynb\n│  point_history_classification.ipynb\n│\n├─model\n│  ├─keypoint_classifier\n│  │  │  keypoint.csv\n│  │  │  keypoint_classifier.hdf5\n│  │  │  keypoint_classifier.py\n│  │  │  keypoint_classifier.tflite\n│  │  └─ keypoint_classifier_label.csv\n│  │\n│  └─point_history_classifier\n│      │  point_history.csv\n│      │  point_history_classifier.hdf5\n│      │  point_history_classifier.py\n│      │  point_history_classifier.tflite\n│      └─ point_history_classifier_label.csv\n│\n└─utils\n    └─cvfpscalc.py\n\u003c/pre\u003e\n### app.py\n推論用のサンプルプログラムです。\u003cbr\u003eまた、ハンドサイン認識用の学習データ(キーポイント)、\u003cbr\u003e\nフィンガージェスチャー認識用の学習データ(人差指の座標履歴)を収集することもできます。\n\n### keypoint_classification.ipynb\nハンドサイン認識用のモデル訓練用スクリプトです。\n\n### point_history_classification.ipynb\nフィンガージェスチャー認識用のモデル訓練用スクリプトです。\n\n### model/keypoint_classifier\nハンドサイン認識に関わるファイルを格納するディレクトリです。\u003cbr\u003e\n以下のファイルが格納されます。\n* 学習用データ(keypoint.csv)\n* 学習済モデル(keypoint_classifier.tflite)\n* ラベルデータ(keypoint_classifier_label.csv)\n* 推論用クラス(keypoint_classifier.py)\n\n### model/point_history_classifier\nフィンガージェスチャー認識に関わるファイルを格納するディレクトリです。\u003cbr\u003e\n以下のファイルが格納されます。\n* 学習用データ(point_history.csv)\n* 学習済モデル(point_history_classifier.tflite)\n* ラベルデータ(point_history_classifier_label.csv)\n* 推論用クラス(point_history_classifier.py)\n\n### utils/cvfpscalc.py\nFPS計測用のモジュールです。\n\n# Training\nハンドサイン認識、フィンガージェスチャー認識は、\u003cbr\u003e学習データの追加、変更、モデルの再トレーニングが出来ます。\n\n### ハンドサイン認識トレーニング方法\n#### 1.学習データ収集\n「k」を押すと、キーポイントの保存するモードになります（「MODE:Logging Key Point」と表示される）\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102235423-aa6cb680-3f35-11eb-8ebd-5d823e211447.jpg\" width=\"60%\"\u003e\u003cbr\u003e\u003cbr\u003e\n「0」～「9」を押すと「model/keypoint_classifier/keypoint.csv」に以下のようにキーポイントが追記されます。\u003cbr\u003e\n1列目：押下した数字(クラスIDとして使用)、2列目以降：キーポイント座標\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102345725-28d26280-3fe1-11eb-9eeb-8c938e3f625b.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\nキーポイント座標は以下の前処理を④まで実施したものを保存します。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102242918-ed328c80-3f3d-11eb-907c-61ba05678d54.png\" width=\"80%\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102244114-418a3c00-3f3f-11eb-8eef-f658e5aa2d0d.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\n初期状態では、パー(クラスID：0)、グー(クラスID：1)、指差し(クラスID：2)の3種類の学習データが入っています。\u003cbr\u003e\n必要に応じて3以降を追加したり、csvの既存データを削除して、学習データを用意してください。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102348846-d0519400-3fe5-11eb-8789-2e7daec65751.jpg\" width=\"25%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102348855-d2b3ee00-3fe5-11eb-9c6d-b8924092a6d8.jpg\" width=\"25%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102348861-d3e51b00-3fe5-11eb-8b07-adc08a48a760.jpg\" width=\"25%\"\u003e\n\n#### 2.モデル訓練\n「[keypoint_classification.ipynb](keypoint_classification.ipynb)」をJupyter Notebookで開いて上から順に実行してください。\u003cbr\u003e\n学習データのクラス数を変更する場合は「NUM_CLASSES = 3」の値を変更し、\u003cbr\u003e「model/keypoint_classifier/keypoint_classifier_label.csv」のラベルを適宜修正してください。\u003cbr\u003e\u003cbr\u003e\n\n#### X.モデル構造\n「[keypoint_classification.ipynb](keypoint_classification.ipynb)」で用意しているモデルのイメージは以下です。\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102246723-69c76a00-3f42-11eb-8a4b-7c6b032b7e71.png\" width=\"50%\"\u003e\u003cbr\u003e\u003cbr\u003e\n\n### フィンガージェスチャー認識トレーニング方法\n#### 1.学習データ収集\n「h」を押すと、指先座標の履歴を保存するモードになります（「MODE:Logging Point History」と表示される）\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102249074-4d78fc80-3f45-11eb-9c1b-3eb975798871.jpg\" width=\"60%\"\u003e\u003cbr\u003e\u003cbr\u003e\n「0」～「9」を押すと「model/point_history_classifier/point_history.csv」に以下のようにキーポイントが追記されます。\u003cbr\u003e\n1列目：押下した数字(クラスIDとして使用)、2列目以降：座標履歴\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102345850-54ede380-3fe1-11eb-8d04-88e351445898.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\nキーポイント座標は以下の前処理を④まで実施したものを保存します。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102244148-49e27700-3f3f-11eb-82e2-fc7de42b30fc.png\" width=\"80%\"\u003e\u003cbr\u003e\u003cbr\u003e\n初期状態では、静止(クラスID：0)、時計回り(クラスID：1)、反時計回り(クラスID：2)、移動(クラスID：4)の\u003cbr\u003e4種類の学習データが入っています。\u003cbr\u003e\n必要に応じて5以降を追加したり、csvの既存データを削除して、学習データを用意してください。\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350939-02b0c080-3fe9-11eb-94d8-54a3decdeebc.jpg\" width=\"20%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350945-05131a80-3fe9-11eb-904c-a1ec573a5c7d.jpg\" width=\"20%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350951-06444780-3fe9-11eb-98cc-91e352edc23c.jpg\" width=\"20%\"\u003e　\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102350942-047a8400-3fe9-11eb-9103-dbf383e67bf5.jpg\" width=\"20%\"\u003e\n\n#### 2.モデル訓練\n「[point_history_classification.ipynb](point_history_classification.ipynb)」をJupyter Notebookで開いて上から順に実行してください。\u003cbr\u003e\n学習データのクラス数を変更する場合は「NUM_CLASSES = 4」の値を変更し、\u003cbr\u003e「model/point_history_classifier/point_history_classifier_label.csv」のラベルを適宜修正してください。\u003cbr\u003e\u003cbr\u003e\n\n#### X.モデル構造\n「[point_history_classification.ipynb](point_history_classification.ipynb)」で用意しているモデルのイメージは以下です。\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102246771-7481ff00-3f42-11eb-8ddf-9e3cc30c5816.png\" width=\"50%\"\u003e\u003cbr\u003e\n「LSTM」を用いたモデルは以下です。\u003cbr\u003e使用する際には「use_lstm = False」を「True」に変更してください（要tf-nightly(2020/12/16時点))\u003cbr\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/37477845/102246817-8368b180-3f42-11eb-9851-23a7b12467aa.png\" width=\"60%\"\u003e\n\n# Application example\n以下に応用事例を紹介します。\n* [Control DJI Tello drone with Hand gestures](https://towardsdatascience.com/control-dji-tello-drone-with-hand-gestures-b76bd1d4644f)\n* [Classifying American Sign Language Alphabets on the OAK-D](https://www.cortic.ca/post/classifying-american-sign-language-alphabets-on-the-oak-d)\n\n# Reference\n* [MediaPipe](https://mediapipe.dev/)\n* [Kazuhito00/mediapipe-python-sample](https://github.com/Kazuhito00/mediapipe-python-sample)\n\n# Author\n高橋かずひと(https://twitter.com/KzhtTkhs)\n\n# License\nhand-gesture-recognition-using-mediapipe is under [Apache v2 license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazuhito00%2Fhand-gesture-recognition-using-mediapipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkazuhito00%2Fhand-gesture-recognition-using-mediapipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkazuhito00%2Fhand-gesture-recognition-using-mediapipe/lists"}