# OCR with Julia

**URL:** <https://discourse.julialang.org/t/ocr-with-julia/4945>\
**Category:** Machine Learning\
**Created:** [July 19, 2017, 8:04am UTC](https://discourse.julialang.org/t/ocr-with-julia/4945 "2017-07-19T08:04:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Hearns](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_hearns/32/1685_2.png) [@John\_Hearns](https://discourse.julialang.org/u/John_Hearns)\
**Post date:** [July 19, 2017, 8:04am UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/1 "2017-07-19T08:04:27Z")

</div>

I am looking for suggestion on doing Optical Character Recognition. This does not necessarily have to be native Julia (see below). Also I am not looking for a full-on Machine Learnign framework which will recognise images.  
I am looking for a library or an external program which if given an image of a typewritten page it will return a scoring value - the higher the score the more readable or more easily recognised is the text.  
If this is best implemented usign Kaggle (which I know next to nothing about) I will hoist that aboard.

To explain, I have had a programming exercise in my head for years. Take an A4 typewritten page. Send it through a straight-cut shredder. Take the set of strips you have and scan them as images. Of course as an exercise you can do this virtually. Then combine the strips into an image page, at random. How can we piece together the original typewritten page?  
That leads to using optimisations -perhaps a genetic algorithm - to arrange the strips.  
Or it maybe that simple brute force is easier - just look at all possible arrangements to the strips.

---

<div class="post-metadata">

**Author:** ![John\_Hearns](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_hearns/32/1685_2.png) [@John\_Hearns](https://discourse.julialang.org/u/John_Hearns)\
**Post date:** [July 19, 2017, 8:35am UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/2 "2017-07-19T08:35:36Z")

</div>

Perhaps bad form to answer my own question… Tesseract may be what I am looking for  
[https://github.com/tesseract-ocr/tesseract](https://github.com/tesseract-ocr/tesseract)

Other suggestions are of course welcomed. (I have searched for this - I just came across Tesseract after I asked on here)

---

<div class="post-metadata">

**Author:** ![hpoit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hpoit/32/245_2.png) [@hpoit](https://discourse.julialang.org/u/hpoit)\
**Post date:** [June 7, 2018, 3:56pm UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/3 "2018-06-07T15:56:42Z")

</div>

I wish we could mobilize the community and build in Julia something better and simpler than this new LSTM-based OCR you just posted. Could we build a repo to start mapping out its design? Maybe if I saw its beginnings I could contribute to the completion of it. In any case, I am completing A. Ng’s ML course which teaches OCR on the eleventh week - maybe I could start mapping out the design.

---

<div class="post-metadata">

**Author:** ![raja4u](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raja4u/32/30787_2.png) [@raja4u](https://discourse.julialang.org/u/raja4u)\
**Post date:** [September 6, 2018, 2:24pm UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/4 "2018-09-06T14:24:42Z")

</div>

Any progress on this front?

---

<div class="post-metadata">

**Author:** ![uwechsler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uwechsler/32/5223_2.png) [@uwechsler](https://discourse.julialang.org/u/uwechsler)\
**Post date:** [March 9, 2020, 1:48pm UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/5 "2020-03-09T13:48:52Z")

</div>

There exists a `julia` wrapper for `tesseract`, see [GitHub - leferrad/OCReract.jl: A simple Julia wrapper for Tesseract OCR](https://github.com/leferrad/OCReract.jl).  
However, it does not appear to be maintained.

---

<div class="post-metadata">

**Author:** ![leferrad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leferrad/32/6105_2.png) [@leferrad](https://discourse.julialang.org/u/leferrad)\
**Post date:** [May 25, 2020, 8:46pm UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/6 "2020-05-25T20:46:11Z")

</div>

I guess Tesseract is a good tool to begin at least (from version 4.0, it has very good results in images with good enough resolution, even noisy ones). Then you can start thinking on adding good pre-processing steps to improve the image or even better ML models for the OCR task.  
As far as I know, there are no Julia frameworks for OCR tasks as you asked. I’ve developed OCReract.jl to be just a simple wrapper for Tesseract to allow retrieving results in a Julia session and, as @uwechsler mentioned, it was not maintained. But recently, I’ve released a stable version with proper documentation for usage so you can try it to see if that meets your needs.  
Repo: [GitHub - leferrad/OCReract.jl: A simple Julia wrapper for Tesseract OCR](https://github.com/leferrad/OCReract.jl)  
Doc: [Home · OCReract.jl](https://leferrad.github.io/OCReract.jl/dev/)

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [December 7, 2021, 5:24pm UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/7 "2021-12-07T17:24:36Z")

</div>

> [@leferrad](#):
>
> Tesseract

If tesseract.exe is not in %path% on Windows OS you may add something like this in your `startup.jl`:

```julia
if ~occursin(raw"C:\bin\Tesseract-OCR", ENV["path"])
    ENV["path"] = string(ENV["path"], raw"C:\bin\Tesseract-OCR;")
end

```

---

<div class="post-metadata">

**Author:** ![leferrad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leferrad/32/6105_2.png) [@leferrad](https://discourse.julialang.org/u/leferrad)\
**Post date:** [December 12, 2021, 10:08pm UTC](https://discourse.julialang.org/t/ocr-with-julia/4945/8 "2021-12-12T22:08:49Z")

</div>

Thanks for the suggestion @ellocco! Could you submit it as an issue [here](https://github.com/leferrad/OCReract.jl/issues)? Then it could have a better attention, as well as a thread to understand better the changes required.
