How to use Tesseract OCR for .NET on Windows

In this tutorial, we explore how to use Tesseract OCR with Iron OCR on Windows 10 and 11. The process begins with creating a console application in Visual Studio 2022. To perform OCR in your project, you must install the Iron OCR library, which can be added via the NuGet Package Manager, NuGet Console, or the NuGet website. It is crucial to ensure the library is up-to-date.

Once set up, we move to the Program.cs file, where the Iron OCR library is imported. An object of Iron Tesseract is created, and the OCR input involves providing a path to the selected image. This image is chosen for its blurriness and small size to test Iron OCR's capabilities. The tutorial demonstrates utilizing the enhanced resolution function to improve image quality and the denoise function to remove image blur. If the image is rotated, the deskew function can restore its original position.

After preparing the image, the read function reads the input image and outputs the extracted text to the console. Running the project shows Iron OCR's ability to extract exact text even from blurry images with near-perfect accuracy.

The tutorial concludes by recommending Iron OCR for high-accuracy OCR tasks, emphasizing its effectiveness in handling challenging images. Support is available for any assistance required. This guide ensures users can confidently implement and benefit from OCR technology in their projects.

Below is an example implementation in C# using Iron OCR:

using IronOcr;

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

        // Specify the path to the image you want to process
        string imagePath = @"C:\path\to\your\image.jpg";

        // Using the Ocr object to perform operations on the image
        using (var Input = new OcrInput(imagePath))
        {
            // Enhance the resolution to improve OCR accuracy
            Input.EnhanceResolution();

            // Denoise the image to remove any blur or noise
            Input.Denoise();

            // Deskew the image in case it's rotated
            Input.Deskew();

            // Perform OCR on the input image
            var Result = Ocr.Read(Input);

            // Output the extracted text to the console
            Console.WriteLine(Result.Text);
        }
    }
}
using IronOcr;

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

        // Specify the path to the image you want to process
        string imagePath = @"C:\path\to\your\image.jpg";

        // Using the Ocr object to perform operations on the image
        using (var Input = new OcrInput(imagePath))
        {
            // Enhance the resolution to improve OCR accuracy
            Input.EnhanceResolution();

            // Denoise the image to remove any blur or noise
            Input.Denoise();

            // Deskew the image in case it's rotated
            Input.Deskew();

            // Perform OCR on the input image
            var Result = Ocr.Read(Input);

            // Output the extracted text to the console
            Console.WriteLine(Result.Text);
        }
    }
}
Imports IronOcr

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

		' Specify the path to the image you want to process
		Dim imagePath As String = "C:\path\to\your\image.jpg"

		' Using the Ocr object to perform operations on the image
		Using Input = New OcrInput(imagePath)
			' Enhance the resolution to improve OCR accuracy
			Input.EnhanceResolution()

			' Denoise the image to remove any blur or noise
			Input.Denoise()

			' Deskew the image in case it's rotated
			Input.Deskew()

			' Perform OCR on the input image
			Dim Result = Ocr.Read(Input)

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

Further Reading: How to use Tesseract OCR for .NET on Windows

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 Read Barcodes and QR Codes Using OCR in C#
NEXT >
How to use OCR with C# on Windows 11