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.
- Overview
- Key Features
- How It Works
- Gesture Guide
- Technical Details
- Setup & Installation
- Usage
- Troubleshooting
- Contributing
- License
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
- 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.
- Hand Detection: Uses MediaPipe to detect and track hands in the webcam feed.
- Gesture Recognition: Analyzes finger positions to recognize numbers (0–9), operators (+, -, *, /), and special commands (clear, equals, exit, etc.).
- Expression Building: As you perform gestures, MathWave builds a math expression.
- Evaluation: When you signal 'equals', the expression is evaluated and the result is displayed.
- Error Handling: If the camera is disconnected or unavailable, MathWave displays a clear message and waits for reconnection.
- 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.).
- 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.
- Clear: Press 'c' on the keyboard.
- Exit: Press 'q' or 'Esc' on the keyboard.
- Language: Python 3.10
- Libraries:
- Camera Handling:
- On macOS, uses
cv2.CAP_AVFOUNDATIONfor stable camera access. - If the camera is disconnected, MathWave displays a message and waits for reconnection.
- On macOS, uses
- Expression Evaluation:
- Uses Python's
eval()for basic math (with error handling for invalid input).
- Uses Python's
- Clone the repository:
git clone https://github.com/YUKII2K3/MathWave-Gesture-Based-Calculator.git cd MathWave-Gesture-Based-Calculator - Create and activate a Python 3.10 virtual environment:
python3.10 -m venv venv source venv/bin/activate - Upgrade pip (recommended):
pip install --upgrade pip
- Install dependencies:
pip install -r requirements.txt
- Run MathWave:
python3.10 MathWave.py
- 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.
- 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.txtto ensure all dependencies are installed.
- Run
- 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.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and add tests if applicable.
- 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.
This project is licensed under the MIT License. See the LICENSE file for details.