額外的 OCR 語言包
IronOCR支持125種國際語言,但只有 英語 作為標準配置安裝在IronOCR中。
附加語言包可輕鬆新增至您的C#、VB或ASP .NET可以透過NuGet或作為Dlls下載並添加為專案引用。
程式碼範例
國際語言範例
//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
垂直書寫語言範例
針對直書式語言調整的字典。 使用韓國和日本的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
自訂語言範例
若您已下載或自行訓練任何 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
多語言示例
一次使用多種語言。
//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
更快的語言範例
字典調整為快速。 使用任何 OcrLanguage 的「Fast」變體。
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
更高精確度的細節語言示例
字典經過調校以提高準確性,但結果較慢。 使用任何 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
如何安裝 OCR 語言包
其他 OCR 語言包可從下面下載。 Either
- 安裝 NuGet 套件。 在 NuGet 上搜索 IronOCR 語言包.
- 或下載 "ocrdata" 文件並將其添加到您的 .NET 項目中任意您喜歡的文件夾。設置
CopyToOutputDirectory = CopyIfNewer
。
下載 OCR 語言包
加拿大原住民字母語言包 加拿大原住民壓縮 NuGet
- 埃塞俄比亞字母語言包 格埃茲語壓縮 NuGet
Fraktur 語言包 普遍黑体壓縮 NuGet
Gurmukhi 字母語言包 古魯穆奇字体壓縮 NuGet
Javanese 語言包 爪哇语壓縮 NuGet
Quechua 語言包 魯納西米壓縮 NuGet
- 約魯巴語語言包 約魯巴語壓縮 NuGet
幫助
如果您要閱讀的語言不在上面的列表中,請聯絡我們與我們一起。 其他語言可應要求提供。
生產資源的優先權授予IronOCR的許可證持有者,因此請也考慮此事。授權IronOCR用於訪問您所需的語言包。