Welsh OCR in C# and .NET
Other versions of this document:
IronOCR is a C# software component allowing .NET coders to read text from images and PDF documents in 126 languages, including Welsh. It is an advanced fork of Tesseract, built exclusively for .NET developers and regularly outperforms other Tesseract engines in both speed and accuracy.
Contents of IronOcr.Languages.Welsh
This package contains three versions of the Welsh OCR language for .NET:
- Welsh
- WelshBest
- WelshFast
Download
Welsh Language Pack [Cymraeg]
Installation
The first step is to install the Welsh OCR package in your .NET project.
Install-Package IronOCR.Languages.Welsh
Code Example
This C# code example demonstrates how to read Welsh text from an image or PDF document.
// 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
In this code:
- We start by using the
IronOcr
namespace to access OCR functionalities. - We create an instance of
IronTesseract
, which is the main class provided by IronOCR for performing OCR operations. - The OCR language is set to Welsh using
Ocr.Language = OcrLanguage.Welsh
. - We open an image file named
Welsh.png
located in theimages
directory for OCR processing. - Finally, the
Ocr.Read(Input)
method reads the text from the image, and the extracted text is stored inAllText
. - The recognized Welsh text is then printed to the console.