Giter VIP home page Giter VIP logo

ocr-math-solver's Introduction

OCR-math-solver

Simple python project for evaluation of handwritten mathematical expressions. Supports digits 0-9 and operators for addition, subtraction, multiplication, division, and brackets:

0123456789+-ร—/()

Description

main.py takes one argument, -i or --image, path to image of handwritten expression. The image is processed and passed to optical character detector which cuts out individual characters and sends them to a simple CNN classifier. Expression constructed from classified characters is passed to an evaluator utilizing Shunting-Yard algorithm. Solution is printed to standard output.

Installation and usage

Installation is possible with docker or manually. For Docker install within this directory use:

docker build --tag ocr-math-solver .    
docker run ocr-math-solver -i ./expression_examples/expression3.jpg

to install without Docker use:

pip3 install -r requirements.txt
python main.py --image | -i PATH_TO_IMAGE

for example:

python main.py -i ./expression_examples/expression3.jpg

Visuals

Input expression:

After preprocessing and character detection:

Output:

3 + 45 x ( 6 + 1 )
= 318

Network training

The network definition can be found in classifier/model.py. Pre-trained model model.h5 was trained on a subset of CROHME offline handwritten dataset. dataset.read_images() can be used to read this dataset and prepare it as a numpy array. To begin training the network, simply run:

python ./classifier/model.py

ocr-math-solver's People

Contributors

brunos252 avatar

Watchers

 avatar

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.