demo.mp4
- Python 3.x
- OpenCV (
cv2
) - NumPy
- Mediapipe
- Scikit-learn
- Flask
Letter | Words |
---|---|
A | a, again, applause |
B | b, baby, boy |
C | c, cold, cookie, cup |
D | d, dad, drink |
E | e |
F | f, food, full |
G | g, girl |
H | h, help |
I | i |
K | k, know |
L | l, learn, love |
M | m, mad, marriage, mom, money, more |
N | n, name, no |
O | o |
P | p, person, please |
Q | q |
R | r |
S | s, sad, shirt, short, sorry, stop |
T | t, tall, teach, thank you |
U | u, understand |
V | v |
W | w, water, what |
X | x |
Y | y, yellow, yes |
Z | z |
Numbers | 3, 5, 6, 7, 8, 9, 10 |
- Clone the repository.
- Make sure you have Python 3.x installed on your system along with the required libraries.
python -m pip install -r requirements.txt
- Go into the root folder of the project and run the app by using the following command.
python app.py
- Go to the development server at:
http://localhost:5000
app.py
: Main Flask application script.templates/index.html
: HTML template for rendering the web page.inference_classifier.py
: Module containing the GestureClassifier class for performing gesture recognition.
This script allows you to collect real-time image data from your webcam with specified labels. It creates a dataset for each label by capturing images and storing them in separate directories within a specified data directory.
- Run the script.
- Enter the labels you want to create when prompted. Enter
-1
to stop adding labels. - Once labels are entered, the webcam will activate.
- Press
Q
to start capturing images for each label. - Images will be stored in the specified data directory under separate folders for each label.
DATA_DIR
: Directory to store the collected data. Default is./data
.dataset_size
: Number of images to collect for each label. Default is300
.
- Ensure proper lighting and background for accurate image collection.
- Press
Q
to start capturing images after each label prompt.
This script captures images from a specified directory, detects hand landmarks using the MediaPipe library, and saves the landmark data along with corresponding labels into a pickle file.
- Place your image data in the specified data directory (
./data
by default). - Run the script.
- The script will process each image, extract hand landmarks, and save the data along with labels into a pickle file named
data.pickle
.
DATA_DIR
: Directory containing the image data. Default is./data
.
- Ensure your images have sufficient resolution and quality for accurate hand landmark detection.
- The script assumes that each subdirectory in the data directory represents a different label/class.
- Hand landmark data is saved as a list of coordinates relative to the top-left corner of the bounding box of the detected hand.
- The pickle file
data.pickle
contains a dictionary with keys 'data' and 'labels', where 'data' is a list of hand landmark data and 'labels' is a list of corresponding labels.
This script trains a Random Forest classifier for gesture recognition using hand landmarks data. It also evaluates the model's performance using cross-validation and saves the trained model for future use.
- Ensure you have hand landmarks data saved as
data.pickle
in the project directory. - Run the script.
- The script will load the hand landmarks data, preprocess it, train a Random Forest classifier, and evaluate its performance.
- Hand landmarks data should be saved as a dictionary (
labels_dict.py
)containing 'data' (list of hand landmark data) and 'labels' (list of corresponding labels). - The script pads each hand landmark sequence with zeros to ensure all sequences have the same length, necessary for training the classifier.
- The classifier is trained using stratified train-test split and evaluated using cross-validation for robustness.
- The trained model is saved as
model.p
using thepickle
module for future use. - Adjust the model parameters and preprocessing steps as needed for improved performance.
This script performs real-time gesture recognition using hand landmarks detected by the MediaPipe library. It loads a pre-trained gesture classification model and overlays the predicted gesture label on the input video stream.
- Ensure you have a trained gesture classification model saved as
model.p
in the project directory. - Run the script.
- The script will activate your webcam and overlay the predicted gesture label on the detected hand landmarks in real-time.
- The gesture classification model is assumed to be trained externally and saved using the
pickle
module. - Hand landmarks are detected using the MediaPipe library, providing a robust representation of hand gestures.
- The script draws bounding boxes around detected hands and overlays the predicted gesture label on the video stream.
- Adjust the
min_detection_confidence
parameter of theHands
class for controlling the confidence threshold of hand landmark detection. - Ensure proper lighting and background for accurate hand landmark detection and gesture recognition.
This Flask-based web application streams real-time video from your webcam and performs gesture recognition using a pre-trained model. The predicted gesture labels are overlaid on the video stream and displayed on a web page.
- Ensure you have your pre-trained gesture classification model saved and inference code ready.
- Run the Flask application (
app.py
). - Open your web browser and navigate to
http://localhost:5000
orhttp://127.0.0.1:5000
. - You should see the real-time video stream with predicted gesture labels overlaid.
- The
GestureClassifier
class is assumed to be implemented ininference_classifier.py
. - The Flask application captures frames from the webcam using OpenCV, performs gesture recognition using the
GestureClassifier
class, and streams the processed frames to the web page. - Ensure proper permissions for accessing the webcam.
- Adjust the URL (
http://localhost:5000
) according to your Flask application settings.