Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
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.
The OCR engine works by using the following steps:
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.
The OCR software first cleans the image and removes errors to prepare its data for reading.
The two main types of OCR algorithms for text recognition are pattern matching and feature extraction.
A character picture, or glyph, is isolated throughout the pattern matching process and compared to a previously recorded glyph.
Through the process of feature extraction, the glyphs are divided into features like lines, closed loops, line direction, and line junctions.
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 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.
Now, let's have a look at AWS OCR.
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.
The rest of the article goes as follows:
This tutorial will use the Visual Studio 2022 version so I assume you must have installed it.
The latest and most stable version of the .NET framework is 6.0. We are going to use this.
Next, we will install the libraries for our use one by one.
The IronOCR library can be downloaded and installed in four ways. These are as follows:
The Visual Studio NuGet Package Manager can be used to incorporate IronOCR into a C# project.
After this, a new window will appear in the search bar: type IronOCR. Check the project box on right side and click Install.
By using this method, developers can install the IronOCR library and any language pack of the developer's choice.
IronOCR can be directly downloaded from the NuGet website by following these instructions:
Developers can download the IronOCR library directly from the website by using this Link.
Install-Package IronOcr
The package will now download/install in the current project and is ready to use.
After typing the command, press enter and it will be installed.
Include this line of code in the program to use IronOCR:
using IronOcr;
using IronOcr;
Imports IronOcr
Now let's install AWS Textract.
Before you use Amazon Textract for the first time, complete the following tasks:
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:
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
Both the libraries can extract text from PDF files. Let's have a look at the code one by one.
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
The code is simple, clean, and very easy to understand and use.
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
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.
The output is pretty similar to IronOCR.
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.
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
The output is clean and matches the original image just with a few lines of code without any technicality and perfect output.
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
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.
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
The code is self-explanatory and easy to understand.
IronOCR is a library that provides a developer's license for free. It also has a distinct pricing structure; the Lite bundle starts at $749 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.
You can get the redistribution of SaaS and OEM products royalty-free service for just a $1599 single-time purchase.
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.
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.
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:
Please visit this link to explore the IRONSUITE.
9 .NET API products for your office documents