An attempt to identify number from hand gestures using OpenCV Image Recognition.
- clone the repo:
https://github.com/mukeshmk/hand-gesture.git - create a virtual environment inside the folder:
python -m venv .venv - activate the virtual environment:
.venv\Scripts\activate(in case of Windows) - install the required packages for the game to run using:
pip install -r requirements.txt - run the code:
python file_name.py - make sure to
deactivateonce your done.
- run
python generate-training-data.py --label label_value --sample num_of_samples - This program will open a start video capture using the default camera (
device: 0) of your machine. - In the video you will see a red colour rectangle:
- Hold you hand in the rectangle and make gesture as per
lable_valuemake sure to throw in some variety. - This will capture
num_of_samplesnumber of images and store it undertraining_data\label_valuedirectory - Do this for the following labels:
1,2,3,4,5andempty. - Check sample images provided under
sample_imagesdirectory.
- run
python train.py - This will create a model with the name
hand-gesture-model.h5(NOTE: will replace the existing file if model is not renamed) - This model has a base of a 5 layered
Convolutional2DNN withMaxPooling2D. - The top classification layer using a 50%
DropOutandDenseLayer. - The output layer is also a
DenseLayer withsoftmaxactivation function. - All other layers use
reluactivation.
- run 'python hand-gesture.py`
- This will open up a video capture using the default camera of your machine.
- Hold your hand out in the indicated box.
- Using the model trained from 'train.py` file, the hand gestures are predected.