How to install and use EasyOCR on Linux

This article will guide you through installing and using the EasyOCR command line tool and Python module. Available as a free and open source application, it can be used to identify and extract text from images. It uses optical character recognition (OCR) technology and many different algorithms and language models to detect text.

Key features of EasyOCR

EasyOCR can detect text in over 80 languages ​​and scripts. It includes pre-trained models for these languages, but you can use EasyOCR to train your own models from scratch. Besides digital and printed text content in images, EasyOCR can also detect and extract handwritten text. Other main features of EasyOCR include the ability to batch process multiple images at the same time, the ability to restrict and block specific characters in the language, the ability to convert extracted lines to paragraphs, the ability to resize and enlarge images to improve detection accuracy, and more.

Installing EasyOCR on Linux

You can install EasyOCR on Linux using the pip package manager. To install pip package manager on Ubuntu use the following command:

                      $ sudo apt install python3-pip

The Pip package manager is available in the official repositories of many Linux distributions, so you can install it from the standard package manager. You can also follow the official installation instructions available here to install the pip package manager on your Linux system.

After successfully installing the pip package manager, run the following command to install EasyOCR on Linux:

                      $ pip3 install easyocr

Using EasyOCR on Linux

To extract the text from the image above, you will need to run the command in the following format:

                      $ easyocr -l en -f image.png

The first parameter “-l” can be used to specify the language of the text content that you want to capture with EasyOCR. You can specify multiple languages ​​using command-separated language codes. The “-f” switch is used to specify an input image file. A list of all languages ​​supported by EasyOCR and their codes can be found here (scroll down to see them).

The output displays specific numbers and text extracted from the image. This output can be read in the following format: coordinates of individual text fragments> detected text> confidence level. Thus, the numbers on the far left represent the coordinates of the identified text boxes, while the number on the far right indicates how accurate the extracted text is.

If you just want to get the detected text in human readable form, add the “–detail 0” switch to the above command:

                      $ easyocr -l en --detail 0 -f image.png

As you can see in the output, the extracted text is in the wrong order. You can try the “–paragraph True” command line option to concatenate the individual parts and sentences in the correct order.

                      $ easyocr -l en --detail 0 --paragraph True -f image.png

Please note that depending on the quality and clarity of the image and the textual content of the image, there may always be some inaccuracies in the extracted text, and you may have to make manual corrections to correct them.

To save the identified text to an external file, use the> symbol and specify a name for the output file. Here’s an example command:

                      $ easyocr -l en --detail 0 --paragraph True -f image.png > output.txt

To learn more about all the command line options supported by EasyOCR, use the following command:

                      $ easyocr --help

Using EasyOCR in Python Programs

EasyOCR is also available as a Python library, so you can import its main module into your Python programs. Below is a sample code to illustrate its use in a Python program:

                      import easyocr

reader = easyocr.Reader(['en'])
result = reader.readtext('image.png', detail=0, paragraph=True)
with open("output.txt", "w") as f:
for line in result:
print(line, file=f)

The first statement is used to import the easyocr module into your Python program. Then, a new instance of the “Reader” class (base class) is created, providing as the main argument a list of languages ​​supported by EasyOCR. If your image contains text in multiple languages, you can add other language codes to the list. The “readtext” method is then called on the “reader” instance, and the path to the image file is provided as the first parameter. This method identifies and extracts text from the provided image. The two optional arguments, “detail” and “paragraph”, are the same as the command line parameters described above. They simplify the text by removing unnecessary elements.


EasyOCR is a command line text extraction tool that comes with pre-trained models for many languages. This allows end users to quickly identify and extract text from images without having their own language models. It also provides detailed bounding box coordinates around identified and tagged words, making it easier to parse individual pieces of text.

Related Posts