Use Tesseract to create OCR server with Spring boot

Tram Ho

Use Tesseract to create OCR server with Spring boot

1. What is tesseract?

Tesseract is a leading OCR (Optical Character Recognition) engine today. This tool is distributed with Apache 2.0 open source license. It supports character recognition on image files and outputs as plain characters, html, pdf, tsv, invisible-text-only pdf. Users can use it directly or programmers can use functions through the API.

Tesseract was developed by Hewlett-Packard Laboratories Bristol at Hewleett-Packard Co, Greeley Colorado from 1985 to 1994. After that, it was updated with some minor changes and discontinued development after 1998. By 2005, Tesseract was distributed as open source by HP and developed by Google since 2006.

Currently, Tesseract has developed to version 3.0x and can work on three popular operating systems, Windows, Mac and Linux. This tool supports character recognition in over 100 different languages, including Vietnamese. Not only that, we can train the program to use Tesseract to be able to identify a certain language.

2. Installing and preparing the project (on Linux environment)

a> Maven Dependency

b> Download tessdata data from Github

https://github.com/tesseract-ocr/tessdata

c> Install Tesseract for Linux with the command:

sudo apt-get install tesseract-ocr

Check the version

tesseract -v

3. Create project

Step 1: create a basic Spring Boot project

Step 2: Rename the tessdata-master data folder that you downloaded from git to tessdata and copy it into the project.

Step 3: Add Dependency into the project

Project structure

DemoOrcServerApplication Class

Class OcrController

Class OcrResult

Class OcrService

4. Check results

Our input is the image

Use postman to check:

So our program has worked well.

My guide here is the end. Thank you for watching!

Share the news now

Source : Viblo