Git Product home page Git Product logo

hxndev / virtual-mouse-using-opencv Goto Github PK

View Code? Open in Web Editor NEW
49.0 1.0 28.0 147.27 MB

In this project we will be using the live feed coming from the webcam to create a virtual mouse with complete functionalities.

License: MIT License

Python 97.59% JavaScript 0.14% HTML 0.02% CSS 0.03% Jupyter Notebook 0.07% Cython 0.32% C 1.46% C++ 0.32% Fortran 0.03% Batchfile 0.01% Shell 0.01% PowerShell 0.01% Xonsh 0.01%
opencv opencv-python cv2 handtracking virtual-mouse virtual-mouse-using-hand-gesture ai-mouse mediapipe autopy code

virtual-mouse-using-opencv's Introduction

Virtual Mouse Using OpenCV

In this project we will be using the live feed coming from the webcam to create a virtual mouse using hand tracking.

Project Description:

In this project, I am using my hand as a virtual mouse than can do everything that a mouse does without even touching your system. I am using the webcam of my system to detect my hands. It will then create a bounding box around my hand and focus on two fingers: The fore finger and the middle finger. The fore finger will act as a cursor and moving it around, we will be moving the cursor around. Now, inorder to successfully click using hand tracking, it is detecting the distance between the fore finger and the middle finger. If they are joined together, then it will perform a click.

Furthermore, a smoothness factor was added as the movement was really shaky.

Alt Text

Requirements:

Following modules need to be installed for it to work properly:

  • OpenCV
  • Mediapipe
  • Autopy

OpenCV:

OpenCV is a huge open-source library for computer vision, machine learning, and image processing. OpenCV supports a wide variety of programming languages like Python, C++, Java, etc. It can process images and videos to identify objects, faces, or even the handwriting of a human.

It can be installed using "pip install opencv-python"

Mediapipe:

MediaPipe is a framework for building multimodal (eg. video, audio, any time series data), cross platform (i.e Android, iOS, web, edge devices) applied ML pipelines.

It can be installed using "pip install mediapipe"

Autopy:

AutoPy is a simple, cross-platform GUI automation library for Python. It includes functions for controlling the keyboard and mouse, finding colors and bitmaps on-screen, and displaying alerts.

It can be installed using "pip install autopy"

Important Note:

I faced alot of dependency issues throughout this project. Some of the issues and their solutions are as follows:

  • autopy not installing: This is because autopy currently doesn't support Python versions above 3.8
  • webcam not opening: It was a bug in mediapipe and was fixed in latest python versions

Hence, inorder for the project to run smoothly, you need to degrade the Python version to 3.8

How to Degrade Python Version:

Follow the following steps:

  • Uninstall Python from add/remove programs
  • Go to AppData and remove any python folder you see.
  • Download Python 3.8 from this link : Python 3.8
  • Install it.
  • Open command promt and run "pip" inorder to confirm installation.
  • Your Python version has been degraded :)

๐Ÿ“ซ Contact Me:

Website Gmail GitHub LinkedIn Instagram

virtual-mouse-using-opencv's People

Contributors

hxndev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

virtual-mouse-using-opencv's Issues

I am facing an error in this project, i have installed python 3.8 and also successfully install those three modules but it is showing erros, the errors are in the description

"E:\Virtual-Mouse-using-OpenCV-main>python "Virtual Mouse.py"
Traceback (most recent call last):
File "Virtual Mouse.py", line 1, in
import cv2
File "E:\Python\lib\site-packages\cv2_init_.py", line 181, in
bootstrap()
File "E:\Python\lib\site-packages\cv2_init_.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "E:\Python\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed while importing cv2: The specified module could not be f"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.