Welsh OCR in C# and .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English
本文档的其他版本:

在威尔士语中 新增 125 种 OCR 语言

IronOCR 是一个 C# 软件组件,允许 .NET 程序员从图像和 PDF 文档中读取 126 种语言(包括威尔士语)的文本。 它是 Tesseract 的一个高级分支,专为 .NET 开发人员构建,在速度和准确性方面通常优于其他 Tesseract 引擎。

IronOcr.Languages.Welsh 的内容

此软件包包含三个版本的威尔士语 OCR 语言,适用于 .NET:

威尔士语

  • 威尔士最佳
  • 威尔士快车

下载

威尔士语包[威尔士语]

安装

第一步是在您的 .NET 项目中安装威尔士语OCR 包。

Install-Package IronOcr.Languages.Welsh

代码示例

此 C# 代码示例演示了如何从图像或 PDF 文档中读取威尔士语文本。

// Import the IronOcr namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Create an instance of IronTesseract
        var Ocr = new IronTesseract();

        // Set the language to Welsh
        Ocr.Language = OcrLanguage.Welsh;

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

            // Output text to the console
            Console.WriteLine(AllText);
        }
    }
}
// Import the IronOcr namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Create an instance of IronTesseract
        var Ocr = new IronTesseract();

        // Set the language to Welsh
        Ocr.Language = OcrLanguage.Welsh;

        // Read text from the given image
        using (var Input = new OcrInput(@"images\Welsh.png"))
        {
            // Perform OCR and get the result
            var Result = Ocr.Read(Input);

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

            // Output text to the console
            Console.WriteLine(AllText);
        }
    }
}
$vbLabelText   $csharpLabel

在此代码中:

  • 我们首先使用 IronOcr 命名空间来访问 OCR 功能。
  • 我们创建了 IronTesseract 的一个实例,它是IronOCR提供的用于执行 OCR 操作的主要类。
  • OCR 语言设置为威尔士语,使用 Ocr.Language = OcrLanguage.Welsh
  • 我们打开位于 images 目录中的名为 Welsh.png 的图像文件进行 OCR 处理。 最后,Ocr.Read(Input) 方法从图像中读取文本,并将提取的文本存储在 AllText 中。
  • 然后,将识别出的威尔士语文本打印到控制台上。