A very simple gesture recognition technique using opencv and python
Before going on into much details and wasting your time just watch this video to get an idea of what I have done. Here is the first video and the second one. Watch and also follow me :p
Since I am wearing a yellow cap in my fingers, I use that to segment the yellow colour which makes it a lot easier to get the gesture. Here are the steps that I have followed:
- Take one frame at a time and convert it from RGB colour space to HSV colour space for better yellow colour segmentation.
- Use a mask for yellow colour.
- Bluring and thresholding.
- If a yellow colour is found and it crosses a reasonable threshold, we start to create a gesture.
- The direction of movement of the yellow cap is calculated by taking the difference between the old center and the new center of the yellow colour after every 5th iteration.
- The directions are taken and stored in a list until the yellow cap disappears from the frame.
- The direction list is processed and the processed direction list is used to take a certain action.
- Square - Start menu
- Cross - Close
- C - Copy
- A - Select all
- N - Create new file
- V - Paste
- L - Lock the computer
- T - Display task manager
- > - Alt+tab
- < - Alt+Shift+Tab
- <> - Take a photo
- [] - Screenshot
- Square and line - Open text editor
- Since I am using threads in the program the first thing you need to do is go to the site mentioned and apply the solution given. Here is the website https://stackoverflow.com/questions/36809788/importerror-no-module-named-thread
- You need additional imutils functionalities. These can be found here https://github.com/jrosebr1/imutils.
First run the range-detector.py to set the range for the mask for colour segmentation and then press q when the perfect range is found. Then start the gesture_action.py. No need to change anything in the gesture_action.py file.
python3 range-detector.py -f HSV -w
python3 gesture_action.py
If you have any questions that are bothering you please contact me on my facebook profile. Just do not ask me questions like where do I live, who do I work for etc. Also no questions like what does this line do. If you think a line is redundant or can be removed to make the program better then you can obviously ask me or make a pull request.