sabari205 / Equation-Solver

Solving handwritten mathematical equations using OCR and CNN
28 stars 16 forks source link
convolutional-neural-networks deep-learning ocr reactjs tensorflow

Handwritten Equation solver

Link to application (Not functional currently as Heroku discontinued free product plans)

The application will be able to predict and solve handwritten mathematical equations from the given image. The system should be capable of solving expression involving arithmetic operations (addition, subtraction, multiplication, division) and solve equations of any degree (linear, quadratic, cubic and so on).

Key AI concepts used include OCR (Optical Character Recognition) and CNN (Convolutional Neural Networks). OCR is used to preprocess the image and segment characters, while CNN is used to predict the characters.

Local execution

Download the repo, move to the folder and run

Installation

The repository can either be cloned or downloaded as a zip.

Run npm install inside the project directory to install all dependencies.

Local setup

Both ReactJS and FastAPI have to be executed :

Start ReactJS using:

cd frontend
npm run start

Start FastAPI using:

cd api
uvicorn app:app --port:8000 --reload

Docker setup

Build and run both the Frontend and API using:

docker-compose up --build

The frontend can be viewed at http://localhost:3000 and the API can be viewed at http://localhost:8000

Result

When image is written through sketchpad

sketchpad-1 sketchpad-2

When image is uploaded

uploaded-1 uploaded-2

Overview

Architecture

Character Segmentation

The major steps include : Noise Removal, Binarization, Thresholding and Image Segmentation.

The Binarized image and the segmented images can be viewed below :

Architecture

Solving the Equation

After each of the character in the image is detected, the string containing the equation is passed to this final module which solves the equation or mathematical expression.

The equation can be of two types :

The 2 types of equations are distinguished by checking if the equation contains ‘=‘. If the equation contains ‘=‘, it is interpreted as the 2nd type, otherwise it is interpreted as the 1st type.

Links

Link to the presentation

References

Introduction to CNN Keras

Character Segmentation

ReactJS - Getting Started

React - P5 Wrapper

React bootstrap

Contributing

We enthusiastically welcome contributions, pull requests are most welcome! Your input is invaluable, and we appreciate any contributions, whether they are major changes or minor enhancements.