Text Detection From Images Using EasyOCR: Complete Guide

In this article, we’ll go over how to implement OCR using EasyOCR, a tool that’s simple to use, accurate, and multilingual. In addition to English, this library also supports other languages. 

Text Detection from Images Using EasyOCR: Complete Guide

About Optical Character Recognition (OCR)

However, EasyOCR, a Python-based OCR tool based on deep learning, allows you to extract text from photos.

A computer vision task for removing characters from images is called optical character recognition (OCR).

OCR is frequently utilized in a variety of tasks, including translation, bill extraction, license plate identification, and many others.

However, OCR implementation is not easy. Even without adding the modeling itself, the pipeline as a whole involves numerous preprocessing processes. Fortunately, EasyOCR is at our disposal.

What is EasyOCR?

PyTorch serves as the backend handler for EasyOCR, a Python package.

While using EasyOCR, I discovered that it is the most user-friendly method for extracting text from photos, even when a powerful deep-learning library, such as PyTorch, is supporting it in the background.

This increases the reliability the accuracy of the text extraction.

easyOCR supports 42+ languages for language detection. Jaided AI Firm is the company that developed EasyOCR.

How to Get Started With Optical Character Recognition

With optical character recognition, each character on a page is individually scanned, allowing your text to be submitted as text documents rather than photos.

A Python module called EasyOCR makes optical character recognition simple to do. It will be applied to word extraction from visuals. Using OpenCV, we’ll be able to see these outcomes.

You must: in order to follow along with this tutorial.

  • Learn about modeling using machine learning.
  • Use Google Colab or Jupyter Notebook.

1. Install Core Dependencies

  • Pytorch

It can be a little challenging to install PyTorch as a complete package, therefore we suggest exploring the official PyTorch website. 

You will understand its interface when you go about the process as you through the official website.

Now, if you carefully examine the above image, you will see that there are many possibilities available for us to select from and obtain the command that is best consistent with our preferences.

When you go through the websites, you are expected to select Package: pip and Compute platform: CPU, and as a result, you will receive the command: pip install torch torchvision torchaudio. 

Once you have this command, installing the PyTorch library will be as simple as walking on the cake. Just run this command at the command prompt.

  • EasyOCR

Running the following command will successfully install the EasyOCR library after the PyTorch library has been installed.

Command: pip3 install easyocr

2. Importing Libraries

import os

Also, import easyocr

import cv2

from matplotlib import pyplot as plt

import numpy as np

3. Reading Images

  • Taking an online image: Here, we’ll pull a picture from a URL (online)

IMAGE_PATH = ‘https://blog.aspose.com/wp-content/uploads/sites/2/2020/05/Perform-OCR-using-C.jpg

The URL of the image is stored in the IMAGE PATH variable in the code excerpt above.

  • Taking image as input locally: Here we will take an image from the local system.

IMAGE_PATH = ‘Perform-OCR.jpg’

One can see from the code snippet above that I pulled the image from the local system.

4. Extracting Text From the Image

  • English text detection

reader = easyocr.Reader([‘en’])

result = reader.readtext(IMAGE_PATH,paragraph=”False”)


[[[[95, 71], [153, 71], [153, 107], [95, 107]], ‘OCR’]]

Adding an image for your preference.

Finally, we have been able to extract the text from the provided image.

Line by line, let’s examine the code:

  • Here, we’re using the Reader class from the EasyOCR class and supplying [‘en’] as an attribute, so that it will only recognize the English portion of the image as text; if it finds other languages, such as Chinese and Japanese, it will ignore those texts.
  • Now that we have set the language property in the line above, when we load the IMAGE PATH in the readText() function, the parameter “paragraph” is set to False, meaning that easyOCR will no longer combine the results, i.e. If easyocr runs into numerous texts, it will display each one separately rather than combining them.
  • Obtaining the outcome as a 2-D NumPy array.

We brought in four items:

  • EasyOCR is the main package that we will use to perform optical character recognition.
  • OpenCV as cv2. It will help us import our image and visualize it.
  • Matplotlib also helps in visualization.
  • Numpy to help perform mathematical calculations.

How to Use EasyOCR to Extract Text From an Image

First, we need to pass in the easyocr reader and pass in the language that we want to use. In our case, that’ll be English.

Secondly, using the ocr_reader, we pass in the read text command and pass in our image. We save these results in a variable called results.

ocr_reader = easyocr.Reader(['en'])
results = ocr_reader.readtext(image)


([[121.756503204768, 455.2312153828863],
   [389.1020796120134, 432.6470713866934],
   [389.24349679523203, 524.7687846171136],
   [122.8979203879866, 547.3529286133066]],
 ([[126.45506700720357, 542.3292546273735],
   [389.0906482289428, 511.83345289506786],
   [393.5449329927964, 599.6707453726265],
   [130.90935177105715, 630.1665471049322]],
 ([[190.6717988226486, 618.007698233973],
   [392.5179510077811, 588.6436857858664],
   [398.3282011773514, 642.992301766027],
   [196.48204899221892, 672.3563142141336]],

After using EasyOCR on the image, we can see that the text was successfully extracted from the image with a high level of confidence.

The various numbers show the coordinates of where our text is located within the image.


In many ways, EasyOCR outperforms Tesseract (another OCR engine created by google used with the python package Pytesseract).

It is simple to use, only requires a few lines of code to implement, and provides accurate results for the majority of evaluated photos.

More so, it is also expanded over a wide range of languages. The AIM’s GitHub repository hosts the full implementation’s source code. 

Frequently Asked Questions

A printed character reader that is reliant on typeface and uses a template matching method.

Yes, it is.

Yes, it is.


It’s very good.

Google Cloud Vision API

Pytesseract or Python-tesseract

Similar Posts

Leave a Reply

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