반응형
using System;
using Tesseract;
namespace OCRDemo
{
class Program
{
static void Main(string[] args)
{
// Create an instance of the Tesseract OCR engine
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
{
// Load the image to be processed
using (var img = Pix.LoadFromFile(@"./image.png"))
{
// Set the page segmentation mode to automatic
engine.SetVariable("tessedit_pageseg_mode", "auto");
// Perform OCR on the image
using (var page = engine.Process(img))
{
// Get the recognized text
var text = page.GetText();
// Get the bounding boxes of the recognized characters
var boxes = page.GetWords();
// Print the recognized text and the position of each character
Console.WriteLine($"Recognized text: {text}");
foreach (var box in boxes)
{
Console.WriteLine($"Character: {box.Text}, Position: ({box.Left},{box.Top})");
}
}
}
}
}
}
}
반응형
'[====== Development ======] > C#' 카테고리의 다른 글
C# 구조체 리스트 정렬 (0) | 2023.03.20 |
---|---|
C# Enum 타입을 리스트로 만드는 방법 (0) | 2023.03.16 |
WPF - Canvas를 이용한 도형 이동 및 크기고 (0) | 2023.03.10 |
Server Streaming with gRPC and .NET Core (0) | 2023.02.16 |
C# gRPC file download (0) | 2023.02.16 |