Skip to content

A gesture-controlled calculator that uses computer vision and hand tracking to perform basic arithmetic operations. Built with Python, OpenCV, and Mediapipe, it enables touch-free calculations using real-time finger gestures.

Notifications You must be signed in to change notification settings

YUKII2K3/MathWave-Gesture-Based-Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

MathWave – Gesture-Based Calculator

MathWave is an innovative, real-time gesture-based calculator that leverages computer vision and machine learning to allow users to perform mathematical operations using only their hands and a webcam. Designed for accessibility, education, and futuristic human-computer interaction, MathWave transforms your webcam into a touchless math input device, recognizing hand gestures to build and solve math expressions live on screen.


Table of Contents


Overview

MathWave is designed to make math input more natural, fun, and accessible. By using MediaPipe and OpenCV, it recognizes a variety of hand gestures through your webcam, translating them into numbers, operators, and commands. This project is ideal for:

  • Touchless interfaces (e.g., public kiosks, accessibility tools)
  • Educational demonstrations
  • Experimenting with computer vision and gesture recognition

Key Features

  • Real-Time Gesture Recognition: Instantly detects and interprets hand gestures for numbers, operators, and special commands.
  • Touchless Math Input: Build and solve math expressions without touching your keyboard or mouse.
  • Robust Camera Handling: Special handling for macOS and error messages if the camera is unavailable or disconnected.
  • Live Feedback: See your gesture, current expression, and result on the screen in real time.
  • Cross-Platform: Works on macOS, Windows, and Linux (Python 3.10 required).
  • Extensible: Easily add new gestures or operations.

How It Works

  1. Hand Detection: Uses MediaPipe to detect and track hands in the webcam feed.
  2. Gesture Recognition: Analyzes finger positions to recognize numbers (0–9), operators (+, -, *, /), and special commands (clear, equals, exit, etc.).
  3. Expression Building: As you perform gestures, MathWave builds a math expression.
  4. Evaluation: When you signal 'equals', the expression is evaluated and the result is displayed.
  5. Error Handling: If the camera is disconnected or unavailable, MathWave displays a clear message and waits for reconnection.

Gesture Guide

Numbers

  • 0–5: Show 0–5 fingers on one hand.
  • 6–9: Show 5 fingers on one hand and 1–4 on the other (6 = 5+1, 7 = 5+2, etc.).

Operators

  • Addition (+): 1 finger up on each hand (index fingers), hands apart.
  • Subtraction (−): 1 finger up on one hand, 2 on the other (or vice versa).
  • Multiplication (×): 1 finger up on one hand, 3 on the other (or vice versa).
  • Division (÷): 1 finger up on one hand, 4 on the other (or vice versa).
  • Square Root (sqrt): Both hands, only pinky finger up.
  • Equals (=): Both hands, all fingers down (fists).
  • Percentage (%): Both hands, only index and middle fingers up (peace sign).
  • Clear: Both hands, all 5 fingers up.
  • Exit: 1 finger up on each hand, index fingertips close together.

Manual Controls

  • Clear: Press 'c' on the keyboard.
  • Exit: Press 'q' or 'Esc' on the keyboard.

Technical Details

  • Language: Python 3.10
  • Libraries:
  • Camera Handling:
    • On macOS, uses cv2.CAP_AVFOUNDATION for stable camera access.
    • If the camera is disconnected, MathWave displays a message and waits for reconnection.
  • Expression Evaluation:
    • Uses Python's eval() for basic math (with error handling for invalid input).

Setup & Installation

  1. Clone the repository:
    git clone https://github.com/YUKII2K3/MathWave-Gesture-Based-Calculator.git
    cd MathWave-Gesture-Based-Calculator
  2. Create and activate a Python 3.10 virtual environment:
    python3.10 -m venv venv
    source venv/bin/activate
  3. Upgrade pip (recommended):
    pip install --upgrade pip
  4. Install dependencies:
    pip install -r requirements.txt
  5. Run MathWave:
    python3.10 MathWave.py

Usage

  • Make sure your webcam is connected and accessible.
  • Start the program and position your hands in front of the camera.
  • Use the gesture guide above to input numbers and operations.
  • The current expression, result, and last recognized gesture will be displayed on the video feed.
  • If the camera disconnects, follow the on-screen instructions to reconnect or exit.

Troubleshooting

  • Camera Not Detected:
    • Ensure your webcam is connected and not used by another application.
    • On macOS, grant camera access to Terminal/Python in System Preferences > Security & Privacy.
  • Dependency Issues:
    • Run pip install -r requirements.txt to ensure all dependencies are installed.
  • Gesture Not Recognized:
    • Ensure your hand is well-lit and fully visible to the camera.
    • Hold gestures steady for a moment to allow recognition.
  • Performance Issues:
    • Close other applications using the camera or heavy system resources.

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes and add tests if applicable.
  4. Submit a pull request with a clear description of your changes.

For major changes, please open an issue first to discuss what you would like to change.


License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A gesture-controlled calculator that uses computer vision and hand tracking to perform basic arithmetic operations. Built with Python, OpenCV, and Mediapipe, it enables touch-free calculations using real-time finger gestures.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages