A Python script which lets users control their cursor using hand gestures. Take a look!
Clone and cd
into the the repository.
git clone https://github.com/a37tam/Wave.git
cd Wave
Create a virtual environment to manage all the dependencies listed in requirements.txt
. Activate it and install dependencies.
python3 -m venv env
source env/bin/activate
pip3 install -r requirements.txt
Run the Python script.
python3 main.py
Deactivate virtual environment.
deactivate
Access video stream from the laptop's webcam.
For each individual frame,
- Perform colour space conversion from BGR (the default colour space in OpenCV) to grayscale.
- Convolve a blurring kernel over the frame to reduce background noise.
- Determine an appropriate pixel intensity threshold value. Use this threshold to obtain a binary image.
- Process all the contours in the binary image and select the contour with the greatest area. This is the user's hand.
- Obtain the convex hull of the largest contour.
- From the convex hull, extract the total number of convexity defects and their coordinates.
- Based on these convexity defects, invoke the corresponding mouse event.
Move cursor: 2 fingers
Left click: 3 fingers
Right click: 4 fingers
To exit the application: Press "q" when the application window has focus.
More features to come!