How to use OCR with C# on Windows 11

In this tutorial, we explore the implementation of Optical Character Recognition (OCR) using IronOCR in Windows 11 with Visual Studio 2022. The process begins with setting up the environment, including the installation of IronOCR via NuGet Package Manager. The tutorial walks you through the coding process, starting from instantiating Iron Tesseract to creating an OCR object.

We then create an instance of OCR input, which is managed efficiently with a using statement to ensure automatic disposal after use. Images are added using the AddImage method, ready for OCR processing. By employing the Read method, we extract text from the images, storing the results in the result object. The extracted text is then displayed on the console, demonstrating the almost perfect accuracy of IronOCR.

The tutorial emphasizes IronOCR's impressive capabilities and versatility, supporting both Windows 11 and Windows 10. Additionally, viewers are encouraged to explore Iron Software's 30-day trial to experience these powerful features firsthand. This guide not only showcases the ease of executing OCR operations but also highlights the robust performance of IronOCR, making it an invaluable tool for developers.

using System; 
using IronOcr;

class Program
{
    static void Main()
    {
        // Instantiate the IronTesseract class, which is the engine for OCR
        var Ocr = new IronTesseract();

        // Using statement ensures that resources are released when done
        using (var Input = new OcrInput())
        {
            // Add an image for processing
            Input.AddImage("path_to_your_image_file");

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

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

class Program
{
    static void Main()
    {
        // Instantiate the IronTesseract class, which is the engine for OCR
        var Ocr = new IronTesseract();

        // Using statement ensures that resources are released when done
        using (var Input = new OcrInput())
        {
            // Add an image for processing
            Input.AddImage("path_to_your_image_file");

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

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

Friend Class Program
	Shared Sub Main()
		' Instantiate the IronTesseract class, which is the engine for OCR
		Dim Ocr = New IronTesseract()

		' Using statement ensures that resources are released when done
		Using Input = New OcrInput()
			' Add an image for processing
			Input.AddImage("path_to_your_image_file")

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

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

Further Reading: How to use OCR with C# on Windows 11

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 Tesseract OCR for .NET on Windows
NEXT >
IronOCR as an alternative to Patagames Tesseract.NET