Convert Image to Text using C# OCR Library

Perform OCR using C#

The OCR (Optical Character Recognition) is a well known and widely used technology to recognize and read text from images and scanned documents. In the OCR operation, the characters on the images are scanned, recognized, and converted into the digital form. The converted text can be validated and saved to perform further operations. In this article, I’ll show you how to perform OCR to convert images to text programmatically using C# within your .NET applications. The rest of the article is divided into the following sections.

C# OCR Library – Installation

Aspose.OCR for .NET is a powerful OCR library that lets you scan and convert images to text quite easily. It doesn’t require lengthy codes to get the OCR features up and running within your .NET applications. The following are the installation methods of the C# OCR Library.

Install via NuGet Package Manager

Simply search for Aspose.OCR in NuGet Package Manager and install it.

C# OCR Library

Install via Package Manager Console

The following is the command to install Aspose.OCR via Package Manager Console.

PM> Install-Package Aspose.OCR

Convert Image to Text using C# OCR API

Let’s see how to perform OCR on an image that could possibly be a page of a scanned document. The following are the steps to perform this operation.

The following code sample shows how to convert an image to text using C#.

Perform OCR on Image with a Single Line of Text

In the previous example, we have performed OCR on the image which contained multiple lines of text. However, it is possible that the image contains only a single line of text. In such cases, you can tell the API to recognize the line only. The following are the steps to perform convert an image containing a single line text.

The following code sample shows how to perform OCR and convert an image containing a single line of text using C#.

Perform OCR for Non-English Characters

Aspose.OCR doesn’t limit the OCR features for the English language and you can recognize the characters of other languages as well. The recognition process and the code will remain the same regardless of the text’s language. The following is the set of characters that can be recognized by the Aspose’s OCR API.

space!#$%&()
*+,./012
456789:;<=
>?@[\]_`{
}~ABCDEFG
IJKLMNOPQR
STUVWXYZa
cdefghijk
mnopqrstu
wxyzÂÀÁÃÄÆ 
ÇÈÉÊËÌÍÎÏÑ 
ÒÓÔÕÖÙÚÛÜẞ 
ßàáâãäæçèé 
êëìíîïñòóô 
õöùúûüÿŒœŸ 

Conclusion

This article demonstrated how to perform OCR and convert images to text programmatically using C#. You can recognize the characters in the images containing single or multiple lines of text. Learn more about the C# OCR API from the documentation.

See Also