COMPARE TO OTHER COMPONENTS

A Comparison Between Google OCR & IronOCR

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 an 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 a 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 the internet are in digital format, mostly in the form of PDFs or images. There are a bunch of online resources available which convert the image to text. However, most 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)

IronOCR - C# Library

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

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

Another powerful feature of IronOCR is that it can scan barcodes & QR codes from all image files and read their 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 the C# language. It allows C# developers to easily integrate Computer Vision detection features into software applications. It performs OCR and detects text from image files, image labels, face detection, and landmark detection.

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

Features

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

The rest of the article goes as follows:

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

1. Creating a Visual Studio Project

In this tutorial, we are going to use Visual Studio 2022, the latest version. So, I assume you have already downloaded and installed it for C#. If not, you can download it from the 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 the 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 in your specified location.

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

2. Installing IronOCR

There are multiple ways to install the 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 the Tools tab
  • Extend the 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 the given steps:

  1. Click on the link to the NuGet website.
  2. Click the 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 it to your project file or run the Windows Installer. Follow the 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 to the downloaded DLL file location.
  4. Finally, click on OK to add the project reference.

2.4. Using the Command Prompt in Visual Studio

  1. Navigate to the Tools tab in Visual Studio.
  2. Extend the 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 it needs to be added on top of the source code file where we need to access its functions.

using IronOcr;
using IronOcr;
$vbLabelText   $csharpLabel

Now, let's install Google Vision OCR.

3. Installing Google OCR

To be able to use the 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 a 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 the Google Cloud client library for performing OCR processing in Visual Studio, we need to use the NuGet Package Manager.

3.1. Using NuGet Package Manager

Access it using the following method:

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

    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;
$vbLabelText   $csharpLabel

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

Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json");
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "key.json");
$vbLabelText   $csharpLabel

Now, everything is set up and ready to use.

4. Image to Text

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

4.1. Using IronOCR

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

var ocr = new IronTesseract();
using (var input = new OcrInput())
{
    // Add the image to be processed
    input.AddImage("test-files/employmentapp.png");

    // Process the image
    var result = ocr.Read(input);

    // Output the extracted text
    Console.WriteLine(result.Text);
}
var ocr = new IronTesseract();
using (var input = new OcrInput())
{
    // Add the image to be processed
    input.AddImage("test-files/employmentapp.png");

    // Process the image
    var result = ocr.Read(input);

    // Output the extracted text
    Console.WriteLine(result.Text);
}
$vbLabelText   $csharpLabel

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 = Google.Cloud.Vision.V1.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 = Google.Cloud.Vision.V1.Image.FromFile("test-files/employmentapp.png");
var response = client.DetectText(image);

foreach (var annotation in response)
{
    if (annotation.Description != null)
    {
        Console.WriteLine(annotation.Description);
    }
}
$vbLabelText   $csharpLabel

The same image is given as input in order to compare the 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, the formatting of the table is not preserved. IronOCR has preserved the formatting of the table exactly as in the 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 their value with ease. First, set the ReadBarCodes configuration to true, and then iterate through each of the barcodes 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())
{
    // Add the image to be processed
    input.AddImage("test-files/Barcode.png");

    // Process the image
    var result = ocr.Read(input);

    // Iterate and output barcode values
    foreach (var barcode in result.Barcodes)
    {
        Console.WriteLine(barcode.Value);
    }
}
var ocr = new IronTesseract();
ocr.Configuration.ReadBarCodes = true;
using (var input = new OcrInput())
{
    // Add the image to be processed
    input.AddImage("test-files/Barcode.png");

    // Process the image
    var result = ocr.Read(input);

    // Iterate and output barcode values
    foreach (var barcode in result.Barcodes)
    {
        Console.WriteLine(barcode.Value);
    }
}
$vbLabelText   $csharpLabel

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 get text from a scanned document as an image file. Code for label detection is as follows:

var client = ImageAnnotatorClient.Create();
var image = Google.Cloud.Vision.V1.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 = Google.Cloud.Vision.V1.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)}%)");
}
$vbLabelText   $csharpLabel

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())
{
    // Add the PDF to be processed
    input.AddPdf("test-files/example.PDF");

    // Process the PDF
    var result = ocr.Read(input);

    // Output the extracted text
    Console.WriteLine(result.Text);
}
var ocr = new IronTesseract();
using (var input = new OcrInput())
{
    // Add the PDF to be processed
    input.AddPdf("test-files/example.PDF");

    // Process the PDF
    var result = ocr.Read(input);

    // Output the extracted text
    Console.WriteLine(result.Text);
}
$vbLabelText   $csharpLabel

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 the facility to extract text from PDF/TIFF documents. However, it only detects text if the file is in Google Cloud Storage. For this, you need to create a Google Storage bucket. The 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 look at Java code as a reference to 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 a certain amount with a free trial. IronOCR provides 1 year of product support and updates for free and then a year after it costs $399. All licenses are perpetual, meaning only a one-time purchase and no hidden charges. You can also choose royalty-free redistribution coverage for SaaS and OEM products with just a $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 the 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. For example, 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 projects. 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 a monthly basis, and the prices become very high for a large number of images as compared to IronOCR licenses. Moreover, the IronOCR license is a one-time purchase and it can be used for a lifetime, and it supports OEM and SaaS distribution.

In the overall conclusion, both 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 developers to write long lengthy codes. It is built on the 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 on Java, Python, and REST and can only run when connected to Google Cloud. This can be time-consuming as the response comes from the server side. You can choose the library according to your specific needs.

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

  • IronBarcode
  • IronXL
  • IronOCR
  • IronPDF
  • IronWebscraper

Visit this link to explore more.

You can download IronOCR from here.

Frequently Asked Questions

What is OCR?

OCR stands for Optical Character Recognition. It is a technology used to convert different types of documents, such as scanned paper documents, PDF files, or images captured by a digital camera, into editable and searchable data.

What are the main features of IronOCR?

IronOCR offers features like reading text and barcodes from multiple languages, specialist document reading, support for various image and document formats, and image correction filters. It also emphasizes fast and high-quality performance.

How does Google Cloud Vision OCR differ from IronOCR?

Google Cloud Vision OCR uses a powerful pretrained ML model that allows for image text detection, document text detection, and more. It is highly integrated with Google Cloud services. IronOCR, on the other hand, is tailored for C# .NET applications and can function offline, offering features like barcode and QR code reading.

Can IronOCR read barcodes and QR codes?

Yes, IronOCR can read barcodes and QR codes from image files, making it a versatile choice for applications that need to handle various types of data extraction.

Is there a free trial available for IronOCR?

Yes, IronOCR offers a free trial that allows developers to test its full capabilities before committing to a purchase.

How does the pricing structure of IronOCR compare to Google Cloud Vision?

IronOCR has a one-time purchase model with perpetual licenses, while Google Cloud Vision charges based on the number of operations performed, which can become costly with high usage.

What programming languages are supported by Google Cloud Vision API?

Google Cloud Vision API supports multiple programming languages, including C#, Java, Python, and others, and requires an internet connection to function as it is cloud-based.

What is required to use Google Cloud Vision OCR in a C# project?

To use Google Cloud Vision OCR in a C# project, you need to create a Google Account, enable billing and the Vision API in Google Cloud Console, create a Service Account, and download the key credentials in JSON format.

Does IronOCR support multiple languages?

Yes, IronOCR supports over 125 languages, including custom language support, making it highly adaptable for international applications.

What platforms can IronOCR be deployed on?

IronOCR can be deployed on various platforms including Windows, Linux, Mac, Azure, AWS, and Lambda, and supports .NET Framework projects as well as .NET Standard and .NET Core projects.

Kannaopat Udonpant
Software Engineer
Before becoming a Software Engineer, Kannapat completed a Environmental Resources PhD from Hokkaido University in Japan. While pursuing his degree, Kannapat also became a member of the Vehicle Robotics Laboratory, which is part of the Department of Bioproduction Engineering. In 2022, he leveraged his C# skills to join Iron Software's engineering team, where he focuses on IronPDF. Kannapat values his job because he learns directly from the developer who writes most of the code used in IronPDF. In addition to peer learning, Kannapat enjoys the social aspect of working at Iron Software. When he's not writing code or documentation, Kannapat can usually be found gaming on his PS5 or rewatching The Last of Us.
< PREVIOUS
AWS vs Google Vision (OCR Features Comparison)
NEXT >
A Comparison Between OCR Software By Iris & IronOCR