IronOCR as an alternative to Patagames Tesseract.NET

In this tutorial, we explore the use of Iron OCR as an alternative to Tesseract for optical character recognition (OCR) in C#. Two .NET C# console projects were created: one utilizing Tesseract and the other Iron OCR. The process begins with installing the Tesseract library via NuGet Package Manager and setting up the project to extract text from an image using the Tesseract .NET SDK. However, when tested with a blurred image, Tesseract failed to deliver accurate results. In contrast, the Iron OCR library, also installed through NuGet, demonstrated superior performance. The tutorial demonstrates how Iron OCR's denoise and deskew functions enhance image clarity, resulting in accurate text extraction. The video concludes by recommending Iron OCR for its ability to provide more precise text extraction, making it a preferred choice over Tesseract for OCR tasks in C# projects. The support team is available for further assistance.

C# Implementation with Iron OCR

Below is an example of how you might implement Iron OCR in a C# console application:

// Import necessary namespaces
using System;
using IronOcr;

class IronOCRTutorial
{
    static void Main(string[] args)
    {
        // Create a new instance of the IronTesseract class
        var Ocr = new IronTesseract();

        // This feature allows image pre-processing before OCR execution
        // Denoise: Cleans the image and reduces noise
        // Deskew: Corrects the tilt of the image
        Ocr.Configuration.ReadBarCodes = false; // Disable barcode reading (optional)
        Ocr.Configuration.EngineMode = IronTesseract.EngineMode.TesseractLstmCombined; // Set OCR engine mode
        Ocr.Configuration.Deskew = true; // Automatically aligns images that are tilted
        Ocr.Configuration.Denoise = true; // Reduces noise in the image

        // Load the image from which text needs to be extracted
        using (var Input = new OcrInput(@"path_to_image.jpg"))
        {
            // Perform OCR to read text from the image
            var Result = Ocr.Read(Input);

            // Output the recognized text to the console
            Console.WriteLine(Result.Text); // Display the extracted text
        }
    }
}
// Import necessary namespaces
using System;
using IronOcr;

class IronOCRTutorial
{
    static void Main(string[] args)
    {
        // Create a new instance of the IronTesseract class
        var Ocr = new IronTesseract();

        // This feature allows image pre-processing before OCR execution
        // Denoise: Cleans the image and reduces noise
        // Deskew: Corrects the tilt of the image
        Ocr.Configuration.ReadBarCodes = false; // Disable barcode reading (optional)
        Ocr.Configuration.EngineMode = IronTesseract.EngineMode.TesseractLstmCombined; // Set OCR engine mode
        Ocr.Configuration.Deskew = true; // Automatically aligns images that are tilted
        Ocr.Configuration.Denoise = true; // Reduces noise in the image

        // Load the image from which text needs to be extracted
        using (var Input = new OcrInput(@"path_to_image.jpg"))
        {
            // Perform OCR to read text from the image
            var Result = Ocr.Read(Input);

            // Output the recognized text to the console
            Console.WriteLine(Result.Text); // Display the extracted text
        }
    }
}
' Import necessary namespaces
Imports System
Imports IronOcr

Friend Class IronOCRTutorial
	Shared Sub Main(ByVal args() As String)
		' Create a new instance of the IronTesseract class
		Dim Ocr = New IronTesseract()

		' This feature allows image pre-processing before OCR execution
		' Denoise: Cleans the image and reduces noise
		' Deskew: Corrects the tilt of the image
		Ocr.Configuration.ReadBarCodes = False ' Disable barcode reading (optional)
		Ocr.Configuration.EngineMode = IronTesseract.EngineMode.TesseractLstmCombined ' Set OCR engine mode
		Ocr.Configuration.Deskew = True ' Automatically aligns images that are tilted
		Ocr.Configuration.Denoise = True ' Reduces noise in the image

		' Load the image from which text needs to be extracted
		Using Input = New OcrInput("path_to_image.jpg")
			' Perform OCR to read text from the image
			Dim Result = Ocr.Read(Input)

			' Output the recognized text to the console
			Console.WriteLine(Result.Text) ' Display the extracted text
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Further Reading: IronOCR as an alternative to Patagames Tesseract.NET

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
How to use OCR with C# on Windows 11