C# 和 .NET 中的塞尔维亚语 OCR

This article was translated from English: Does it need improvement?
Translated
View the article in English
Other versions of this document:

在塞尔维亚语 新增 125 种 OCR 语言

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

IronOcr.Languages.Serbian 的内容

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

  • 塞尔维亚语
  • 塞尔维亚语Best
  • 塞尔维亚语Fast
  • 塞尔维亚拉丁语
  • 塞尔维亚拉丁语Best
  • 塞尔维亚拉丁语Fast

下载

塞尔维亚语语言包[塞尔维亚语]

安装

我们首先需要做的就是将我们的塞尔维亚语OCR 包安装到您的 .NET 项目中。

Install-Package IronOcr.Languages.Serbian

代码示例

此 C# 代码示例从图像或 PDF 文档中读取塞尔维亚语文本。

// Ensure all necessary namespaces are imported
using IronOcr;

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

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

        // Use a using statement to ensure resources are disposed properly
        using (var Input = new OcrInput(@"images\Serbian.png"))
        {
            // Perform OCR and store the result
            var Result = Ocr.Read(Input);

            // Extract all text from the OCR result
            var AllText = Result.Text;

            // Output the resulting text
            Console.WriteLine(AllText);
        }
    }
}
// Ensure all necessary namespaces are imported
using IronOcr;

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

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

        // Use a using statement to ensure resources are disposed properly
        using (var Input = new OcrInput(@"images\Serbian.png"))
        {
            // Perform OCR and store the result
            var Result = Ocr.Read(Input);

            // Extract all text from the OCR result
            var AllText = Result.Text;

            // Output the resulting text
            Console.WriteLine(AllText);
        }
    }
}
' Ensure all necessary namespaces are imported
Imports IronOcr

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

		' Set the language to Serbian
		Ocr.Language = OcrLanguage.Serbian

		' Use a using statement to ensure resources are disposed properly
		Using Input = New OcrInput("images\Serbian.png")
			' Perform OCR and store the result
			Dim Result = Ocr.Read(Input)

			' Extract all text from the OCR result
			Dim AllText = Result.Text

			' Output the resulting text
			Console.WriteLine(AllText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

代码说明:

  • 我们初始化一个新的IronTesseract实例,用于执行 OCR。
  • OCR引擎的语言设置为塞尔维亚语,使用OcrLanguage.Serbian
  • 我们使用OcrInput加载图像Serbian.png ,OcrInput 会从指定的路径读取文件。
  • 对 OCR 对象调用Read函数来处理图像并提取文本。
  • 从图像中提取的文本存储在变量AllText中,然后打印到控制台。