Git Product home page Git Product logo

easyocr-cpp's Introduction

EasyOCR-cpp

alt text

Custom C++ implementation of EasyOCR

Built and tested on Windows 11, libtorch 1.13+cpu and OpenCV 4.6

This C++ project implements the pre/post processing to run a OCR pipeline consisting of a text detector CRAFT, and a CRNN based text recognizer. Unlike the EasyOCR python which is API based, this repo provides a set of classes to show how you can integrate OCR in any C++ program for maximum flexibility. The torchExample.cpp main program highlights how to utilize all elements of the EasyOCR-cpp pipeline. Because a test program is only provided, make sure to configure your input image within torchExample.cpp if you only plan to utilize the test program.

thrown together quickly within a week so many debug comments :)

Libtorch is being utilized with an in-house class I ussually use for C++ inference TorchModel, and OpenCV for the pre/post processing steps. The TorchModel class can easily adapted to run inference on most Pytorch models converted to TorchScript. Provides some handy functions to pre process opencv::Mat and handle device usage (GPU,CPU). Great starting point for C++ based inference for Pytorch Models.

Some features that have yet to be implemented:

  • beam search, only implemented greedy decoding
  • .txt/.pdf output
  • exact bounding box merge alg from EasyOCR, opted for custom one which is less complex
  • support for other languages, atm only english is supported.

If you would like to support feel free to make a PR, or a issue if you are having trouble.

Steps to run

Dependencies

Click to Download libtorch - > download

Use OpenCV Windows installer and unzip (v4.6) - > OpenCV libs

Make sure to change the location in the Makefile for OpenCV to point to your OpenCV build dir

Create a build directory within the repo, cd to it and run

cmake -DCMAKE_PREFIX_PATH=<absolute-path-to-libtorch-folder> ..

This will generate a solution within the build folder you can open up in Visual Studio. Make sure to use the Release config when building

Running

Configure your input image here. Currently the test program is using the test.jpg which comes in the repo.

Launch from command-line, or within Visual Studio after building.

Since its designed to be used in a C++ program, text is not being written to disk at the moment An output image will be generated in the main repo dir containing an annotated version of the input image with detection bounding boxes

easyocr-cpp's People

Contributors

ksasso1028 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.