Articles → CSHARP → OCR API In C#

OCR API In C#






Tesseract.NET.SDK Nugget Package




Picture showing installing the Tesseract.NET.SDK using Nugget



Sample Image




Picture showing the sample image from which data will be read using OCR



Code To Read Text From Image


using Patagames.Ocr;
using Patagames.Ocr.Enums;
using System;

namespace OCRInCSharp
{
    class Program
    {
        static void Main(string[] args)
        {            
            ConvertImageToText();
            Console.ReadLine();   
        }

        public static void ConvertImageToText()
        {
            using (var api = OcrApi.Create())
            {
                api.Init(Languages.English);
                string plainText = api.GetTextFromImage("C:\\temp\\1.png");
    
                Console.WriteLine(plainText);                
            }
        }

    }
}



Output


Picture showing reading the text from image using OCR



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, February 8, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250