Read Text From Images Using Python and EasyOCR

We frequently received documents in the form of images or PDFs. Sometimes we need to extract text/data from photos, and copy/paste is not an option. If we have several papers, it is extremely difficult and time consuming to extract data from photos.

With Python OCR, systems can read text from images, invoices, PDFs, hand-written text, and printed documents. OCR, or optical character recognition, is a computer vision technology. Text can be extracted from photos, and images may be simply converted to text. EasyOCR is the most basic method of implementing OCR. It is a Python library that can read text from photos in over 40 different languages. It is incredibly simple to implement with only a few lines of code and produces good results.

OCR-Text

When to use OCR

When we encounter a circumstance in which we must deal with non-editable textual pictures, PDFs, and printed hard copies, it will take a significant amount of time and effort to accomplish your work. Then OCR may be a better alternative for you, since it will quickly address your problem by extracting text from these papers rather than doing the same manually. Increase work efficiency by avoiding human errors.

How to use EasyOCR

EasyOCR is incredibly simple to use as it has few dependencies.

Install the EasyOCR package first with the pip install easyocr command.

When easyocr is installed, use the import easyocr command to import the package to your project.

Then you may start writing code to extract text from photos. By supplying [‘en’] to process in English, it will read only English text and ignore the rest of the text. You can pass whatever language you like and then load image path in readtext (image path) method for reading text.

And that’s how easily you extracted text from an image.

Let us try to extract text from below image

Read text from Images

“import easyocr
reader = easyocr.Reader([‘en’])
Result = reader.readtext(‘abc.png’)
Print(result)”

OUTPUT: [([[272, 304], [446, 304], [446, 336], [272, 336]], ‘Hello World!!’, 0.737285318007567)]

This kind of output could be difficult for the non-developers to understand hence we can make it simple by passing the detail parameter as 0.

“import easyocr
reader = easyocr.Reader([‘en’])
Result = reader.readtext(‘abc.png’, detail=0)
Print(result)”

OUTPUT: [‘Hello World!!’]

The output is not showing the coordinates of the text as we pass the detail parameter as 0. It is only showing the required text. In this code ‘en’ is english language we can write any language in which we want to extract text.

Use Cases of OCR

  • Converts hand-written text to machine-readable text.
  • Invoice processing.
  • Traffic sign Recognition.
  • PDF extraction.
  • Number Plate Recognition.
  • Digital Document Scanning.

Advantages

  • Easy and fast document processing.
  • Cost Reduction.
  • Increase Production
  • High accuracy
  • Reduce workload of employees
  • Environment Friendly- As it read text from documents and process them it will reduce the use of papers and save papers.

Disadvantages

  • OCR cannot read hand-written text.
  • OCR images needs lot of memory space.
  • OCR systems are quite expensive.
  • OCR systems are not 100% accurate.
  • OCR needs a good quality image to work well.

How OCR helps in solving Business Problems?

OCR helps in Business to become more productive and cost-efficient by making easy to process documents and digitize them.

  • Converts Document to editable and searchable data- We can get any type of document it can be paper document, image, by email or hand-written data. OCR digitize all your data and make it easy to edit or search for the information we are looking without consuming lot of time and efforts.
  • Accelerate speed of Document processing
  • Improve data Security- OCR uses AI and Machine Learning to recognize sensitive information and protects from unauthorized employee to access the information.
  • Reduce Cost- OCR assist Business to reduce cost by improves accuracy of Data entry and save money spent on manual entry also reduce errors.
  • Retrieve information faster- Employees usually spend a lot of time in retrieving information from documents. When the document is very large it can be very useful in making information more accessible for employees and making decision faster so that they can focus on more important tasks.

Conclusion

EasyOCR is the simplest and easiest way to implement Optical Character Recognition (OCR) with very few lines of code. Dealing with images becomes simple and quick. A large amount of text can be processed quickly. The information obtained through OCR is then more understandable and accurate. OCR is more accurate and takes less time than manual typing. It contributes to improved performance accuracy.

If you want to learn more about such topics or if you need software consulting, please contact us at info@ignatiuz.com.

Leave a comment