DelphiLearn PythonPythonPython GUIRAD StudioWindows

How To Build A GUI For Optical Character Recognition

blogbanner easyocr

Are you looking for the easiest way to build an Optical Character Recognizer for 80+ languages and build a nice GUI for them, and all of them are free? You can deliver end-to-end multilingual OCR solutions easily by combining EasyOCR and Python4Delphi library, inside Delphi and C++Builder.

This post will guide you on how to run the EasyOCR library and use Python for Delphi to display it in the Delphi Windows GUI app.

 

What is the EasyOCR library?

How To Build A GUI For Optical Character Recognition - EasyOCR Logo

EasyOCR, as the name suggests, is a Python package that allows computer vision developers to effortlessly perform Optical Character Recognition. EasyOCR provides end-to-end, and ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic, etc.

How To Build A GUI For Optical Character Recognition - The EasyOCR Framework
EasyOCR Pipeline. Image Source: https://github.com/JaidedAI/EasyOCR

When it comes to OCR, using EasyOCR is by far the most straightforward way to apply Optical Character Recognition:

  • The EasyOCR package can be installed with a single pip command.
  • The dependencies on the EasyOCR package are minimal, making it easy to configure your OCR development environment.
  • Once EasyOCR is installed, only one import statement is required to import the package into your project.
  • From there, all you need is two lines of code to perform OCR — one to initialize the Reader class and then another to OCR the image via the readtext function.

 

How do I enable EasyOCR inside Python4Delphi in Windows?

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

How To Build A GUI For Optical Character Recognition Python4Delphi in RAD Studio IDE
Open Demo01.dproj

The next step is installing EasyOCR into your system. Here is how you can get EasyOCR using pip for stable release:

Note: For Windows, please install torch and torchvision first by following the official instructions here. On the pytorch website, be sure to select the right CUDA version you have. If you intend to run on CPU mode only, select CUDA = None.

Or read more about PyTorch in our article about it:

How can I automatically recognize characters in images with EasyOCR?

Example 1: Simplified Chinese Character and English Recognition

To save your time when running OCR for Chinese character inside Python4Delphi GUI, let’s run this script inside your cmd, to download the detection and recognition models for Simplified Chinese:

Next, we will test the EasyOCR library to detect both Chinese characters and English in this image:

How To Build A GUI For Optical Character Recognition. Results of processing in terminal window

Next, we will test the EasyOCR library to detect both Chinese characters and English in this image:

How To Build A GUI For Optical Character Recognition. Chinese OCR
Image Source: https://cms.qz.com/wp-content/uploads/2017/06/china-english-road-signs-2017-e1498204314511.jpg?quality=75&strip=all&w=1600&h=903.

The following is a basic usage of EasyOCR to detect both Chinese characters and English in the sample image above (run this inside the lower Memo of Python4Delphi Demo01 GUI):

Let’s see the result on our P4D GUI:

How To Build A GUI For Optical Character Recognition. Demo output
EasyOCR Simplified Chinese Character and English Detection Demo with Python4Delphi in Windows.

 

Example 2: Arabic Character and English Recognition

Next example, we will test the EasyOCR library to detect both Arabic characters and English in this image:

How To Build A GUI For Optical Character Recognition. Recognizing Arabic characters in your app.
Image Source: https://sc04.alicdn.com/kf/H25fecd88d1a54cd494a7d11f23491f13g.jpg

Run the following EasyOCR code to detect both Arabic characters and English in the sample image above (run this inside the lower Memo of Python4Delphi Demo01 GUI):

Let’s see the result on our Python GUI:

How To Build A GUI For Optical Character Recognition. Results of processing OCR in your app.
EasyOCR Arabic Character and English Detection Demo with Python4Delphi in Windows.

Check out the full source code here!

Amazing isn’t it? You can make your computer recognize Chinese, Arabic, and English characters, as well as other 80+ supported languages.

Congratulations, now you have learned how to run the EasyOCR library using Python for Delphi to display it in the Delphi Windows GUI app! Now you can build countless powerful apps based on this end-to-end OCR framework created by the EasyOCR library and Python4Delphi.

 

Where can I find more examples of building GUI for Computer Vision libraries?

Check out the EasyOCR computer vision framework for Python and use it in your projects: 

https://pypi.org/project/easyocr/ and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi: https://github.com/pyscripter/python4delphi

Or read our collections of Computer Vision and AI-related articles:

Keras: 

OpenCV:

Face Recognition:

Mahotas:

PyTorch:

5 Ultimate Python Computer Vision Libraries:

10 Ultimate Python AI Libraries:

close
Related posts
Learn PythonPythonPython GUIWindows

What Are The Differences Between C++ and Python?

DelphiDelphiVCLPythonPython GUIWindows

What Is The Deallocates Method And What Does It Do?

DelphiDelphiVCLPythonPython GUIWindows

What You Need To Know About The Observers Property

DelphiLearn PythonPythonPython GUIRAD StudioWindows

What You Need To Automatically Scrape Millions Of Tweets

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish