Sanskrit OCR in C# and .NET

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

126 種其他語言

IronOCR 是一個 C# 軟體元件,讓 .NET 程式設計師能夠從 126 種語言(包括梵文)的圖片和 PDF 文件中讀取文字。

這是 Tesseract 的進階分支版本,專為 .NET 開發人員打造,無論在速度或準確度方面,其表現均經常優於其他 Tesseract 引擎。

IronOcr.Languages.Sanskrit 的內容

此套件包含 49 種適用於 .NET 的 OCR 語言:

  • 梵文
  • 梵文Best
  • 梵文Fast

下載

梵文語言套件 [ससकतम]

安裝

第一步是將 Sanskrit OCR 套件安裝至您的 .NET 專案中。

Install-Package IronOcr.Languages.Sanskrit

程式碼範例

此 C# 程式碼範例可從圖片或 PDF 文件中讀取梵文文本。

// Import the IronOcr namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Create an instance of IronTesseract for OCR operations
        var Ocr = new IronTesseract
        {
            // Set the OCR language to Sanskrit
            Language = OcrLanguage.Sanskrit
        };

        // Define the input image or PDF file containing Sanskrit text
        using (var Input = new OcrInput(@"images\Sanskrit.png"))
        {
            // Perform OCR to read the text from the Input
            var Result = Ocr.Read(Input);

            // Capture the extracted text
            var AllText = Result.Text;

            // Print the extracted text to the console
            System.Co/nsole.WriteLine(AllText);
        }
    }
}
// Import the IronOcr namespace
using IronOcr;

class Program
{
    static void Main()
    {
        // Create an instance of IronTesseract for OCR operations
        var Ocr = new IronTesseract
        {
            // Set the OCR language to Sanskrit
            Language = OcrLanguage.Sanskrit
        };

        // Define the input image or PDF file containing Sanskrit text
        using (var Input = new OcrInput(@"images\Sanskrit.png"))
        {
            // Perform OCR to read the text from the Input
            var Result = Ocr.Read(Input);

            // Capture the extracted text
            var AllText = Result.Text;

            // Print the extracted text to the console
            System.Co/nsole.WriteLine(AllText);
        }
    }
}
Imports IronOcr

Class Program
    Shared Sub Main()
        ' Create an instance of IronTesseract for OCR operations
        Dim Ocr As New IronTesseract With {
            ' Set the OCR language to Sanskrit
            .Language = OcrLanguage.Sanskrit
        }

        ' Define the input image or PDF file containing Sanskrit text
        Using Input As New OcrInput("images\Sanskrit.png")
            ' Perform OCR to read the text from the Input
            Dim Result = Ocr.Read(Input)

            ' Capture the extracted text
            Dim AllText = Result.Text

            ' Print the extracted text to the console
            System.Console.WriteLine(AllText)
        End Using
    End Sub
End Class
$vbLabelText   $csharpLabel
  • 此範例展示如何設定 IronTesseract,對梵文圖片或 PDF 執行 OCR 處理。
  • Ocr.Read() 方法會處理輸入內容並擷取文字內容,該內容可透過 Result.Text 屬性存取。