Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
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
Further Reading: IronOCR as an alternative to Patagames Tesseract.NET