Deep Learning OCR on Document and Receipt Photos using C# in .NET Framework
Today we will be simplifying the normally tedious process of image to text conversion. This will work on most scanned or photographed printed documents, including receipts, checks, and invoices. To accomplish this, we will be harnessing the power of deep learning to perform optical character recognition (OCR) using one of our APIs. For C# users, this is much easier than you might think.
Let’s start by installing our API client via NuGet, by running the following snippet in the console of the Package Manager:
Install-Package Cloudmersive.APIClient.NET.OCR -Version 1.3.1
Then, simply call ImageOcrPhotoToText, and provide it with an image file and optionally a language.
using Cloudmersive.APIClient.NET.OCR.Model;namespace Example
public class ImageOcrPhotoToTextExample
public void main()
// Configure API key authorization: Apikey
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ImageOcrApi();
var imageFile = new System.IO.Stream(); // System.IO.Stream | Image file to perform OCR on. Common file formats such as PNG, JPEG are supported.
var language = language_example; // string | Optional, language of the input document, default is English (ENG). Possible values are ENG (English), ARA (Arabic), ZHO (Chinese - Simplified), ZHO-HANT (Chinese - Traditional), ASM (Assamese), AFR (Afrikaans), AMH (Amharic), AZE (Azerbaijani), AZE-CYRL (Azerbaijani - Cyrillic), BEL (Belarusian), BEN (Bengali), BOD (Tibetan), BOS (Bosnian), BUL (Bulgarian), CAT (Catalan; Valencian), CEB (Cebuano), CES (Czech), CHR (Cherokee), CYM (Welsh), DAN (Danish), DEU (German), DZO (Dzongkha), ELL (Greek), ENM (Archaic/Middle English), EPO (Esperanto), EST (Estonian), EUS (Basque), FAS (Persian), FIN (Finnish), FRA (French), FRK (Frankish), FRM (Middle-French), GLE (Irish), GLG (Galician), GRC (Ancient Greek), HAT (Hatian), HEB (Hebrew), HIN (Hindi), HRV (Croatian), HUN (Hungarian), IKU (Inuktitut), IND (Indonesian), ISL (Icelandic), ITA (Italian), ITA-OLD (Old - Italian), JAV (Javanese), JPN (Japanese), KAN (Kannada), KAT (Georgian), KAT-OLD (Old-Georgian), KAZ (Kazakh), KHM (Central Khmer), KIR (Kirghiz), KOR (Korean), KUR (Kurdish), LAO (Lao), LAT (Latin), LAV (Latvian), LIT (Lithuanian), MAL (Malayalam), MAR (Marathi), MKD (Macedonian), MLT (Maltese), MSA (Malay), MYA (Burmese), NEP (Nepali), NLD (Dutch), NOR (Norwegian), ORI (Oriya), PAN (Panjabi), POL (Polish), POR (Portuguese), PUS (Pushto), RON (Romanian), RUS (Russian), SAN (Sanskrit), SIN (Sinhala), SLK (Slovak), SLV (Slovenian), SPA (Spanish), SPA-OLD (Old Spanish), SQI (Albanian), SRP (Serbian), SRP-LAT (Latin Serbian), SWA (Swahili), SWE (Swedish), SYR (Syriac), TAM (Tamil), TEL (Telugu), TGK (Tajik), TGL (Tagalog), THA (Thai), TIR (Tigrinya), TUR (Turkish), UIG (Uighur), UKR (Ukrainian), URD (Urdu), UZB (Uzbek), UZB-CYR (Cyrillic Uzbek), VIE (Vietnamese), YID (Yiddish) (optional)try
// Convert a photo of a document into text
ImageToTextResponse result = apiInstance.ImageOcrPhotoToText(imageFile, language);
catch (Exception e)
Debug.Print("Exception when calling ImageOcrApi.ImageOcrPhotoToText: " + e.Message );
And that’s pretty much it. This function has a great deal of practical applications, such as digitizing books, online check depositing, and processing expense receipts. Our Document/Conversion API offers further related functionality, including document and image format conversion and manipulation that covers over a hundred different file formats.