COMPARE TO OTHER COMPONENTS

A Comparison Between Google OCR & IronOCR

Published May 16, 2023
Share:

OCR stands for Optical Character Recognition. It provides the facility to convert an image file to machine encoded text. The scanned documents are always saved as image file by the computer. The data in these image files cannot be searched, edited, or saved in text format using a normal text editor or even using word processing application. OCR processing helps convert these images to machine readable text for further processing by its users.

In this modern age, the scanned documents shared over int.NET are in digital format and mostly in the form of PDFs or images. There are a bunch of online resources available which converts the image to text. However, mostly businesses require this functionality in their software applications. Keeping this in mind, there are many libraries which provide OCR processing technology to be embedded in software applications.

In this article, we are going to discuss two of the most popular OCR libraries for C#. These are:

  • IronOCR
  • Google Cloud Vision OCR (Vision API)

Introduction

IronOCR - C# Library

IronOCR for .NET is C# library to scan, search and read images & PDFs. It takes an image or PDF file as an input, and uses the latest Tesseract 5 custom build .NET OCR engine to output text, structured data or searchable PDF documents. Its Tesseract is available in 125+ languages along with cross-platform support in .NET Core, Standard, from 2.0 up to 7.

IronOCR is a user-friendly API which allows C# developers to convert images to text automatically, simply by using IronTesseract class and API key. It prioritizes speed, accuracy and ease of use. It also aids Computer Vision API to find text with trained set of models.

Another powerful feature of IronOCR is that it can scan barcodes & QR codes from all image files and read its text. Other important features of IronOCR are given below.

Features

  • International Languages: 125+ and custom languages support with High and Fast Quality performance
  • Text and Barcode Reading: Read Text & Numbers from Multiple Languages at Once
  • Specialist Documents: Specifically read text from Receipts, Cheques, Invoices
  • Read from Many Formats: Images (PNG, JPG, GIF, TIFF, BMP), System.Drawing Objects, Streams, PDF documents (optimized target DPI)
  • Filters: Filter Wizard, Image Correction, Fix Image Orientation, Fix Image Colors
  • Simple Data Output: .NET Text Strings, Barcode and QR Data, Images

Now, let's have a look at Google Cloud Vision API.

Google Cloud Vision OCR

Google Cloud Vision API is a Google Cloud OCR client library which supports C# language. It allows C# developers to easily integrate Computer Vision detection features in software applications. It performs OCR and detects text from image file, image labels, face detection, landmark detection.

Google Cloud Vision API uses REST and RPC APIs to provide a powerful pretrained ML (machine learning) model. With Cloud import vision API, you can quickly classify images to millions of already pre-defined categories. It can also detect objects, read text from printed documents and handwritten text.

Features

  • Image Text Detection: OCR an image for text recognition, convert to machine language code
  • Document Text Detection: OCR a file (PDF/TIFF), dense text
  • Landmark Detection: Returns co-ordinates of detected object
  • Logo Detection: Returns a textual description
  • Label Detection: Returns generalized labels for image

The rest of the article goes as follows:

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

1. Creating Visual Studio Project

In this tutorial, we are going to use Visual Studio 2022 latest version. So, I assume you have already downloaded and installed it for C#. If not, you can download from Visual Studio website.

Now, we need to create a Console project to get started with both libraries. Follow the steps to create a project:

  • Open your Visual Studio 2022.
  • Click on Create a new Project.

    How to Print Barcode in C# Windows Application Figure 1 - Create a new project

  • Select C# Console Application from given options.

    How to Print Barcode in C# Windows Application Figure 2 - Console App

  • Configure your new project with a name and the location. E.g "OCRProject".
  • Click Next.

    How to Print Barcode in C# Windows Application Figure 3 - Configure project

  • From additional information, select .NET 6.0 Framework as it is the most stable version.

    How to Print Barcode in C# Windows Application Figure 4 - Additional information

  • Now, click Create and the project will be created on your specified location.

Next, we will now install the libraries in our project for comparison.

2. Installing IronOCR

There are multiple ways to install IronOCR library. Let's have a look at them one by one.

2.1. Using Visual Studio NuGet Package Manager

NuGet is the package manager for downloading and installing dependencies in your project. Its packages contain the compiled code (DLL) and the manifest file. Access it using the following method:

  • Click on Tools tab
  • Extend NuGet Package Manager option
  • Click Manage NuGet Packages for Solution

    How to Print Barcode in C# Windows Application Figure 5 - NuGet Package Manager

  • or, right click Solution Explorer
  • Click Manage NuGet Packages

    How to Print Barcode in C# Windows Application Figure 6 - Solution Explorer

Now, the NuGet Package Manager window will open. Browse for IronOCR and click Install.

How to Print Barcode in C# Windows Application Figure 7 - IronOCR

2.2. Download from NuGet Website

It can be downloaded directly from the NuGet official website. Follow given steps:

  1. Click on the link: "".
  2. Click Download package option on the right-hand side of the page.
  3. Open the downloaded package and it will start installing.
  4. Finally, reload the solution and it's done.

2.3. Download using the IronOCR Webpage

Simply visit the Iron Software website and navigate to the IronOCR for .NET webpage. Scroll to the bottom and click Download DLL or Download Windows Installer.

How to Print Barcode in C# Windows Application Figure 8 - Iron Software Website

A Zip file will be downloaded. Extract it and add in your project file or run the Windows Installer. Follow below steps to add it to your project.

  1. Right-click the dependencies of the project in Visual Studio from the Solution Explorer.
  2. Then, select the option Add Project Reference.
  3. Browse the downloaded DLL file location.
  4. Finally, click on OK to add project reference.

2.4. Using Command prompt in Visual Studio

  1. Navigate to Tools tab in Visual Studio.
  2. Extend NuGet Package Manager option.
  3. Select Package Manager Console and type the following command:

    Install-Package IronOCR

This will automatically download and install IronOCR in your project.

Now, we are ready to use IronOCR in our project.

2.5. Adding Necessary IronOCR Namespaces

There is only one namespace required and needs to be added on top of the source code file where we need to access its functions.


    using IronOCR;

    using IronOCR;
Imports IronOCR
VB   C#

Now, let's install Google Vision OCR.

3. Installing Google OCR

To be able to use vision API in your C# project, you must have the following prerequisites fulfilled

  1. Create a Google Account
  2. Create a new project from Google Cloud Console
  3. Enable Billing
  4. Enable Vision API
  5. Create Service Account and set the credentials
  6. Download the service account key credentials in JSON file format

You can have a detailed look at the setup and requirements of using Google Cloud Vision from the official documentation here.

Now, to install Google Cloud client library for performing OCR processing in Visual Studio, we need to use NuGet Package Manager.

3.1. Using NuGet Package Manager

Access it using the following method:

  • Click on Tools tab
  • Extend NuGet Package Manager option
  • Click Manage NuGet Packages for Solutions

    How to Print Barcode in C# Windows Application Figure 9 - Tools tab

  • or, right click Solution Explorer
  • Click Manage NuGet Packages

    How to Print Barcode in C# Windows Application Figure 10 - Manage NuGet Packages

Now, the NuGet Package Manager window will open. Browse for Google Cloud Vision OCR and click Install.

How to Print Barcode in C# Windows Application Figure 11 - Google Cloud Vision OCR

3.2. Adding Google Vision API Namespace

Include the following namespace to use Google OCR Vision API:


    using Google.Cloud.Vision.V1;

    using Google.Cloud.Vision.V1;
Imports Google.Cloud.Vision.V1
VB   C#

Also set the environment variable with the key credentials downloaded in JSON file.


    Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json");

    Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json");
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json")
VB   C#

Now, everything is set up and ready to use.

4. Images to Text

Reading data from images is quite a tedious task. Images resolution and quality play an important role while extracting content. Both the libraries provide Optical Character Recognition (OCR) functionality to extract text from images.

4.1. Using IronOCR

IronOCR makes it very easy for the developers to read the contents of an image file with its powerful IronTesseract class. Here we will use PNG image to read text from image file and the code is as follows:


    var OCR = new IronTesseract();
    using (var Input = new OcrInput()){
        Input.AddImage("test-files/employmentapp.png");
        var Result = OCR.Read(Input);
        Console.WriteLine(Result.Text);
    }

    var OCR = new IronTesseract();
    using (var Input = new OcrInput()){
        Input.AddImage("test-files/employmentapp.png");
        var Result = OCR.Read(Input);
        Console.WriteLine(Result.Text);
    }
Dim OCR = New IronTesseract()
	Using Input = New OcrInput()
		Input.AddImage("test-files/employmentapp.png")
		Dim Result = OCR.Read(Input)
		Console.WriteLine(Result.Text)
	End Using
VB   C#

INPUT IMAGE

How to Print Barcode in C# Windows Application Figure 12 - Input with bounding boxes

OUTPUT

How to Print Barcode in C# Windows Application Figure 13 - Image Output with individual words

The output of IronOCR matches the original image given to it. The code is clean and easy to understand without any technicalities.

4.2. Using Google OCR

Google Cloud Vision OCR also converts the image to text with different fonts. First, we need to create a client using the credentials file. Then using this client object we can call the DetectText method to get a response in form of annotation. The code is given as follows:


    Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json");
    var client = ImageAnnotatorClient.Create();
    var image = Image.FromFile("test-files/employmentapp.png");
    var response = client.DetectText(image);
    foreach (var annotation in response)
    {
        if (annotation.Description != null)
        {
            Console.WriteLine(annotation.Description);
        }
    }

    Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json");
    var client = ImageAnnotatorClient.Create();
    var image = Image.FromFile("test-files/employmentapp.png");
    var response = client.DetectText(image);
    foreach (var annotation in response)
    {
        if (annotation.Description != null)
        {
            Console.WriteLine(annotation.Description);
        }
    }
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json")
	Dim client = ImageAnnotatorClient.Create()
	Dim image As System.Drawing.Image = System.Drawing.Image.FromFile("test-files/employmentapp.png")
	Dim response = client.DetectText(image)
	For Each annotation In response
		If annotation.Description IsNot Nothing Then
			Console.WriteLine(annotation.Description)
		End If
	Next annotation
VB   C#

The same image is given as input in order to compare output of both libraries.

How to Print Barcode in C# Windows Application Figure 14 - Output

From the above output, you can clearly see that, IronOCR preserves the image output formats. Although Google OCR has given accurate output text, but the formatting of the table is not preserved. IronOCR has preserved the formatting of the table exactly as in given image.

5. Barcode and QR Code to Text

5.1. Using IronOCR

IronOCR provides a unique and useful feature while reading images i.e. it can read barcodes and QR Codes. It can detect barcodes and display its value with ease. First, set the ReadBarCodes configuration to true and then iterate through each of the barcode in the OCR results. The code for reading barcodes 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);
        }
    }

    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);
        }
    }
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)
		Next Barcode
	End Using
VB   C#

INPUT IMAGE

How to Print Barcode in C# Windows Application Figure 15 - Input

OUTPUT

How to Print Barcode in C# Windows Application Figure 16 - Image Output

All the three barcodes in the input are read successfully, and their hidden text is displayed.

5.2. Using Google OCR

Google Vision API does not allow this functionality yet. Reading barcodes can be handy in software applications. However, Google OCR allows you to extract handwritten text and to get text from scanned document as an image file. Code for label detection is as follows:


    var client = ImageAnnotatorClient.Create();
    var image = Image.FromUri("gs://cloud-samples-data/vision/using_curl/shanghai.jpeg");
    var labels = client.DetectLabels(image);

    Console.WriteLine("Labels (and confidence score):");
    Console.WriteLine(new String('=', 30));

    foreach (var label in labels)
    {
        Console.WriteLine($"{label.Description} ({(int)(label.Score * 100)}%)");
    }

    var client = ImageAnnotatorClient.Create();
    var image = Image.FromUri("gs://cloud-samples-data/vision/using_curl/shanghai.jpeg");
    var labels = client.DetectLabels(image);

    Console.WriteLine("Labels (and confidence score):");
    Console.WriteLine(new String('=', 30));

    foreach (var label in labels)
    {
        Console.WriteLine($"{label.Description} ({(int)(label.Score * 100)}%)");
    }
Imports System

Dim client = ImageAnnotatorClient.Create()
	Dim image = System.Drawing.Image.FromUri("gs://cloud-samples-data/vision/using_curl/shanghai.jpeg")
	Dim labels = client.DetectLabels(image)

	Console.WriteLine("Labels (and confidence score):")
	Console.WriteLine(New String("="c, 30))

	For Each label In labels
		Console.WriteLine($"{label.Description} ({CInt(Math.Truncate(label.Score * 100))}%)")
	Next label
VB   C#

OUTPUT

How to Print Barcode in C# Windows Application Figure 17 - Label Detection Output

6. PDF to Text

6.1. Using IronOCR

Reading PDF files is as easy as reading image files in IronOCR. You only need to change the AddImage method to AddPdf in the image reading code. The code goes as follows:


    var OCR = new IronTesseract();
    using (var Input = new OcrInput()){
        Input.AddPdf("test-files/example.PDF");
        var Result = OCR.Read(Input);
        Console.WriteLine(Result.Text);
    }

    var OCR = new IronTesseract();
    using (var Input = new OcrInput()){
        Input.AddPdf("test-files/example.PDF");
        var Result = OCR.Read(Input);
        Console.WriteLine(Result.Text);
    }
Dim OCR = New IronTesseract()
	Using Input = New OcrInput()
		Input.AddPdf("test-files/example.PDF")
		Dim Result = OCR.Read(Input)
		Console.WriteLine(Result.Text)
	End Using
VB   C#

OUTPUT

The extracted text is in the same formatting as the PDF file.

How to Print Barcode in C# Windows Application Figure 18 - PDF to Text Output

6.2. Using Google OCR

Google OCR also provides facility to extract text from a PDF/TIFF documents. However, it only detects text if the file is at Google Cloud Storage. For this you need to create a Google Storage bucket. Code for C# is not straightforward and quite lengthy to implement here. There are no samples available for C# to detect texts in files. You can have a look at Java code as a reference to give it a try.

7. Licensing

IronOCR is free for development purposes, but it needs to be licensed for commercial use. It also provides a free trial to test all its potential for your needs. The Lite package starts from $749 with a free trial. IronOCR provides 1 year of product support and updates for free and then $399 year after. All licenses are perpetual, meaning only one time purchase and no hidden charges. You can also choose royalty free redistribution coverage for SaaS and OEM products in just $1999 single time purchase. For more info on license packages and pricing plans please visit here.

How to Print Barcode in C# Windows Application Figure 19 - IronOCR License

Google Cloud Vision pricing plans are based on number of operations performed by the application on an image. For files like PDF which have multiple pages, each page is treated as an image. Moreover, each feature applied to an image is a separate billable unit. E.g. if you apply text detection and label detection to the same image, each feature will be charged separately. The pricing plans are given below and for more info, please visit this link.

How to Print Barcode in C# Windows Application Figure 20 - Google Cloud Vision OCR License

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.

Google Cloud Vision API is an advanced AI built API. It provides a variety of image analyzing features which can be very helpful in building ML applications. It allows developers to directly communicate with the Google Cloud using an API key, which means there is no need to store files locally.

IronOCR licenses are user-based, which means you should always purchase a license based on the number of developers who will use the product. Google Cloud Vision licenses are based on the number of pictures to extract information from and analyze the data. The licenses are on monthly basis and the prices become very high for large number of images as compared to IronOCR license. Moreover, IronOCR license is one-time purchase, and it can be used for lifetime, and it supports OEM and SaaS distribution.

In overall conclusion, both the libraries possess machine learning capabilities. IronOCR has a slight advantage over Google OCR as it is specifically built for C# .NET framework which is fast and time saving. It provides all features with very few lines of code, lifting the burden from developer to write long lengthy codes. It is built on most popular Tesseract 5 API which makes it easy to integrate and analyze images, and other file formats with accurate output. On the other hand, Google Vision OCR is built on AI and more focused for Java, Python and REST and can only run when connected to Google Cloud. This can be time-consuming as the response comes from server side. You can choose the library according to your specific needs.

Now, you can get 5 Iron products for the price of 2. Following tools are included in Iron Suite:

  • IronBarcode
  • IronXL
  • IronOCR
  • IronPDF
  • IronWebscraper

Visit this link to explore more.

You can download IronOCR from here.

< PREVIOUS
AWS vs Google Vision (OCR Features Comparison)
NEXT >
A Comparison Between OCR Software By Iris & IronOCR

Ready to get started? Version: 2024.11 just released

Free NuGet Download Total downloads: 2,698,613 View Licenses >