Giter Site home page Giter Site logo

gocr's Introduction

gocr

gocr is a go based OCR module

Available Scanner

  • Linear Mean Scanner
  • Circular Scanner (Currently the best)

Available predictor

  • NNPredictor (kNN with k = 1)
  • CNNPredictor (Need to install tensorflow first) (Doesn't upport custom train)

Future Improvement

  • Sauvola Segmentation
  • Better character detection
  • Better symbol detection
  • Spelling Correction

How to use

To use OCR we have some generated Model that we train using tensorflow. We use Convolutional Neural Network as the model architecture and produce good detection.

You can load and use the model to CNN Predictor like this example below:

d, _ := os.Getwd()

image, _ := gocr.ReadImage(d + "/imagetext_3.png")
s := gocr.NewCNNPredictorFromDir(modelPath + "tensor_4/")

// Define the image size
s.InputHeight, s.InputWidth = 64, 64

strings := gocr.ScanToStrings(s, image)
for _, s := range strings {
  fmt.Println(s)
}

However you can also use your own train data. Currently the predictor that support custom training only NNPredictor. Training takes csv file that have file image path and string representation.

ie:

a.gif,a
b.gif,b
A1.gif,A
B1.gif,B

Train the sample data to model and scan image

d, _ := os.Getwd()

// Load the sample data and save it in model.cbor file
err := gocr.TrainAverage(d+"/English/Fnt/", d+"/English/")
if err != nil {
  panic(err)
}

image, _ := gocr.ReadImage(d + "/imagetext_3.png")
s := gocr.NewCNNPredictorFromDir(modelPath + "sample1/model.cbor")

strings := gocr.ScanToStrings(s, image)
for _, s := range strings {
  fmt.Println(s)
}

License

gocr is released under the Apache 2.0 License. se LICENSE for details.

gocr's People

Contributors

sugab avatar agungkeys avatar ariefdarmawan 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.