A realâtime math problem drawing and solving tool using hand gestures and Googleâs Gemini AI.
Draw math expressions in front of your webcam using your index finger, clear the canvas with your thumb, and show four fingers to send the drawing to the AI for solving.
- Hand Tracking & Drawing
Utilizescvzone
+ MediaPipe to detect your hand, track finger position, and draw on a transparent canvas. - AIâPowered Math Solver
Sends your handâdrawn math problem to Google Gemini (viagoogle-generativeai
) for instant solutions. - Interactive Web UI
Built with Streamlit for a seamless webcam feed + drawing overlay and solution display.
- Python 3.8+
- A webcam supported by
imageio
/ OpenCV - A Google Gemini API key (called
GEMINI_API_KEY
)
git clone https://github.com/GautamBytes/Math_Gesture_Prediction_tool.git
cd Math_Gesture_Prediction_tool
python -m venv .venv
.\.venv\Scripts\activate
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
To generate a Gemini API key, visit:
https://aistudio.google.com/app/apikey
Then create a file named .env
in the project root with the following content:
GEMINI_API_KEY=your_google_gemini_api_key_here
Note: Do not commit your
.env
file to version control.
Run the provided cameraâlisting script to find your webcamâs index:
python list_cameras_imageio.py
Youâll see output like:
Index 0: Camera found
Index 1: Camera not found, error: ...
Remember the index where âCamera foundâ appears (commonly
0
or1
).
If your camera index is not 0
, open main.py
and update:
camera_index = 0 # â change to the index found above
streamlit run main.py
- The browser will open at
http://localhost:8501
by default. - To specify a different port, add
--server.port <PORT>
to the command.
- Draw
- Raise index finger to draw lines on the canvas.
- Clear
- Show thumb up gesture to reset/clear the canvas.
- Solve
- Show four fingers (all but pinky) to send the current drawing to Google Gemini for solving.
- The AIâs solution appears in the rightâhand pane.
Expand the âHow to useâ panel in the app for these same instructions.
- No camera detected
- Doubleâcheck the camera index via
list_cameras_imageio.py
. - Ensure no other app is blocking the webcam.
- Doubleâcheck the camera index via
GEMINI_API_KEY
** not found**- Confirm your
.env
file is in the project root. - Restart the Streamlit server after updating
.env
.
- Confirm your
- Slow or inconsistent detection
- Improve lighting & background contrast.
- Reduce
modelComplexity
or lower detection thresholds inHandDetector
.