avatarIrfan Alghani Khalid

Summary

The undefined website provides a tutorial on implementing an OCR (Optical Character Recognition) model using the EasyOCR library in Python, demonstrating its ease of use and multilingual capabilities.

Abstract

The article on the undefined website introduces EasyOCR, a Python library that simplifies the process of creating an OCR model. It explains the complexity of OCR and how EasyOCR bypasses these intricacies by offering a ready-to-use model. The tutorial guides readers through installing the library using pip, implementing OCR on images with both Latin and non-Latin characters, and handling the output for better readability. It also addresses potential issues with running EasyOCR on platforms like Google Colab by suggesting a reinstallation of the OpenCV library. The article concludes by showcasing EasyOCR's multilingual support, including languages like Korean and Japanese, and provides tips on simplifying the OCR output.

Opinions

  • The author expresses that implementing OCR can be complex due to preprocessing and modeling steps, but EasyOCR makes it accessible with greater accuracy.
  • EasyOCR is praised for its ability to extract text from images with high accuracy and for supporting a wide range of languages beyond Latin characters.
  • The article suggests that EasyOCR can be a valuable tool for tasks such as translation, invoice extraction, and plate number recognition.
  • The author recommends using the detail=0 parameter in the readtext function to obtain a simplified output without bounding boxes and confidence scores.
  • The author provides a personal LinkedIn connection option and promotes an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus (GPT-4).

Create Your Own OCR in Few Lines of Code Using EasyOCR

Implement your own OCR without a headache

Photo by Markus Winkler on Unsplash

Introduction

Optical Character Recognition (OCR) is a computer vision task for extracting characters from images. OCR is widely used in many applications, such as translation, invoice extraction, plate number recognition, and many more.

Implementing OCR is not simple. The pipeline itself contains lots of preprocessing steps, and that’s not including the modeling itself. But thankfully, EasyOCR is available to us!

EasyOCR is a Python-based library for using a ready-to-use OCR model. With this library, you don’t have to worry about the preprocessing and the modeling step. In a few lines of code, you can use the OCR with greater accuracy. For more details, you can read about EasyOCR through the link here.

In this article, I will show you how to implement an OCR model using the EasyOCR library. Without further ado, let’s get started!

Implementation

Install the OCR

We cannot use the EasyOCR library right now. Therefore, we need to install the library first. For installing that, we can use the pip command. Here is the code for doing that:

Run the OCR

After you install the library, you can implement the OCR process now. Just like this article’s title says, you only need a few lines of code for implementing the OCR. With EasyOCR, it’s possible!

For example, we will extract texts from the picture below:

Photo by Alejandro Luengo on Unsplash

From that picture, how can we extract the texts? With EasyOCR, the code looks like this:

With less than five lines of code, you can implement your own OCR easier! So how does the result? Please run the code down below:

From the result, we can see that the library can extract almost every text inside the picture easier. And what’s incredible about it is the accuracy of the OCR has. It’s incredible!

If you have any problems running the EasyOCR, especially when you run it on Google Colab, you can reinstall the OpenCV library to the desired version. You can run the command below for fixing the problem:

Multilingual Support

Outside the Latin characters, the EasyOCR library also supports other languages like Korean, Japanese, Arabic, Hindi, etc. Let’s take an example from this picture below:

Photo by BBiDDac on Unsplash

From that picture, we will extract the hangeul characters along with Latin characters at the same time.

With EasyOCR, adding other languages is really straightforward. All you need is to add another language code inside the easyocr.Reader object. Here is the code for doing that:

From that code, we can get outputs in Korean and English simultaneously. And amazingly, it detects the text accurately for both languages.

Simplify the output

In case you want to simplify the result, you can add a parameter inside the readtext function with detail=0.

This parameter will throw out the bounding box and also the confidence score from the output.

Here is the code for doing that:

If you want to unify texts that are close to each other, you can write these lines of code below:

Conclusion

Well done! You have learned how to implement OCR using EasyOCR. I hope this article helps you implement OCR in a few lines of code.

Thank you for reading my article!

References

[1] https://github.com/JaidedAI/EasyOCR [2] https://exerror.com/importerror-cannot-import-name-_registermattype-from-cv2-cv2/

Want to Connect?
You can connect with me through LinkedIn.
Machine Learning
Programming
Data Science
Artificial Intelligence
Python
Recommended from ReadMedium