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.
Table of Contents
What is the EasyOCR library?
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.
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.
The next step is installing EasyOCR into your system. Here is how you can get EasyOCR using pip for stable release:
1 |
pip install easyocr |
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:
1 2 |
import easyocr reader = easyocr.Reader(['ch_sim','en']) |
Next, we will test the EasyOCR library to detect both Chinese characters and English in this image:
Next, we will test the EasyOCR library to detect both Chinese characters and English in this image:
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):
1 2 3 4 5 6 7 |
import os os.system('cmd /k "chcp 936"') import easyocr reader = easyocr.Reader(['ch_sim','en']) result = reader.readtext('C:/Users/YOUR_USERNAME/chinese2.jpg') print(result) |
Let’s see the result on our P4D GUI:
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:
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):
1 2 3 4 5 6 7 |
import os os.system('cmd /k "chcp 1256"') import easyocr reader = easyocr.Reader(["ar","fa","ur","ug","en"]) result = reader.readtext('C:/Users/ASUS/arabic.jpg') print(result) |
Let’s see the result on our Python GUI:
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: