附加的OCR语言包

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

IronOCR支持125种国际语言,但只有 英语 作为标准配置安装在IronOCR中。

C#、VB 或其他程序中可以轻松添加额外的语言包。ASP .NET通过NuGet或作为Dll下载并添加为项目引用。



代码示例

国际语言范例

//PM> Install-Package IronOcr.Languages.ChineseSimplified

using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.ChineseSimplified;

using (var input = new OcrInput())
{
    input.AddImage("img/chinese.gif");

    // Add image filters if needed
    // Input.Deskew();
    // Input.DeNoise();

    OcrResult result = ocr.Read(input);

    string TestResult = result.Text;

    // Console can't print unicode. Save to disk instead.
    result.SaveAsTextFile("chinese.txt");
}
//PM> Install-Package IronOcr.Languages.ChineseSimplified

using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.ChineseSimplified;

using (var input = new OcrInput())
{
    input.AddImage("img/chinese.gif");

    // Add image filters if needed
    // Input.Deskew();
    // Input.DeNoise();

    OcrResult result = ocr.Read(input);

    string TestResult = result.Text;

    // Console can't print unicode. Save to disk instead.
    result.SaveAsTextFile("chinese.txt");
}
'PM> Install-Package IronOcr.Languages.ChineseSimplified

Imports IronOcr

Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.ChineseSimplified

Using input = New OcrInput()
	input.AddImage("img/chinese.gif")

	' Add image filters if needed
	' Input.Deskew();
	' Input.DeNoise();

	Dim result As OcrResult = ocr.Read(input)

	Dim TestResult As String = result.Text

	' Console can't print unicode. Save to disk instead.
	result.SaveAsTextFile("chinese.txt")
End Using
VB   C#

纵向书写语言示例

为垂直书写语言调整的词典。 使用韩语和日语的“垂直”变体OcrLanguage。

using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.JapaneseVertical;

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.JapaneseVertical;

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.JapaneseVertical

Using input = New OcrInput("images\image.png")
	Dim result As OcrResult = ocr.Read(input)
	Console.WriteLine(result.Text)
End Using
VB   C#

自定义语言示例

要使用您下载或自行训练的任何 Tesseract .Traineddata 语言文件

using IronOcr;

IronTesseract ocr = new IronTesseract();

ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
using IronOcr;

IronTesseract ocr = new IronTesseract();

ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr As New IronTesseract()

ocr.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata")

Using input = New OcrInput("images\image.png")
	Dim result As OcrResult = ocr.Read(input)
	Console.WriteLine(result.Text)
End Using
VB   C#

多种语言示例

一次使用多种语言。

//PM> Install-Package IronOcr.Languages.Arabic
using IronOcr;

IronTesseract ocr = new IronTesseract();

ocr.Language = OcrLanguage.English;
ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
// Add any number of languages

using (var input = new OcrInput(@"images\multi-lang.pdf"))
{
    var Result = ocr.Read(input);
    Console.WriteLine(Result.Text);
}
//PM> Install-Package IronOcr.Languages.Arabic
using IronOcr;

IronTesseract ocr = new IronTesseract();

ocr.Language = OcrLanguage.English;
ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
// Add any number of languages

using (var input = new OcrInput(@"images\multi-lang.pdf"))
{
    var Result = ocr.Read(input);
    Console.WriteLine(Result.Text);
}
'PM> Install-Package IronOcr.Languages.Arabic
Imports IronOcr

Private ocr As New IronTesseract()

ocr.Language = OcrLanguage.English
ocr.AddSecondaryLanguage(OcrLanguage.Arabic)
' Add any number of languages

Using input = New OcrInput("images\multi-lang.pdf")
	Dim Result = ocr.Read(input)
	Console.WriteLine(Result.Text)
End Using
VB   C#

更快的语言示例

为速度而优化的字典。 使用任何OcrLanguage的“快速”变体。

using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.EnglishFast;

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.EnglishFast;

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
Imports IronOcr

Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.EnglishFast

Using input = New OcrInput("images\image.png")
	Dim result As OcrResult = ocr.Read(input)
	Console.WriteLine(result.Text)
End Using
VB   C#

更高精度的详细语言示例

字典调整为准确性,但结果速度较慢。 使用任何OcrLanguage的“最佳”变体。


//PM> Install-Package IronOcr.Languages.French
using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.FrenchBest;

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}

//PM> Install-Package IronOcr.Languages.French
using IronOcr;

IronTesseract ocr = new IronTesseract();
ocr.Language = OcrLanguage.FrenchBest;

using (var input = new OcrInput(@"images\image.png"))
{
    OcrResult result = ocr.Read(input);
    Console.WriteLine(result.Text);
}
'PM> Install-Package IronOcr.Languages.French
Imports IronOcr

Private ocr As New IronTesseract()
ocr.Language = OcrLanguage.FrenchBest

Using input = New OcrInput("images\image.png")
	Dim result As OcrResult = ocr.Read(input)
	Console.WriteLine(result.Text)
End Using
VB   C#

如何安装 OCR 语言包

可下载的其他OCR语言包如下。 任一

  • 安装 NuGet 包。 在 NuGet 中搜索 IronOcr 语言.
  • 或下载“ocrdata”文件,并将其添加到您喜欢的任何文件夹中的 .NET 项目中。设置 CopyToOutputDirectory = CopyIfNewer

下载 OCR 语言包

帮助

如果您想阅读的语言不在上面的列表中,请联系我们与我们在一起。 根据要求提供多种其他语言。

生产资源的优先权归 IronOCR 许可证持有者,请也考虑。授权IronOCR 可访问您所需的语言包。