Understanding OCR: Your (Entertaining) Guide to Optical Character Recognition

Poatek
Poatek
Published in
6 min readJul 19, 2023
Source: https://medium.com/huawei-developers/tagged/huawei

This guide introduces Optical Character Recognition (OCR), a technology that has made data handling more efficient across different industries. OCR has been utilized to digitize books, automate invoice processing, translate multilingual texts, and improve accessibility for visually impaired individuals. The guide explores the reasons behind using OCR and highlights its practical applications.

Intro

So, you might wonder, what is OCR? It’s a specific technology designed to convert documents, such as scanned paper documents, PDF files, or even images captured by a digital camera, into editable and searchable data. It works by recognizing the text in these documents and translating them into machine-readable text.

Source: https://argoskyc.com/wp-content/uploads/2022/03/OCR-ID-Template-How-1-896x1024.png

For instance, two current impressive examples of OCR technology in action are Google Lens and iOS 15’s Live Text feature. Google Lens, a powerful image recognition tool, incorporates OCR to extract and process text within images. Whether you need to translate foreign menus, copy printed text, or search for information, Google Lens seamlessly performs these tasks by leveraging its robust OCR capabilities. Similarly, Apple’s iOS 15 introduces Live Text, a game-changing feature that uses OCR to detect and convert text in real time from photos, screenshots, and camera views. It allows users to extract and interact with text, such as dialing a phone number directly from a picture or looking up addresses on Maps. Both Google Lens and iOS 15’s Live Text demonstrate exceptional OCR performance, providing users efficient and convenient ways to extract and utilize textual information daily.

Live text OCR in iOS 15. Source: https://9to5mac.com/2021/09/21/how-iphone-live-text-ocr-works-in-ios-15/
Google Lens extracts the text from images but, in this case, failed in object detection (I swear, the OCR feature is great!). Source: Reddit.

The history of OCR

Initially, OCR devices were primarily designed to assist blind and visually impaired individuals. An example of such a device is the optophone, created by Irish inventor Dr. Edmund Fournier d’Albe in 1912. The optophone scanner emitted sounds corresponding to specific letters or characters when moved across a printed page, allowing blind individuals to interpret them.

Optophone by Dr Edmund Fournier d’Albe. Source: https://en.wikipedia.org/wiki/Optophone

In 1954, the inaugural functional OCR machine found its home at Reader’s Digest, an esteemed American magazine. The primary function of this machine was to convert typewritten sales reports into punch cards for computer-based reading and searching purposes. However, during this period, it was not yet feasible to selectively extract relevant data, resulting in the need to process entire documents. Furthermore, these early OCR devices were characterized by their sizeable dimensions and high cost.

Punched card. Source: https://en.wikipedia.org/wiki/Punched_card

Why should you pay attention to OCR?

The importance of OCR is multi-faceted. It finds profound usage in various sectors. Many businesses use OCR for data entry automation, which saves manual labor and time. Libraries, universities, and other educational institutions rely on it for digitizing printed materials, making them more accessible and easier to search through. More impressively, OCR bears a significant societal impact as it aids visually challenged individuals by converting textual information to speech.

Globally, we see OCR’s impact in many pivotal sectors. It helps in traffic management systems through automatic license plate recognition and in postal services for mail sorting based on ZIP codes. OCR operates mostly behind the scenes, but its influence is substantial.

Cool applications using OCR

OCR technology has practical applications in various fields. It can extract information from invoices, convert legal documents into digital format, digitize medical records, solve CAPTCHA challenges, digitize printed materials in libraries, recognize and convert sheet music, read license plate numbers, and convert handwritten text into a digital format. OCR simplifies tasks, improves data accessibility, and enhances efficiency in different industries by transforming physical documents into digital formats.

In CAPTCHA, an image is generated consisting of a series of letters or numbers. This image is intentionally distorted with techniques such as image distortion, variations in size and font, distracting backgrounds, random segments, highlights, and noise. However, OCR (Optical Character Recognition) systems can remove the noise and segment the image, making it manageable for analysis. These OCR systems play a vital role in deciphering the obscured text within CAPTCHA images for further processing and understanding. (ps: the guy in the pic looks a lot like my bud victu gandara©). Source: Reddit.
Segmentation results for optical Music recognition. Source: Singh, Amarjot, Ketan Bacchuwar, and Akshay Bhasin. “A survey of OCR applications.” International Journal of Machine Learning and Computing 2.3 (2012): 314.

How does an OCR algorithm work?

A typical OCR pipeline involves three essential steps, including text detection, character segmentation, and text recognition. While there are additional stages, such as preprocessing and post-processing in a comprehensive OCR system, this article will primarily focus on the core steps involved in transforming an image into machine-readable text.

Source: Andrew Ng.
  1. Text Detection: In this stage, the aim is to locate and identify areas in an image or document that contain text. Various techniques can be employed, including edge detection, contour analysis, or advanced object detection algorithms like convolutional neural networks (CNNs). The result is a bounding box or region of interest (ROI) encompassing the text.
  2. Character Segmentation: Once the text regions are identified, the next step is to segment the individual characters within those regions. Techniques such as connected component analysis, contour analysis, or projection profile analysis can be employed to separate characters. By dividing the text into individual characters, we establish boundaries for recognition.
  3. Text Recognition: In this stage, the segmented characters are processed to recognize the actual text they represent. This can involve using traditional machine learning algorithms like Support Vector Machines (SVM), k-Nearest Neighbors (k-NN), or more advanced techniques like deep learning models, such as convolutional neural networks (CNNs) or recurrent neural networks (RNNs). The recognized characters are then combined to form words and sentences.

Why OCR is still an open task/problem

OCR systems struggle with low-resolution images, uneven lighting, blurriness, and noise. Enhancing OCR accuracy on challenging images remains a priority research area. Accommodating diverse character sets, different writing styles, and alignment variations across languages is a significant challenge.

I swear. Source: the author.

Recognizing handwritten text poses difficulties due to variability in writing styles, stroke formation, and character shapes. Improving accuracy and effectively handling different handwriting styles are ongoing research areas. OCR for historical documents is complex due to paper degradation, complex layouts, and outdated writing styles. Developing techniques specifically for historical documents, OCR is an active research field.

Analyzing and understanding complex document layouts, such as tables, multi-column text, or non-linear structures, is challenging. Robust layout analysis techniques are vital for accurate OCR.

Optimizing deep learning models for efficiency, reducing computational requirements, and handling limited training data are ongoing research areas. Addressing model size, training time, and generalization challenges is focused upon.

Some individuals argue that OCR is a solved task; however, it is important to note that OCR technology has made significant progress, but challenges with image quality, handwriting, historical documents, and complex layouts continue to require research advancements. OCR is not without limitations, and ongoing research efforts aim to further improve its capabilities in various domains.

Moniele Kunrath

References

https://hackerwins.github.io/2019-07-30/cs229a-week11

https://en.wikipedia.org/wiki/Optical_character_recognition

https://towardsdatascience.com/a-gentle-introduction-to-ocr-ee1469a201aa

Doermann, David, and Karl Tombre. Handbook of document image processing and recognition. Springer Publishing Company, Incorporated, 2014.

Singh, Amarjot, Ketan Bacchuwar, and Akshay Bhasin. “A survey of OCR applications.” International Journal of Machine Learning and Computing 2.3 (2012): 314.

Islam, Noman, Zeeshan Islam, and Nazia Noor. “A survey on optical character recognition system.” arXiv preprint arXiv:1710.05703 (2017).

Chaudhuri, Arindam, et al. Optical character recognition systems. Springer International Publishing, 2017.

https://github.com/kba/awesome-ocr/blob/master/README.md

Extra meme:

--

--

Poatek
Poatek
Editor for

We’re a software engineering company filled with the best tech talent!📍Porto Alegre, São Paulo, Miami and Lisbon linktr.ee/poatek.official