Skip to content

This is a program that recognizes hand signs and finger gestures with a simple MLP using the detected key points. MediaPipe is used to estimate the hand poses..

License

Notifications You must be signed in to change notification settings

flawed-hooman/Hand-Gesture-Recognition-using-MediaPipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hand-Gesture-Recognition-using-Mediapipe

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.

102222442-c452cd00-3f26-11eb-93ec-c387c98231be

This repository contains the following contents.

  • Sample program
  • Hand sign recognition model(TFLite)
  • Finger gesture recognition model(TFLite)
  • Learning data for hand sign recognition and notebook for learning
  • Learning data for finger gesture recognition and notebook for learning

Requirements

  • mediapipe 0.8.1
  • OpenCV 3.4.2 or Later
  • Tensorflow 2.3.0 or Later
    tf-nightly 2.5.0.dev or later (For creating a TFLite for an LSTM model)
  • scikit-learn 0.23.2 or Later (for displaying the confusion matrix)
  • matplotlib 3.3.2 or Later (For displaying the confusion matrix)

Demo

Run app.py for the demo. The following options can be specified when running the demo.

  • --device
    Specifying the camera device number (Default:0)
  • --width
    Width at the time of camera capture (Default:960)
  • --height
    Height at the time of camera capture (Default:540)
  • --use_static_image_mode
    Whether to use static_image_mode option for MediaPipe inference (Default:Unspecified)
  • --min_detection_confidence
    Detection confidence threshold (Default:0.5)
  • --min_tracking_confidence
    Tracking confidence threshold (Default:0.5)

Details

app.py

This is a sample program for inference.
In addition, learning data (key points) for hand sign recognition,
You can also collect training data (index finger coordinate history) for finger gesture recognition.

keypoint_classification.ipynb

This is a model training script for hand sign recognition.

point_history_classification.ipynb

This is a model training script for finger gesture recognition.

model/keypoint_classifier

This directory stores files related to hand sign recognition.
The following files are stored.

  • Training data(keypoint.csv)
  • Trained model(keypoint_classifier.tflite)
  • Label data(keypoint_classifier_label.csv)
  • Inference module(keypoint_classifier.py)

model/point_history_classifier

This directory stores files related to finger gesture recognition.
The following files are stored.

  • Training data(point_history.csv)
  • Trained model(point_history_classifier.tflite)
  • Label data(point_history_classifier_label.csv)
  • Inference module(point_history_classifier.py)

utils/cvfpscalc.py

This is a module for FPS measurement.

Training

Hand sign recognition and finger gesture recognition can add and change training data and retrain the model.

Hand sign recognition training

1.Learning data collection

Press "k" to enter the mode to save key points(displayed as 「MODE:Logging Key Point」)


If you press "0" to "9", the key points will be added to "model/keypoint_classifier/keypoint.csv" as shown below.
1st column: Pressed number (used as class ID), 2nd and subsequent columns: Key point coordinates


The key point coordinates are ---.


In the initial state, three types of learning data are included: open hand (class ID: 0), close hand (class ID: 1), and pointing (class ID: 2).

  

2.Model training

The "keypoint_classification.ipynb" contains the model training details.

3.Model structure

The image of the model prepared in "keypoint_classification.ipynb" is as follows.

Finger gesture recognition training

1.Learning data collection

Press "h" to enter the mode to save the history of fingertip coordinates (displayed as "MODE:Logging Point History").


If you press "0" to "9", the key points will be added to "model/point_history_classifier/point_history.csv" as shown below.
1st column: Pressed number (used as class ID), 2nd and subsequent columns: Coordinate history


In the initial state, 4 types of learning data are included: stationary (class ID: 0), clockwise (class ID: 1), counterclockwise (class ID: 2), and moving (class ID: 4).

   

2.Model training

The "point_history_classification.ipynb" contains model training details.

X.Model structure

The image of the model prepared in "point_history_classification.ipynb" is as follows.
The model using "LSTM" is as follows.

Reference

License

Hand-Gesture-Recognition-using-Mediapipe is under Apache v2 license.

About

This is a program that recognizes hand signs and finger gestures with a simple MLP using the detected key points. MediaPipe is used to estimate the hand poses..

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published