使用 C# 和 .NET 实现韩文字母 OCR

This article was translated from English: Does it need improvement?
Translated
View the article in English

还有126种语言

IronOCR 是一个 C# 软件组件,允许 .NET 程序员从图像和 PDF 文档中读取 126 种语言的文本,包括韩文字母。

它是 Tesseract 的一个高级分支,专为 .NET 开发人员构建,在速度和准确性方面通常优于其他 Tesseract 引擎。

IronOcr.Languages.Hangul 的内容

此软件包包含 156 种适用于 .NET 的 OCR 语言:

韩文字母 韩文字母Best 韩文字母Fast

  • 韩文垂直字母
  • 韩文垂直字母Best
  • 韩文垂直字母Fast

下载

韩文字母语言包 [韩文字母]

下载为Zip 文件

安装

第一步是将韩文字母OCR 包安装到您的 .NET 项目中。

Install-Package IronOCR.Languages.Hangul

代码示例

此 C# 代码示例从图像或 PDF 文档中读取韩文字母文本。

// Ensure the IronOCR library is installed
// PM> Install-Package IronOcr.Languages.Hangul

using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new instance of IronTesseract for performing OCR
        var Ocr = new IronTesseract();

        // Specify the Hangul language pack for better accuracy with Korean texts
        Ocr.Language = OcrLanguage.Hangul;

        // Load the image or PDF you want to read
        using (var Input = new OcrInput(@"images\Hangul.png"))
        {
            // Perform OCR to read the text from the image
            var Result = Ocr.Read(Input);

            // Extract the recognized text
            var AllText = Result.Text;

            // Output the text to the console
            Console.WriteLine(AllText);
        }
    }
}
// Ensure the IronOCR library is installed
// PM> Install-Package IronOcr.Languages.Hangul

using IronOcr;

class Program
{
    static void Main()
    {
        // Create a new instance of IronTesseract for performing OCR
        var Ocr = new IronTesseract();

        // Specify the Hangul language pack for better accuracy with Korean texts
        Ocr.Language = OcrLanguage.Hangul;

        // Load the image or PDF you want to read
        using (var Input = new OcrInput(@"images\Hangul.png"))
        {
            // Perform OCR to read the text from the image
            var Result = Ocr.Read(Input);

            // Extract the recognized text
            var AllText = Result.Text;

            // Output the text to the console
            Console.WriteLine(AllText);
        }
    }
}
' Ensure the IronOCR library is installed
' PM> Install-Package IronOcr.Languages.Hangul

Imports IronOcr

Friend Class Program
	Shared Sub Main()
		' Create a new instance of IronTesseract for performing OCR
		Dim Ocr = New IronTesseract()

		' Specify the Hangul language pack for better accuracy with Korean texts
		Ocr.Language = OcrLanguage.Hangul

		' Load the image or PDF you want to read
		Using Input = New OcrInput("images\Hangul.png")
			' Perform OCR to read the text from the image
			Dim Result = Ocr.Read(Input)

			' Extract the recognized text
			Dim AllText = Result.Text

			' Output the text to the console
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel
  • PdfWriter:此对象负责写入PDF文件。它作用于文件路径,并写入有效PDF文档所需的结构。

  • IronTesseract :这是用于执行 OCR 操作的主要类。
  • OcrLanguage.Hangul :此设置指定 OCR 引擎应使用韩语语言包,该语言包针对韩语文本识别优化了引擎。
  • OcrInput :这是要处理的图像或 PDF 的容器。
  • Ocr.Read() :此方法执行 OCR 操作并返回包含识别文本的结果对象。