A Comparison between IronOCR and AWS OCR

What is OCR?

The procedure used to transform an image of text into a machine-readable text format is known as Optical Character Recognition (OCR). For example, if you scan a form, invoices or a receipt, your computer saves the scan as an image file. The data in the image file cannot be edited, searched for, or counted using a text editor. However, you can use OCR solutions to convert the image file into a text document with its contents stored as text data.

In this modern era, most business workflows involve receiving information from print media. Different documents like paper forms, invoices, scanned legal documents, table extraction, handwritten texts and printed text or contracts are all part of business processes. Moreover, digitizing such documentation content creates images with the text hidden within it. Text in images cannot be processed by word processing tool in the same way as text documents. OCR technology solves the problem by converting text images into text data that can be analyzed by other business software.

How OCR works?

The OCR engine works by using the following steps:

Image acquisition

In this process, a scanner reads documents and converts them to binary data. The OCR softwares identify the scanned image and classify the light areas as background and the dark areas as text.

Preprocessing

The OCR software first cleans the image and removes errors to prepare its data for reading.

Text recognition

The two main types of OCR algorithms for text recognition are pattern matching and feature extraction.

Pattern matching

A character picture, or glyph, is isolated throughout the pattern matching process and compared to a previously recorded glyph.

Feature extraction

Through the process of feature extraction, the glyphs are divided into features like lines, closed loops, line direction, and line junctions.

Postprocessing

The technology transforms the retrieved text data into a digital file after analysis. Some OCR systems can create annotated PDF documents that include both the before and after versions of the scanned document.

This article will discuss the comparison between two of the most prevalent applications and document libraries for OCR. These are:

  • IronOCR
  • AWS OCR Textract

Introduction

IronOCR Library

IronOCR is a C# .NET library that offers services to scan, search, read images and PDFs. It comes with 127+ global language packs. The output is achieved as text, structured data, or searchable PDFs. Supports .NET versions like 6, 5, Core, Standard, and Framework.

IronOCR is unique in its ability to automatically detect and extract data from imperfectly scanned images and documents. The 'IronTesseract' Class has the most straightforward API. It provides the most advanced build of Tesseract known anywhere, on any platform with increased speed, accuracy and a native DLL and API.

IronOCR can also scan barcodes and QR codes from all image formats, and it reads text and performs PDF scanning using the latest Tesseract 5 engine.

Features

  • It is made purely for .NET applications.
  • It can support 127 different languages. Arabic, Chinese, English, Finnish, French, German, Japanese, and many other languages are supported by IronOCR.
  • It can correct a tilted image's position and remove noise from an image for precise output.
  • It performs exceptionally well in low-resolution images with low DPI.
  • It can read multiple types of QR codes and barcodes.
  • It also supports the Gif and Tiff formats.
  • It allows many threads at once. It is an outstanding feature that is not present in other OCR libraries. It makes the processes smoother.
  • It can easily perform OCR on PDF files and export searchable PDF documents using OCR.

Now, let's have a look at AWS OCR.

AWS OCR Textract

Amazon's AWS Textract is a machine learning (ML) service that automatically extracts text, handwriting, and data from scanned documents. It goes beyond simple optical character recognition (OCR) to identify, understand, and extract data from forms and tables using deep learning technology.

AWS OCR Textract uses machine learning to read and process any type of document, accurately extracting text, handwriting, tabular data, and other data with no manual effort. Instead of taking hours or days to extract the data, Textract can do so quickly. Additionally, you can add human reviews with Amazon Augmented Artificial Intelligence (AI) to provide oversight of your models and check sensitive data.

Features

  • Detect typed and handwritten text in a variety of documents, including financial reports, medical records, tables, and tax forms.
  • Extract text, forms, and table data from documents with structured data, using the Document Analysis API.
  • Specify and extract information from documents using the Queries feature within the Analyze Document API.
  • Process invoices and receipts with the Analyze Expense API.
  • Process ID documents such as driver's licenses and passports issued by U.S. government, using the Analyze ID API.
  • Scalable document analysis which can accelerate decision making.

The rest of the article goes as follows:

  1. Creating Visual Studio Project
  2. Installing IronOCR
  3. Installing AWS OCR Textract
  4. PDF to Text
  5. Image to Text
  6. Barcode and QR to Text
  7. Licensing
  8. Conclusion

1. Creating Visual Studio Project

This tutorial will use the Visual Studio 2022 version so I assume you must have installed it.

  • Open Visual Studio 2022.
  • Generate a new .NET Core project and then select Console App.

Console Application

  • Give a name to the project. E.g TextReader.
  • The latest and most stable version of the .NET framework is 6.0. We are going to use this.

    .NET Framework

  • Click Create button and the project will be created.

Next, we will install the libraries for our use one by one.

2. Installing IronOCR

The IronOCR library can be downloaded and installed in four ways. These are as follows:

  1. Using the Visual Studio NuGet Package Manager.
  2. Direct download via the NuGet website.
  3. Direct download via the IronOCR webpage.
  4. Using the Command Line in Visual Studio.

2.1. Using the Visual Studio NuGet Manager

The Visual Studio NuGet Package Manager can be used to incorporate IronOCR into a C# project.

  1. Expand Tools or by right-clicking solution explorer.
  2. Extend the NuGet Package Manager.
  3. Click on Manage NuGet Packages for Solutions or click Manage NuGet Packages in solution explorer.
Manage NuGet Package

Manage NuGet Packages

After this, a new window will appear in the search bar: type IronOCR. Check the project box on right side and click Install.

Browse IronOCR

Browse IronOCR

By using this method, developers can install the IronOCR library and any language pack of the developer's choice.

2.2. Direct download via the NuGet website

IronOCR can be directly downloaded from the NuGet website by following these instructions:

  1. Navigate to the link "https://www.nuget.org/packages/IronOCR/".
  2. Select the download package option from the menu on the right-hand side.
  3. Double-click the download package. It will be installed automatically.
  4. Next, reload the solution and start using it on the project.

2.3. Direct download via the IronOCR webpage

Developers can download the IronOCR library directly from the website by using this Link.

  1. Right-click the project from the solution window.
  2. Then, select option Reference and browse the location of the downloaded reference.
  3. Next, click OK to add the reference.

2.4. Using the Command Line in Visual Studio

  1. In Visual Studio, go to Tools-> NuGet Package manager -> Package manager console
  2. Enter the following line in the package manager console tab:

    Install-Package IronOCR

The package will now download/install in the current project and is ready to use.

Package Manager Console

Console Application

Install IronOCR

Console Application

After typing the command, press enter and it will be installed.

2.5. Adding IronOCR Namespace

Include this line of code in the program to use IronOCR:

using IronOcr;
using IronOcr;
Imports IronOcr
VB   C#

Now let's install AWS Textract.

3. Installing AWS Textract OCR

Before you use Amazon Textract for the first time, complete the following tasks:

  1. Sign Up for AWS services.
  2. Create an IAM User.

Once you have successfully signed up for the account and created IAM user, you can now set the access keys in AWS console to access the API programmatically using C#. You will need:

  • AccessKeyId
  • SecretAccessKey
  • RegionEndPoint (Your access area)- In this example case: AFSouth1

3.1. Using NuGet Package Manager

  • You can download and install AWS Textract SDK from Nuget Package Manager.
NuGet Package Manager

NuGet Package Manager

  • Click on Browse and search for AWS Textract:
AWS Textract

AWS Textract

3.2. Adding AWS OCR Namespaces

Include the following namespaces to use AWS Textract:

using Amazon.Textract;
using Amazon.Textract.Model;
using Amazon.Textract;
using Amazon.Textract.Model;
Imports Amazon.Textract
Imports Amazon.Textract.Model
VB   C#

4. PDF file to Text

Both the libraries can extract text from PDF files. Let's have a look at the code one by one.

4.1. Using IronOCR

IronOCR allows to recognize and read text from PDF document formats using the advanced Tesseract. The following simple code is used for extracting information:

var Ocr = new IronTesseract();
using (var input = new OcrInput())
{
    input.AddPdf("example.pdf","password");
    // We can also select specific PDF page numbers to OCR
    var Result = Ocr.Read(input);
    Console.WriteLine(Result.Text);
    Console.WriteLine($"{Result.Pages.Count()} Pages");
    // Read every page of the PDF
}
var Ocr = new IronTesseract();
using (var input = new OcrInput())
{
    input.AddPdf("example.pdf","password");
    // We can also select specific PDF page numbers to OCR
    var Result = Ocr.Read(input);
    Console.WriteLine(Result.Text);
    Console.WriteLine($"{Result.Pages.Count()} Pages");
    // Read every page of the PDF
}
Dim Ocr = New IronTesseract()
Using input = New OcrInput()
	input.AddPdf("example.pdf","password")
	' We can also select specific PDF page numbers to OCR
	Dim Result = Ocr.Read(input)
	Console.WriteLine(Result.Text)
	Console.WriteLine($"{Result.Pages.Count()} Pages")
	' Read every page of the PDF
End Using
VB   C#

The code is simple, clean, and very easy to understand and use.

Input PDF File

Example PDF

Example PDF

Output

IronOCR Output

IronOCR Output

4.2. AWS Textract

Amazon Textract makes it easy to add document text detection and analysis to your applications. The following code is used to read PDF and same PDF is passed:

public static async void ReturnResult()
{
    AmazonTextractClient client = new AmazonTextractClient("your_access_key_id", "your_secret_access_key", Amazon.RegionEndpoint.AFSouth1);
    var request = new StartDocumentTextDetectionRequest();
    request.DocumentLocation = new DocumentLocation
    {
        S3Object = new S3Object
                {
                    Bucket = "your_bucket_name",
                    Name = "your_bucket_key"
                }
         };
         var id = await client.StartDocumentTextDetectionAsync(request);
         var jobId = id.JobId;
         var response = client.GetDocumentTextDetectionAsync(new GetDocumentTextDetectionRequest{
             JobId = jobId
         });
         response.Wait();
         if (response.Result.JobStatus.Equals("SUCCEEDED"))
         {
        foreach (var block in response.Result.Blocks)
                {
                    if (block.BlockType == "WORD")
                    {
                        Console.WriteLine(block.Text);
                    }
                    else if (block.BlockType == "PAGE")
                    {
                        Console.WriteLine(block.Text);
                    }
                    else if (block.BlockType == "Line")
                    {
                        Console.WriteLine(block.Text);
                    }
                }
            }
        }
}
static void Main(String[] args)
{
    ReturnResult();
}
public static async void ReturnResult()
{
    AmazonTextractClient client = new AmazonTextractClient("your_access_key_id", "your_secret_access_key", Amazon.RegionEndpoint.AFSouth1);
    var request = new StartDocumentTextDetectionRequest();
    request.DocumentLocation = new DocumentLocation
    {
        S3Object = new S3Object
                {
                    Bucket = "your_bucket_name",
                    Name = "your_bucket_key"
                }
         };
         var id = await client.StartDocumentTextDetectionAsync(request);
         var jobId = id.JobId;
         var response = client.GetDocumentTextDetectionAsync(new GetDocumentTextDetectionRequest{
             JobId = jobId
         });
         response.Wait();
         if (response.Result.JobStatus.Equals("SUCCEEDED"))
         {
        foreach (var block in response.Result.Blocks)
                {
                    if (block.BlockType == "WORD")
                    {
                        Console.WriteLine(block.Text);
                    }
                    else if (block.BlockType == "PAGE")
                    {
                        Console.WriteLine(block.Text);
                    }
                    else if (block.BlockType == "Line")
                    {
                        Console.WriteLine(block.Text);
                    }
                }
            }
        }
}
static void Main(String[] args)
{
    ReturnResult();
}
Public Shared Async Sub ReturnResult()
	Dim client As New AmazonTextractClient("your_access_key_id", "your_secret_access_key", Amazon.RegionEndpoint.AFSouth1)
	Dim request = New StartDocumentTextDetectionRequest()
	request.DocumentLocation = New DocumentLocation With {
		.S3Object = New S3Object With {
			.Bucket = "your_bucket_name",
			.Name = "your_bucket_key"
		}
	}
		 Dim id = Await client.StartDocumentTextDetectionAsync(request)
		 Dim jobId = id.JobId
		 Dim response = client.GetDocumentTextDetectionAsync(New GetDocumentTextDetectionRequest With {.JobId = jobId})
		 response.Wait()
		 If response.Result.JobStatus.Equals("SUCCEEDED") Then
		For Each block In response.Result.Blocks
					If block.BlockType = "WORD" Then
						Console.WriteLine(block.Text)
					ElseIf block.BlockType = "PAGE" Then
						Console.WriteLine(block.Text)
					ElseIf block.BlockType = "Line" Then
						Console.WriteLine(block.Text)
					End If
		Next block
		 End If
End Sub
}
Shared Sub Main(ByVal args() As String)
	ReturnResult()
End Sub
VB   C#

The code is a bit tricky, lengthy and needs attention while passing and retrieving objects. First, we have to create AmazonTextractClient object with 3 parameters: AccessKeyId, SecretAccessKey, and Region. Then we have to initiate a request using StartDocumentTextDetectionRequest() method. The request object then sets the DocumentLocation using the bucket name and key. This request is then passed to StartDocumentTextDetectionAsync() method. As it is an async method, we have to use await keyword before it and make the ReturnResult function async. On successful, the result is returned and jobid is saved. The jobid is passed to GetDocumentTextDetectionAsync() method and wait for SUCCEEDED response. Foreach loop is used to loop through each block and check if it is "WORD", "PAGE" or "LINE", then print out the text recognition. Lastly, call this method in Main method for document processing.

Output

The output is pretty similar to IronOCR.

AWS Textract Output

AWS Textract Output

5. Images to Text

Reading data from images is tricky as the quality of image plays a vital role while extracting information. Both the libraries provide the facility to extract text. Here we will use png files.

5.1. Using IronOCR

The code is almost similar to the previous one. Here, AddPDF method is replaced with AddImage method.

var Ocr = new IronTesseract();
using (var Input = new OcrInput()){
    Input.AddImage("test-files/redacted-employmentapp.png")
    //... you can add any number of images
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
var Ocr = new IronTesseract();
using (var Input = new OcrInput()){
    Input.AddImage("test-files/redacted-employmentapp.png")
    //... you can add any number of images
    var Result = Ocr.Read(Input);
    Console.WriteLine(Result.Text);
}
Dim Ocr = New IronTesseract()
Using Input = New OcrInput()
	Input.AddImage("test-files/redacted-employmentapp.png") var Result = Ocr.Read(Input)
	Console.WriteLine(Result.Text)
End Using
VB   C#

Input Image

Redacted Employee Data

Redacted Employee Data

Output

The output is clean and matches the original image just with a few lines of code without any technicality and perfect output.

Image Output

Image Output

Image Output

5.2. Using AWS Textract

The following code helps to detect text from images:

public static async void ReturnResult()
{
    AmazonTextractClient client = new   AmazonTextractClient("your_access_key_id", "your_secret_access_key", Amazon.RegionEndpoint.AFSouth1);
    var request = new DetectDocumentTextRequest();
    request.Document = new Document {
            Bytes = new MemoryStream(File.ReadAllBytes(@"test-files/redacted-employmentapp.png"))}; 
    var result = await client.DetectDocumentTextAsync(request);
    foreach (var block in result.Blocks)
    {
        if (block.BlockType == "WORD")
        {
            Console.WriteLine(block.Text);
        }
    }
}

static void Main(String[] args)
{
    ReturnResult();
}
public static async void ReturnResult()
{
    AmazonTextractClient client = new   AmazonTextractClient("your_access_key_id", "your_secret_access_key", Amazon.RegionEndpoint.AFSouth1);
    var request = new DetectDocumentTextRequest();
    request.Document = new Document {
            Bytes = new MemoryStream(File.ReadAllBytes(@"test-files/redacted-employmentapp.png"))}; 
    var result = await client.DetectDocumentTextAsync(request);
    foreach (var block in result.Blocks)
    {
        if (block.BlockType == "WORD")
        {
            Console.WriteLine(block.Text);
        }
    }
}

static void Main(String[] args)
{
    ReturnResult();
}
Public Shared Async Sub ReturnResult()
	Dim client As New AmazonTextractClient("your_access_key_id", "your_secret_access_key", Amazon.RegionEndpoint.AFSouth1)
	Dim request = New DetectDocumentTextRequest()
	request.Document = New Document With {.Bytes = New MemoryStream(File.ReadAllBytes("test-files/redacted-employmentapp.png"))}
	Dim result = Await client.DetectDocumentTextAsync(request)
	For Each block In result.Blocks
		If block.BlockType = "WORD" Then
			Console.WriteLine(block.Text)
		End If
	Next block
End Sub

Shared Sub Main(ByVal args() As String)
	ReturnResult()
End Sub
VB   C#

Again, the code is almost similar to previous one. Here, we have to initiate a request using DetectDocumentTextRequest() method. The request object then sets the document by reading all the bytes. This request is then passed to DetectDocumentTextAsync() method. As it is an async method, we have to use await keyword before it and make the ReturnResult function async. On successful, the result is returned in blocks. Foreach loop is used to loop through each block and check if it is "WORD", then print out the text recognition. Lastly, call this method in Main method for document processing.

The output is similar to IronOCR but this needs the file to be uploaded to AWS bucket in the first place.

6. Barcode and QR code to Text

A unique feature of IronOCR is it can read barcodes and QR codes from documents while it is scanning for text. Instances of the OcrResult.OcrBarcode class gives the developer detailed information about each scanned barcode. AWS Textract does not provide this functionality.

The code for IronOCR is given below:

var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
using (var input = new OcrInput())
{
    input.AddImage("test-files/Barcode.png");
    var Result = Ocr.Read(input);
    foreach (var Barcode in Result.Barcodes)
    {
        Console.WriteLine(Barcode.Value);
        // type and location properties also exposed
    }
}
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
using (var input = new OcrInput())
{
    input.AddImage("test-files/Barcode.png");
    var Result = Ocr.Read(input);
    foreach (var Barcode in Result.Barcodes)
    {
        Console.WriteLine(Barcode.Value);
        // type and location properties also exposed
    }
}
Dim Ocr = New IronTesseract()
Ocr.Configuration.ReadBarCodes = True
Using input = New OcrInput()
	input.AddImage("test-files/Barcode.png")
	Dim Result = Ocr.Read(input)
	For Each Barcode In Result.Barcodes
		Console.WriteLine(Barcode.Value)
		' type and location properties also exposed
	Next Barcode
End Using
VB   C#

The code is self-explanatory and easy to understand.

Licensing

IronOCR is a library that provides a developer's license for free. It also has a distinct pricing structure; the Lite bundle starts at $499 with no hidden fees. The redistribution of SaaS and OEM products is also possible. All licenses come with a 30-day money-back guarantee, a year of software support and upgrades, dev/staging/production validity, and a perpetual license (one-time purchase). To see IronOCR's entire price structure and licensing details, go here.

IronOCR Pricing Plan

IronOCR Pricing Plan

You can get the redistribution of SaaS and OEM products royalty-free service for just a $1599 single-time purchase.

SAAS Service

SAAS Service

AWS Textract API provides developers with AWS Free Tier service. You can get started with Amazon Textract for free. The Free Tier lasts for three months and the pricing is shown below.

Pricing List

Pricing List

Pricing List

You can have a look at the pricing details from this link. Further you can also adjust the prices as per your needs using pricing calculator.

8. Conclusion

IronOCR provides C# developers the most advanced Tesseract API we know of, on any platform. IronOCR can be deployed on Windows, Linux, Mac, Azure, AWS, Lambda and supports .NET Framework projects as well as .NET Standard and .NET Core. We can also read barcodes in OCR scans, and even export our OCR as HTML and searchable PDFs.

Amazon Textract makes it easy to add document text detection and analysis to your applications. Amazon Textract is based on the proven, highly scalable, deep-learning technology that was developed by Amazon's computer vision scientists to analyze billions of images and videos daily. You don't need any machine learning expertise to use it. Amazon Textract includes simple, easy-to-use APIs that can analyze image files and PDF files. Amazon Textract is always learning from new data, and Amazon is continually adding new features to the service.

IronOCR licenses are developer-based, which means you should always purchase a license based on the number of developers who will use the product. AWS Textract licenses are based on the number of pages of the document to extract information and analyze the data. The licenses are on monthly basis and the prices become very high for large number of pages as compared to IronOCR license. Moreover, IronOCR license is one-time purchase and it can be used for lifetime and it supports OME and SaaS distribution.

In overall comparison, IronOCR and AWS OCR both have machine learning capabilities to detect text from a document or image. IronOCR has a slight advantage over AWS OCR as it's fast and time-saving. The code is simple and it's straightforward when detecting text from documents. The task is accomplished in a few methods. On the other hand, AWS Textract uses many methods to achieve the same task. This increases the server response and sometimes it's time-consuming. We can see that if we input even an imperfect document to IronOCR, it can accurately read its content to a statistical accuracy of about 99%, even though the document was badly formatted, skewed, and had digital noise. IronOCR works out of the box with no need to performance tune or heavily modify input images. Speed is Blazing: IronOCR.2020 + is up to 10 times faster and makes over 250% fewer errors than previous builds.

Further, Iron Software is currently offering a five-tool package for the price of just two. The tools included in the Iron Suite are:

  • IronBarcode
  • IronXL
  • IronOCR
  • IronPDF
  • IronWebScraper

Please visit this link to explore the IRONSUITE.