Example 1: Reading text from an Image

Step 1: Install and load the libraries:

R




install.packages('tesseract')
install.packages('magick')
library(tesseract)
library(magick)


Step 2: Load an image from a URL or file storage.

R




# Reading the image
img = image_read('https://media.w3wiki.org/wp-content/uploads/20190328185307/gfg28.png')
 
# Display
print(img)


Output:

w3wiki

Step 3: Apply the OCR method on it.

R




# OCR
text <- ocr(img)
 
# extracted text
print(text)


Output:

[1] "w3wiki\nA computer science portal for geeks\n"

Optical Character Recognition (Ocr) Using R

OCR transforms text images into machine-readable formats. With applications ranging from receipts to license plates, we explore the process, syntax, and examples, demonstrating its versatility. In this tutorial, we will learn to perform Optical Character Recognition in R programming language using the Tesseract and Magick libraries.

Similar Reads

Optical Character Recognition

OCR stands for Optical Character Recognition. It is the procedure that transforms a text image into a text format that computers can read. OCR generally scans the image and extracts the text from the image that we can store in any string variable. OCRs are used to read receipts, cheques, code scanners, license plate scanners, and other numerous applications....

Example 1: Reading text from an Image

Step 1: Install and load the libraries:...

Example 2: Converting text from PDF.

...

Text Localization in OCR

...

Advantages of OCR

...

Disadvantages of OCR

Here we need to convert the PDF into png and then perform the OCR. The syntax is as follows:...

Conclusion

...

Contact Us