Welsh OCR in C# and .NET
This article was translated from English: Does it need improvement?
Translated
View the article in English
此文件的其他版本:
IronOCR是一個C#軟體元件,允許.NET開發者從圖像和PDF文件中讀取126種語言的文字,包括威爾士文。 它是Tesseract的一個先進分支,專為.NET開發人員設計,在速度和準確性方面經常優於其他Tesseract引擎。
IronOcr.Languages.Welsh的內容
此套件包含三種適用於.NET的威爾士文OCR語言版本:
- Welsh
- WelshBest
- WelshFast
下載
威爾士語言包 [Cymraeg]
安裝
第一步是將威爾士 OCR套件安裝到您的.NET專案中。
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);
}
}
}
' Import the IronOcr namespace
Imports IronOcr
Friend Class Program
Shared Sub Main()
' Create an instance of IronTesseract
Dim Ocr = New IronTesseract()
' Set the language to Welsh
Ocr.Language = OcrLanguage.Welsh
' Read text from the given image
Using Input = New OcrInput("images\Welsh.png")
' Perform OCR and get the result
Dim Result = Ocr.Read(Input)
' Extract all recognized text
Dim AllText = Result.Text
' Output text to the console
Console.WriteLine(AllText)
End Using
End Sub
End Class
$vbLabelText
$csharpLabel
在這段程式碼中:
- 我們首先使用
IronOcr命名空間來存取OCR功能。 - 我們建立一個
IronTesseract實例,這是IronOCR提供的執行OCR操作的主要類。 - OCR語言設置為威爾士文,使用
Ocr.Language = OcrLanguage.Welsh。 - 我們打開位於
Welsh.png圖像文件以進行OCR處理。 - 最後,
AllText中。 - 然後將識別出的威爾士文字列印到控制台。

