February 23, 2020

Don’t Miss this Python Project – Mouse Control With Hand Gestures.

Mouse Control With Hand Gestures.

Hey there, welcome back guys, we are back with another interesting python project with source code Mouse control with hand gestures using python for you. Thanks for showing lots of love on the Fake News Classifier with the NLP project.

Get $100/hour To Use Facebook, Twitter, And Youtube | Learn More

The title sounds cool, right? It would be so cool to control your mouse with your hand gestures. Image using your mouse pointer without touching the mouse.

Someone might think you as a magician you can look cool in front of your friends. This is possible by using some image processing concepts, computer vision, and python. This is my most famous python project in Github that gained popularity with 5 stars and 5 forks. Here is the link to the project.


Demonstration of Python Project With Source Code

Watch the demonstration of this python project on Github. Take a look at the consequence of the project if you find it cool you can develop it for yourself.

Python project github
Mouse control with hand gestures.

Work Flow of the project –

The philosophy behind this project is as follows –

  • We specify the color range of interest i.e. the color of the glove.
  • Using the color range we filter only objects having that color code.
  • Next, we select the region of interest. The region with the maximum area in our feed. (This region of interest lies in the color range).
  • Now, we associate the mouse controls with the movements of our ROI ( Region of interest, hand in this case).

Also, Check – Customer Churn Prediction using Machine Learning 2021 | MOST POPULAR PYTHON PROJECT


Steps to run this python project

  1. Prerequisite( Ignore if you have python) – As a prerequisite, you need python installed in your system. Download the compatible version of python from here.
  2. Run the following commands in terminal or cmd-
git clone https://github.com/globefire/Hand_detection_tracking_opencv
cd Hand_detection_tracking_opencv-
pip install -r requirements.txt 
python hand_detection_tracking.py

Note from the developer(Nitin Sahu): When your palm is open you can move the mouse with your hand gestures. When you form a fist a left click is performed.

MUST-READ: Hands-on Exploratory data analysis python Code & Steps -2021 | MOST POPULAR PYTHON PROJECT


Libraries used for this interesting python project

This project uses opencv_python, NumPy, and pyinput libraries. Here is an overview of these libraries.

  1. opencv_python – This free open-source library developed by intel is used to capture the feed. The feed is very important in the project, you will also need a webcam installed. You can implement the project without webcam too. You need to install the IP Webcam. Comment down in this artice for a detailed explanation.
  2. NumPy – We use this powerful mathematical library to define kernels. These kernels are essential to filter the region of interest. NumPy is also used to maintain the color range of interest.
  3. PyInput – This is the cherry of the cake here. We use this library to perform mouse pointer operations like moving it, performing clicks.

Let’s see the explanation of the code now.


Will You Be Rich & Famous ? Click Here to Find Out in 60 Seconds | Click Here

Walkthrough of Python Code –

  1. Importing python modules and creating necessary instances.
Mouse control with hand gestures using python
Image 1/3

We need to create instances of the modules imported to use them. The explanation of instances like kernel Open, kernel Close is mentioned in the script.

2. Capture feed and filter it

python project with source code
Image 2/3

Here we detect only regions within the color range of our interest. Then we remove the noises from this region by applying morphology.

And select the region with the maximum area as our controller.

3. Perform mouse operations

python mini project github
Image 3/3

After filtering the region of interest, we decide when to move the mouse pointer and when to perform a click.

If the area of our control(our palm) lies in an integer range we consider it as an open palm. Else we consider it a first.

MUST READ – How to Get a Coding Job with No Experience [Updated]


Concluding – Mouse control with hand gestures

I would now conclude the article. Always remember you’ve got an idea? Python a sturdy tool will help you achieve that idea.

I had many ideas and bringing them into real-life python has helped me a lot. I have many interesting python projects for beginners in Github that are developed to solve my daily life predicaments.


Thank you for reading this article. If you savored the idea behind this article if you found this article effective do share a word on Facebook, Instagram, LinkedIn.

Also, we would appreciate it if you leave a star on the Github repository it drives people like me to contribute more in the open-source world.

Do read my previous article on how to make a live color detector with python, how to build an audiobook generator with python.

Give your opinions about this Mouse control with hand gestures in python in the comment section.

Also If you have queries regarding this interesting python mini-project, you can write it down in the comment section below.


You can check out our other projects with source code below-

  1. Fake News Classifier with NLP 2021
  2. Spam Email Detection using Machine Learning Projects for Beginners in Python (2021)
  3. Hands-on Exploratory data analysis python Code & Steps -2021
  4. Best (2021) Python Project with Source Code
  5. Live Color Detector (#1 ) in Python 2021
  6. Wondering Why Is Coding So Hard? Read This Article

Feel free to contact us! Happy Coding!

Mini Projects
One Comment

Comments are closed.