GithubHelp home page GithubHelp logo

kishlay-notabot / tesseract-bbox-examples Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 383 KB

Complex examples for tesseract.js which can help users to generate and export bbox data of detected words, crop individual images etc.

JavaScript 100.00%

tesseract-bbox-examples's Introduction

tesseract-bbox-examples V5

Use node.js to run these files! [Tesseract v5.0.4]

package-json file included, run npm i to install dependencies before running for the first time.
Run these commands to run the specific files:

  • node ocr-and-bbox-export.js
  • node crop-from-exported-json.js
  • When we run OCR-and-bbox-export.js for the first time, the hin.traineddata file will be downloaded and used, it is the trained model data provided by the Tesseract engine.

Complex examples for tesseract.js which can help users to generate and export bbox data of detected words, crop individual images etc.

I strongly recommend to visit the dcda repository to see and understand the use case of this code in detail.

These examples are coded and directly implemented during the development of this project https://github.com/Kishlay-notabot/dcda/

Explanation

I was working on the dcda project above and I wanted to use Tesseract engine to give me bbox data of the detected symbols/words. I could not find any examples related to it on the internet so I had to reverse engineer the demo code at https://tesseract.projectnaptha.com/ and see how the code outlines the bbox data. It introduced me to canvas API. And then it was an easy [not so easy] journey ahead.

Below is the explanation of all the files included above:

1. OCR-and-bbox-export.js

This code executes word level detection on the input images and exports the output to the same input_images folder as ocr_results.json.

2. Crop-from-exported-json.js

This code uses the exported json file to crop out individual images of the words detected in the input images. It contains a size threshold and also a aspect ratio threshold to discard false detections to a limit.

3. Folder: Symbol-level/

This folder contains 2 files which are the same as above but deal with characters instead of words. This was not used in my project because of many issues like false detections, and the weirdly cut out images make it hard to decide and hard code fixed padding values, which would not induce uniformity. I ended up using word level outputs for the main dcda project because it has lesser false detections after tweaking.

image

The image below shows the word level cropped images. They undeniably do have false detections but comparatively lesser than what we face while dealing with symbol level outputs.

tesseract-bbox-examples's People

Contributors

kishlay-notabot avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

tbergman

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.