1. Products
  2.   OCR
  3.   Ruby
  4.   Ruby-Tesseract-OCR
 
  

Free Ruby Library to Load & Extract Text from Images

Open Source Ruby OCR API that allows Software Developers to Load, Recognize and Extract Text from Images (scanned images & PDF files)

Optical Character Recognition (OCR) is a powerful technology that enables computers to recognize and extract text from images or scanned documents. It has numerous applications, ranging from digitizing printed materials to automating data entry processes. In the Ruby programming language, one popular library for OCR is Ruby-Tesseract-OCR. Ruby-Tesseract-OCR is a Ruby gem that serves as a wrapper for the Tesseract OCR engine. Tesseract is an Open Source OCR engine developed by Google and is renowned for its accuracy and language support.

Ruby-Tesseract-OCR goes beyond basic OCR capabilities and offers additional features for advanced use cases. For instance, Software developers can specify a region of interest (ROI) within an image to limit the OCR analysis to a specific area. This is particularly useful when dealing with complex documents or when you only need to extract text from a specific section. The library provides several additional features to enhance OCR capabilities, such as loading an existing image, extracting text from images or scanned documents, obtaining HOCR (HTML OCR) output, and many more.

The Ruby-Tesseract-OCR gem provides an easy-to-use interface to interact with the Tesseract engine, enabling Ruby developers to integrate OCR capabilities into their projects effortlessly. Whether you need to extract information from invoices, digitize printed materials, or automate data entry tasks, the open source library provides a reliable and efficient solution. Give it a try, and unlock the potential of OCR in your Ruby projects today.

Previous Next

Getting Started with Ruby-Tesseract-OCR

The recommend way to install Ruby-Tesseract-OCR is using Rubygems. Please use the following command for a smooth installation.

Install Ruby-Tesseract-OCR via Rubygems

gem install tesseract-ocr 

You can download the compiled shared library from Github repository.

Extract Text from Images & Scanned Documents via Ruby

Ruby-Tesseract-OCR is a very powerful open source library that allows software developers to load and extract text from various types of images with just a couple of lines of Ruby code. The library makes it easy to extract text from images, PDFS or scanned documents. The typical workflow involves loading an image, configuring the OCR parameters, and invoking the OCR engine to recognize the text. For a successful operation developers needs to provide the path to the image they want to process and call the text_for method to extract the text. Finally, the result will be printed to the console. The library offers various Fconfiguration options for controlling OCR behavior, such as page segmentation mode, whitelist characters, and more. The following examples shows how software developers can load a JPEG image and extract text from it inside Ruby applications.

How to Extract Text from Images using Ruby Commands?

require 'tesseract'

e = Tesseract::Engine.new {|e|
  e.language  = :eng
  e.blacklist = '|'
}

e.text_for('test/first.png').strip # => 'ABC'

Extract Text from a Particular Image Area via Ruby

The open source Ruby-Tesseract-OCR library goes beyond basic OCR capabilities and offers additional features for advanced use cases. For instance, users can specify a region of interest (ROI) within an image to limit the OCR analysis to a specific area. This is particularly useful when dealing with complex documents or when users only need to extract text from a specific section. Additionally, the library provides methods for obtaining HOCR (HTML OCR) output, which includes not only the recognized text but also information about the layout and coordinates of the text elements. HOCR output is helpful when you need more granular data or want to perform further analysis on the text structure.

How to perform hOCR on an Image via Ruby Library?

require 'tesseract'

e = Tesseract::Engine.new {|e|
  e.language  = :eng
  e.blacklist = '|'
}

puts e.hocr_for('test/first.png')
 English