<meta http-equiv="content-language" content="zh" />
<h1>C#和.NET的中文OCR</h1>
<h6>本文档的其他版本:</h6>
<ul>
<li><a href="../chinese">英语版 (This Page in English)</a></li>
<li><a href="/csharp/ocr/languages/">更多语言</a></li>
</ul>
<p>IronOCR是C#软件组件,允许.NET编码人员以126种语言(包括简体和繁体中文)从图像和PDF文档中读取文本。语言包有简体和繁体中文字符。</p>
<p>它是Tesseract的高级分支,专门为.NET开发人员构建,在速度和准确性方面均经常优于其他Tesseract引擎。</p>
<h2> IronOCR语言中文的内容</h2>
<p>该软件包包含352种.NET的OCR语言:</p>
<ul>
<li>简体中文</li>
<li>简体中文最佳</li>
<li>简体中文快速</li>
<li>中文简体垂直</li>
<li>简体中文垂直最佳</li>
<li>简体中文垂直快速</li>
<li>中国传统的</li>
<li>中国传统最佳</li>
<li>中国传统快</li>
<li>中文繁体垂直</li>
<li>中国传统垂直最佳</li>
<li>中文繁体垂直快速</li>
</ul>
<h2>下载</h2>
<p>中文语言包<span style='white-space:default'>[中文(Zhōngwén)]</span> <br/> * Download as <a class='languages-dll'
href='/csharp/ocr/packages/language-packs/Chinese.ocrdata.zip'>压缩<i class='fas fa-download'></i><br/> * Install with as
</a><a target='_blank' class='languages-nuget'
href="https://www.nuget.org/packages/IronOcr.Languages.Chinese/">https://www.nuget.org/packages/IronOcr.Languages.Chinese/</a>'>
NuGet<i class='nuget-icon'></i></p>
<h2>安装</h2>
<p>我们要做的第一件事是将我们的<strong>中文</strong>OCR软件包安装到您的.NET项目中。</p>
<p> <code>PM> Install-Package IronOcr.Languages.Chinese</code></p>
<h2>代码示例</h2>
<p>此C#代码示例从Image或PDF文档中读取简体中文文本。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Use an OcrInput to load the image
using (var Input = new OcrInput(@"images\Chinese.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Retrieve the recognized text
var AllText = Result.Text;
// Output the recognized text to the console
Console.WriteLine(AllText);
}
```
<h2>为什么选择IronOCR?</h2>
<p> IronOCR是易于安装,完整且文档证明的.NET软件库。</p>
<p>选择IronOCR可获得<strong>99.8%+的OCR准确性,</strong>而无需使用任何外部Web服务,持续的费用或通过Internet发送机密文档。</p>
<h4>为什么C#开发人员选择IronOCR而不是Vanilla Tesseract:</h4>
<ul>
<li>作为单个DLL或Nuget安装</li>
<li>包括开箱即用的Tesseract 5、4和3发动机。</li>
<li>准确率 99.8% 明显优于常规Tesseract。</li>
<li>极快的速度和多线程支持</li>
<li>兼容MVC,WebApp,桌面,控制台和服务器应用程序</li>
<li>没有可以使用的Exes或C ++代码</li>
<li>完整的PDF OCR支持</li>
<li>对几乎所有图像文件或PDF执行OCR</li>
<li>全面的.NET Core,Standard和FrameWork支持</li>
<li>在Windows,Mac,Linux,Azure,Docker,Lambda,AWS上部署</li>
<li>读取条形码和QR码</li>
<li>将OCR导出为XHTML</li>
<li>将OCR导出到可搜索的PDF文档</li>
<li>多线程支持</li>
<li>通过Nuget或OcrData文件管理的126种国际语言</li>
<li>提取图像,坐标,统计信息和字体。 不只是文字。</li>
<li>可用于在商业和专有应用程序中重新分发Tesseract OCR。</li>
</ul>
<p><em>当处理真实世界的图像和不完善的文档(例如照片)或具有数字噪点或不完美的低分辨率扫描时,IronOCR会发光。</em></p>
<p> .NET平台的其他<a href="/csharp/ocr/use-case/free-ocr-csharp/">免费OCR</a>库(例如其他.NET Tesseract API和Web服务)在这些实际使用案例中的性能不佳。</p>
<h2>带Tesseract 5的OCR-在C#中开始编码</h2>
<p>下面的代码示例显示了使用C#或VB .NET从图像读取文本是多么容易。</p>
<h3> OneLiner: 最简单的一行代码</h3>
```csharp
// Quick one-liner to read text from image
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;
```
<h3>可配置的Hello World</h3>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Create and configure OcrInput
using (var Input = new OcrInput())
{
Input.AddImage("images/sample.jpeg");
// You can add multiple images
// Perform OCR on the input
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
```
<h3>C#PDF OCR</h3>
<p>可以类似地使用相同的方法从任何PDF文档中提取文本。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from PDF
using (var input = new OcrInput())
{
input.AddPdf("example.pdf", "password");
// Optionally select specific PDF pages for OCR
var Result = Ocr.Read(input);
// Display the recognized text and page count
Console.WriteLine(Result.Text);
Console.WriteLine($"{Result.Pages.Count()} Pages");
// 1 page per PDF page
}
```
<h3>多页TIFF的OCR</h3>
<p> OCR读取TIFF文件格式,包括多个页面文档。 TIFF也可以直接转换为带有可搜索文本的PDF文件。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from multi-frame TIFF
using (var Input = new OcrInput())
{
Input.AddMultiFrameTiff("multi-frame.tiff");
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
```
<h3>条码和QR</h3>
<p> IronOCR的独特功能是在扫描文本时可以读取文档中的条形码和QR码。 <code>OcrResult.OcrBarcode</code>类的实例为开发人员提供了有关每个扫描条形码的详细信息。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing with barcode reading enabled
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
// OCR with barcode scanning
using (var input = new OcrInput())
{
input.AddImage("img/Barcode.png");
var Result = Ocr.Read(input);
// Output recognized barcodes
foreach (var Barcode in Result.Barcodes)
{
Console.WriteLine(Barcode.Value);
// Type and location properties are also exposed
}
}
```
<h3>图像特定区域的OCR</h3>
<p> IronOCR的所有扫描和读取方法均提供了准确指定要从中读取文本的页面的哪一部分的功能。 当我们查看标准化表格时,这非常有用,可以节省大量时间并提高效率。</p>
<p>要使用裁剪区域,我们将需要添加对<code>System.Drawing</code>的系统引用,以便可以使用<code>System.Drawing.Rectangle</code>对象。</p>
```csharp
// Import the IronOcr library
using IronOcr;
using System.Drawing; // Ensure this assembly reference is added
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from a specific area of an image
using (var Input = new OcrInput())
{
var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
// Dimensions are in pixels
Input.Add("document.png", ContentArea);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text); // Output the recognized text
}
```
<h3>OCR用于低质量扫描</h3>
<p>IronOCR <code>OcrInput</code>类可以修复普通Tesseract无法读取的扫描。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from low quality scan
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
Input.DeNoise(); // Fix digital noise and bad scan quality
Input.Deskew(); // Correct the rotation and perspective
var Result = Ocr.Read(Input); // Perform the OCR
Console.WriteLine(Result.Text); // Output the recognized text
}
```
<h3>将OCR结果导出为可搜索的PDF</h3>
<p>带有可复制文本字符串的图像到PDF。 可以由搜索引擎和数据库建立索引。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Convert OCR results to a searchable PDF
using (var Input = new OcrInput())
{
Input.Title = "Quarterly Report";
Input.AddImage("image1.jpeg");
Input.AddImage("image2.png");
Input.AddImage("image3.gif");
var Result = Ocr.Read(Input);
Result.SaveAsSearchablePdf("searchable.pdf"); // Save results as searchable PDF
}
```
<h3>TIFF到可搜索的PDF转换</h3>
<p>将TIFF文档(或任何图像文件组)直接转换为可搜索的PDF,可通过Intranet,网站和google搜索引擎对其进行索引。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Convert TIFF to searchable PDF
using (var Input = new OcrInput())
{
Input.AddMultiFrameTiff("example.tiff");
Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf");
}
```
<h3>将OCR结果导出为HTML</h3>
<p> OCR图像到XHTML的转换。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Convert OCR results to HTML format
using (var Input = new OcrInput())
{
Input.Title = "Html Title";
Input.AddImage("image1.jpeg");
var Result = Ocr.Read(Input);
Result.SaveAsHocrFile("results.html"); // Save results as HTML
}
```
<h2>OCR图像增强滤镜</h2>
<p>IronOCR为<code>OcrInput</code>对象提供了独特的过滤器,以提高OCR性能。</p>
<h3>图像增强代码示例</h3>
<p>使OCR输入图像质量更高,以产生更好,更快的OCR结果。</p>
```csharp
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Enhance low quality image for OCR
using (var Input = new OcrInput(@"LowQuality.jpeg"))
{
Input.DeNoise(); // Fix digital noise
Input.Deskew(); // Correct rotation and perspective
var Result = Ocr.Read(Input); // Perform the OCR
Console.WriteLine(Result.Text); // Output the recognized text
}
```
<h3>OCR图像过滤器列表</h3>
<p>IronOCR内置的用于增强OCR性能的输入滤波器包括:</p>
<p> <strong>Rotate</strong> -顺时针旋转图像数度。 对于逆时针,请使用负数。</p>
<p> <strong>Binarize</strong> -此图像过滤器将每个像素变为黑色或白色,而没有中间地线。可能会改善文本与背景对比度非常低的OCR性能。</p>
<p> <strong>ToGrayScale</strong> -此图像过滤器将每个像素变成灰度阴影。 不太可能提高OCR精度,但可能会提高速度</p>
<p> <strong>Contrast</strong> -自动增加对比度。 在低对比度扫描中,此过滤器通常可以提高OCR速度和准确性。</p>
<p> <strong>DeNoise</strong> -消除数字噪声。 该滤波器仅应在预期有噪声的地方使用。</p>
<p> <strong>Invert</strong> -反转每种颜色。 例如,白色变成黑色:黑色变成白色。</p>
<p> <strong>Dilate</strong> -高级形态。 <em>膨胀</em>将像素添加到图像中对象的边界。侵蚀对面</p>
<p> <strong>Erode</strong> -高级形态。 <em>侵蚀</em>去除了对象边界上的像素</p>
<p> <strong>Deskew</strong> -旋转图像,使其朝上且正交。 这对于OCR非常有用,因为Tesseract对倾斜扫描的公差可以低至5度。</p>
<p> <strong>DeepCleanBackgroundNoise</strong>-消除大量背景噪音。 仅在已知极端文档背景噪音的情况下使用此过滤器,因为此过滤器还会冒降低干净文档的OCR准确性的风险,并且CPU成本很高。</p>
<p> <strong>EnhanceResolution</strong>增强低质量图像的分辨率。 由于<em>OcrInput.MinimumDPI</em>和<em>OcrInput.TargetDPI</em>将自动捕获并解析低分辨率输入,因此通常不需要此过滤器。</p>
<p> <strong>CleanBackgroundNoise</strong> 这种设置有些耗时。 但是,它允许该库自动清除数字图像中的数字噪音,纸屑和其他瑕疵,否则将使其无法被其他OCR库读取。</p>
<p> <strong>EnhanceContrast</strong> 是一种设置,可使IronOCR自动增加文本与图像背景的对比度,从而提高OCR的准确性,并通常提高OCR的性能和速度。</p>
<p> <strong>EnhanceResolution</strong> 是一项设置,它将自动检测低分辨率图像(低于275dpi),并自动放大图像,然后对所有文本进行锐化处理,以便可以由OCR库完美读取。 尽管此操作本身很耗时,但通常会减少对图像进行OCR操作的总时间。</p>
<p> 语言 IronOCR支持22种国际语言包,并且语言设置可用于选择一种或多种要用于OCR操作的多种语言。</p>
<p> 策略 铁OCR支持两种策略。 我们可以选择对文档进行快速而不太准确的扫描,或者使用高级策略,该策略使用一些人工智能模型通过查看句子中单词彼此之间的统计关系来自动提高OCR文本的准确性。</p>
<p> <strong>ColorSpace</strong>是一种设置,通过该设置,我们可以选择灰度或彩色OCR。 通常,灰度是最佳选择。但是,有时当某些文本或背景的色相相似但颜色差异很大时,全色颜色空间会提供更好的效果。</p>
<p> <strong>DetectWhiteTextOnDarkBackgrounds</strong> 通常,所有OCR库都希望在白色背景上看到黑色文本。 此设置使IronOCR可以自动检测底片或带有白色文本的暗页并进行读取。</p>
<p> <strong>InputImageType</strong> 通过此设置,开发人员可以指导OCR库是查看完整文档还是片段(如屏幕截图)。</p>
<p> <strong>RotateAndStraighten</strong> 是一种高级设置,它使IronOCR具有读取不仅旋转而且还包含透视图的文档的独特功能,例如文本文档的照片。</p>
<p> <strong>ReadBarcodes</strong> 是一项有用的功能,它允许IronOCR在读取文本的同时自动读取页面上的条形码和QR码,而不会增加大量额外的时间负担。</p>
<p><strong>颜色深度</strong> 此设置确定OCR库将使用每个像素多少位来确定颜色的深度。较高的色深可能会提高OCR质量,但也会增加OCR操作完成所需的时间。</p>
<h2> 126语言包</h2>
<p>IronOCR通过以DLL形式分发的语言包支持<strong>126种国际语言</strong>,这些语言包可以<a href="/csharp/ocr/languages/">从本网站下载</a>,也可以从<a
href="https://www.nuget.org/packages?q=IronOcr.Languages">NuGet软件包管理器下载</a>。</p>
<p>语言包括德语,法语,英语,中文,日语等。 存在用于护照MRZ,MICR支票,财务数据,车牌等的专业语言包。 您还可以使用任何Tesseract“ .traineddata”文件-包括您自己创建的文件。</p>
<h3>语言范例</h3>
<p>使用其他OCR语言。</p>
```csharp
// Import the IronOcr library
// Ensure the Arabic language package is installed via NuGet
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic; // Set language to Arabic
// OCR using Arabic language
using (var input = new OcrInput())
{
input.AddImage("img/arabic.gif");
// Add image filters as needed
// This can improve OCR accuracy even with lower quality inputs
var Result = Ocr.Read(input);
// Saving Arabic text to file, console may not display correctly
Result.SaveAsTextFile("arabic.txt");
}
```
<h3>多语言示例</h3>
<p>也可以同时使用多种语言进行OCR。 这确实可以帮助获取Unicode文档中的英语元数据和URL。</p>
```csharp
// Import the IronOcr library
// Ensure the Chinese Simplified and other required languages are installed via NuGet
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.ChineseSimplified;
Ocr.AddSecondaryLanguage(OcrLanguage.Chinese);
// You can add multiple secondary languages
// OCR multi-language document
using (var input = new OcrInput())
{
input.Add("multi-language.pdf");
var Result = Ocr.Read(input);
Result.SaveAsTextFile("results.txt"); // Save results
}
```
<h2>详细的OCR结果对象</h2>
<p>IronOCR为每个OCR操作返回一个OCR结果对象。 通常,开发人员仅使用此对象的text属性来从图像中扫描文本。 但是,OCR结果DOM比这要先进得多。</p>
```csharp
// Import the IronOcr library
using IronOcr;
using System.Drawing; // Ensure assembly reference is added
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm; // Use both Tesseract and LSTM
Ocr.Configuration.ReadBarCodes = true; // Enable barcode reading
// OCR processing
using (var Input = new OcrInput(@"images\sample.tiff"))
{
OcrResult Result = Ocr.Read(Input);
var Pages = Result.Pages;
var Words = Pages[0].Words;
var Barcodes = Result.Barcodes;
// Explore detailed API options here:
// - Pages, Blocks, Paragraphs, Lines, Words, Characters
// - Image Export, Font Coordinates, Statistics
}
```
<h2>性能</h2>
<p>IronOCR开箱即用,无需性能调整或大量修改输入图像。</p>
<p>速度飞快:IronOCR.2020 +的速度提高了10倍,并且比以前的版本减少了250%以上的错误。</p>
<h2>学到更多</h2>
<p>要了解有关C#,VB,F#或任何其他.NET语言中OCR的更多信息,请<a
href="/csharp/ocr/tutorials/how-to-read-text-from-an-image-in-csharp-net/">阅读我们的社区教程</a>,其中提供了有关如何使用Iron
OCR的真实示例,并可能显示出如何从中获得最大收益的细微差别。 这个图书馆。</p>
<p>还提供<a href="/csharp/ocr/object-reference/api/">了.NET开发人员的</a>完整<a href="/csharp/ocr/object-reference/api/">对象参考</a>。</p>
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// Use an OcrInput to load the imageusing (varInput = new OcrInput(@"images\Chinese.png")){// Perform OCR on the input imagevarResult = Ocr.Read(Input);// Retrieve the recognized textvarAllText = Result.Text;// Output the recognized text to the consoleConsole.WriteLine(AllText);}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Use an OcrInput to load the image
using (var Input = new OcrInput(@"images\Chinese.png"))
{
// Perform OCR on the input image
var Result = Ocr.Read(Input);
// Retrieve the recognized text
var AllText = Result.Text;
// Output the recognized text to the console
Console.WriteLine(AllText);
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' Use an OcrInput to load the imageUsingInput = New OcrInput("images\Chinese.png")' Perform OCR on the input imageDimResult = Ocr.Read(Input)' Retrieve the recognized textDimAllText = Result.Text' Output the recognized text to the consoleConsole.WriteLine(AllText)EndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' Use an OcrInput to load the image
Using Input = New OcrInput("images\Chinese.png")
' Perform OCR on the input image
Dim Result = Ocr.Read(Input)
' Retrieve the recognized text
Dim AllText = Result.Text
' Output the recognized text to the console
Console.WriteLine(AllText)
End Using
// Quick one-liner to read text from imagestringText = new IronTesseract().Read(@"img\Screenshot.png").Text;
// Quick one-liner to read text from image
string Text = new IronTesseract().Read(@"img\Screenshot.png").Text;
' Quick one-liner to read text from imageDimTextAsString = (New IronTesseract()).Read("img\Screenshot.png").Text
' Quick one-liner to read text from image
Dim Text As String = (New IronTesseract()).Read("img\Screenshot.png").Text
可配置的Hello World
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// Create and configure OcrInputusing (varInput = new OcrInput()){Input.AddImage("images/sample.jpeg");// You can add multiple images// Perform OCR on the inputvarResult = Ocr.Read(Input);// Output the recognized text to the consoleConsole.WriteLine(Result.Text);}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Create and configure OcrInput
using (var Input = new OcrInput())
{
Input.AddImage("images/sample.jpeg");
// You can add multiple images
// Perform OCR on the input
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' Create and configure OcrInputUsingInput = New OcrInput()Input.AddImage("images/sample.jpeg")' You can add multiple images' Perform OCR on the inputDimResult = Ocr.Read(Input)' Output the recognized text to the consoleConsole.WriteLine(Result.Text)EndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' Create and configure OcrInput
Using Input = New OcrInput()
Input.AddImage("images/sample.jpeg")
' You can add multiple images
' Perform OCR on the input
Dim Result = Ocr.Read(Input)
' Output the recognized text to the console
Console.WriteLine(Result.Text)
End Using
C#PDF OCR
可以类似地使用相同的方法从任何PDF文档中提取文本。
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// OCR from PDFusing (var input = new OcrInput()){input.AddPdf("example.pdf", "password");// Optionally select specific PDF pages for OCRvarResult = Ocr.Read(input);// Display the recognized text and page countConsole.WriteLine(Result.Text);Console.WriteLine($"{Result.Pages.Count()} Pages");// 1 page per PDF page}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from PDF
using (var input = new OcrInput())
{
input.AddPdf("example.pdf", "password");
// Optionally select specific PDF pages for OCR
var Result = Ocr.Read(input);
// Display the recognized text and page count
Console.WriteLine(Result.Text);
Console.WriteLine($"{Result.Pages.Count()} Pages");
// 1 page per PDF page
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' OCR from PDFUsing input = New OcrInput()input.AddPdf("example.pdf", "password")' Optionally select specific PDF pages for OCRDimResult = Ocr.Read(input)' Display the recognized text and page countConsole.WriteLine(Result.Text)Console.WriteLine($"{Result.Pages.Count()} Pages")' 1 page per PDF pageEndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' OCR from PDF
Using input = New OcrInput()
input.AddPdf("example.pdf", "password")
' Optionally select specific PDF pages for OCR
Dim Result = Ocr.Read(input)
' Display the recognized text and page count
Console.WriteLine(Result.Text)
Console.WriteLine($"{Result.Pages.Count()} Pages")
' 1 page per PDF page
End Using
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// OCR from multi-frame TIFFusing (varInput = new OcrInput()){Input.AddMultiFrameTiff("multi-frame.tiff");varResult = Ocr.Read(Input);// Output the recognized text to the consoleConsole.WriteLine(Result.Text);}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from multi-frame TIFF
using (var Input = new OcrInput())
{
Input.AddMultiFrameTiff("multi-frame.tiff");
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' OCR from multi-frame TIFFUsingInput = New OcrInput()Input.AddMultiFrameTiff("multi-frame.tiff")DimResult = Ocr.Read(Input)' Output the recognized text to the consoleConsole.WriteLine(Result.Text)EndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' OCR from multi-frame TIFF
Using Input = New OcrInput()
Input.AddMultiFrameTiff("multi-frame.tiff")
Dim Result = Ocr.Read(Input)
' Output the recognized text to the console
Console.WriteLine(Result.Text)
End Using
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processing with barcode reading enabledvarOcr = new IronTesseract();Ocr.Configuration.ReadBarCodes = true;// OCR with barcode scanningusing (var input = new OcrInput()){input.AddImage("img/Barcode.png");varResult = Ocr.Read(input);// Output recognized barcodesforeach (varBarcodeinResult.Barcodes){Console.WriteLine(Barcode.Value);// Type and location properties are also exposed}}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing with barcode reading enabled
var Ocr = new IronTesseract();
Ocr.Configuration.ReadBarCodes = true;
// OCR with barcode scanning
using (var input = new OcrInput())
{
input.AddImage("img/Barcode.png");
var Result = Ocr.Read(input);
// Output recognized barcodes
foreach (var Barcode in Result.Barcodes)
{
Console.WriteLine(Barcode.Value);
// Type and location properties are also exposed
}
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processing with barcode reading enabledPrivateOcr = New IronTesseract()Ocr.Configuration.ReadBarCodes = True' OCR with barcode scanningUsing input = New OcrInput()input.AddImage("img/Barcode.png")DimResult = Ocr.Read(input)' Output recognized barcodesFor EachBarcodeInResult.BarcodesConsole.WriteLine(Barcode.Value)' Type and location properties are also exposedNextBarcodeEndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing with barcode reading enabled
Private Ocr = New IronTesseract()
Ocr.Configuration.ReadBarCodes = True
' OCR with barcode scanning
Using input = New OcrInput()
input.AddImage("img/Barcode.png")
Dim Result = Ocr.Read(input)
' Output recognized barcodes
For Each Barcode In Result.Barcodes
Console.WriteLine(Barcode.Value)
' Type and location properties are also exposed
Next Barcode
End Using
// Import the IronOcr libraryusing IronOcr;using System.Drawing; // Ensure this assembly reference is added// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// OCR from a specific area of an imageusing (varInput = new OcrInput()){varContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };// Dimensions are in pixelsInput.Add("document.png", ContentArea);varResult = Ocr.Read(Input);Console.WriteLine(Result.Text); // Output the recognized text}
// Import the IronOcr library
using IronOcr;
using System.Drawing; // Ensure this assembly reference is added
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from a specific area of an image
using (var Input = new OcrInput())
{
var ContentArea = new System.Drawing.Rectangle() { X = 215, Y = 1250, Height = 280, Width = 1335 };
// Dimensions are in pixels
Input.Add("document.png", ContentArea);
var Result = Ocr.Read(Input);
Console.WriteLine(Result.Text); // Output the recognized text
}
' Import the IronOcr libraryImportsIronOcrImportsSystem.Drawing' Ensure this assembly reference is added' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' OCR from a specific area of an imageUsingInput = New OcrInput()DimContentArea = New System.Drawing.Rectangle() With { .X = 215, .Y = 1250, .Height = 280, .Width = 1335}' Dimensions are in pixelsInput.Add("document.png", ContentArea)DimResult = Ocr.Read(Input)Console.WriteLine(Result.Text) ' Output the recognized textEndUsing
' Import the IronOcr library
Imports IronOcr
Imports System.Drawing ' Ensure this assembly reference is added
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' OCR from a specific area of an image
Using Input = New OcrInput()
Dim ContentArea = New System.Drawing.Rectangle() With {
.X = 215,
.Y = 1250,
.Height = 280,
.Width = 1335
}
' Dimensions are in pixels
Input.Add("document.png", ContentArea)
Dim Result = Ocr.Read(Input)
Console.WriteLine(Result.Text) ' Output the recognized text
End Using
OCR用于低质量扫描
IronOCR OcrInput类可以修复普通Tesseract无法读取的扫描。
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// OCR from low quality scanusing (varInput = new OcrInput(@"img\Potter.LowQuality.tiff")){Input.DeNoise(); // Fix digital noise and bad scan qualityInput.Deskew(); // Correct the rotation and perspectivevarResult = Ocr.Read(Input); // Perform the OCRConsole.WriteLine(Result.Text); // Output the recognized text}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// OCR from low quality scan
using (var Input = new OcrInput(@"img\Potter.LowQuality.tiff"))
{
Input.DeNoise(); // Fix digital noise and bad scan quality
Input.Deskew(); // Correct the rotation and perspective
var Result = Ocr.Read(Input); // Perform the OCR
Console.WriteLine(Result.Text); // Output the recognized text
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' OCR from low quality scanUsingInput = New OcrInput("img\Potter.LowQuality.tiff")Input.DeNoise() ' Fix digital noise and bad scan qualityInput.Deskew() ' Correct the rotation and perspectiveDimResult = Ocr.Read(Input) ' Perform the OCRConsole.WriteLine(Result.Text) ' Output the recognized textEndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' OCR from low quality scan
Using Input = New OcrInput("img\Potter.LowQuality.tiff")
Input.DeNoise() ' Fix digital noise and bad scan quality
Input.Deskew() ' Correct the rotation and perspective
Dim Result = Ocr.Read(Input) ' Perform the OCR
Console.WriteLine(Result.Text) ' Output the recognized text
End Using
将OCR结果导出为可搜索的PDF
带有可复制文本字符串的图像到PDF。 可以由搜索引擎和数据库建立索引。
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// Convert OCR results to a searchable PDFusing (varInput = new OcrInput()){Input.Title = "Quarterly Report";Input.AddImage("image1.jpeg");Input.AddImage("image2.png");Input.AddImage("image3.gif");varResult = Ocr.Read(Input);Result.SaveAsSearchablePdf("searchable.pdf"); // Save results as searchable PDF}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Convert OCR results to a searchable PDF
using (var Input = new OcrInput())
{
Input.Title = "Quarterly Report";
Input.AddImage("image1.jpeg");
Input.AddImage("image2.png");
Input.AddImage("image3.gif");
var Result = Ocr.Read(Input);
Result.SaveAsSearchablePdf("searchable.pdf"); // Save results as searchable PDF
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' Convert OCR results to a searchable PDFUsingInput = New OcrInput()Input.Title = "Quarterly Report"Input.AddImage("image1.jpeg")Input.AddImage("image2.png")Input.AddImage("image3.gif")DimResult = Ocr.Read(Input)Result.SaveAsSearchablePdf("searchable.pdf") ' Save results as searchable PDFEndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' Convert OCR results to a searchable PDF
Using Input = New OcrInput()
Input.Title = "Quarterly Report"
Input.AddImage("image1.jpeg")
Input.AddImage("image2.png")
Input.AddImage("image3.gif")
Dim Result = Ocr.Read(Input)
Result.SaveAsSearchablePdf("searchable.pdf") ' Save results as searchable PDF
End Using
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// Convert TIFF to searchable PDFusing (varInput = new OcrInput()){Input.AddMultiFrameTiff("example.tiff");Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf");}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Convert TIFF to searchable PDF
using (var Input = new OcrInput())
{
Input.AddMultiFrameTiff("example.tiff");
Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf");
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' Convert TIFF to searchable PDFUsingInput = New OcrInput()Input.AddMultiFrameTiff("example.tiff")Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf")EndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' Convert TIFF to searchable PDF
Using Input = New OcrInput()
Input.AddMultiFrameTiff("example.tiff")
Ocr.Read(Input).SaveAsSearchablePdf("searchable.pdf")
End Using
将OCR结果导出为HTML
OCR图像到XHTML的转换。
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// Convert OCR results to HTML formatusing (varInput = new OcrInput()){Input.Title = "Html Title";Input.AddImage("image1.jpeg");varResult = Ocr.Read(Input);Result.SaveAsHocrFile("results.html"); // Save results as HTML}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Convert OCR results to HTML format
using (var Input = new OcrInput())
{
Input.Title = "Html Title";
Input.AddImage("image1.jpeg");
var Result = Ocr.Read(Input);
Result.SaveAsHocrFile("results.html"); // Save results as HTML
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' Convert OCR results to HTML formatUsingInput = New OcrInput()Input.Title = "Html Title"Input.AddImage("image1.jpeg")DimResult = Ocr.Read(Input)Result.SaveAsHocrFile("results.html") ' Save results as HTMLEndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' Convert OCR results to HTML format
Using Input = New OcrInput()
Input.Title = "Html Title"
Input.AddImage("image1.jpeg")
Dim Result = Ocr.Read(Input)
Result.SaveAsHocrFile("results.html") ' Save results as HTML
End Using
OCR图像增强滤镜
IronOCR为OcrInput对象提供了独特的过滤器,以提高OCR性能。
图像增强代码示例
使OCR输入图像质量更高,以产生更好,更快的OCR结果。
// Import the IronOcr libraryusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese// Enhance low quality image for OCRusing (varInput = new OcrInput(@"LowQuality.jpeg")){Input.DeNoise(); // Fix digital noiseInput.Deskew(); // Correct rotation and perspectivevarResult = Ocr.Read(Input); // Perform the OCRConsole.WriteLine(Result.Text); // Output the recognized text}
// Import the IronOcr library
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
// Enhance low quality image for OCR
using (var Input = new OcrInput(@"LowQuality.jpeg"))
{
Input.DeNoise(); // Fix digital noise
Input.Deskew(); // Correct rotation and perspective
var Result = Ocr.Read(Input); // Perform the OCR
Console.WriteLine(Result.Text); // Output the recognized text
}
' Import the IronOcr libraryImportsIronOcr' Create an instance of IronTesseract for OCR processingPrivateOcr = New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to Chinese' Enhance low quality image for OCRUsingInput = New OcrInput("LowQuality.jpeg")Input.DeNoise() ' Fix digital noiseInput.Deskew() ' Correct rotation and perspectiveDimResult = Ocr.Read(Input) ' Perform the OCRConsole.WriteLine(Result.Text) ' Output the recognized textEndUsing
' Import the IronOcr library
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Private Ocr = New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
' Enhance low quality image for OCR
Using Input = New OcrInput("LowQuality.jpeg")
Input.DeNoise() ' Fix digital noise
Input.Deskew() ' Correct rotation and perspective
Dim Result = Ocr.Read(Input) ' Perform the OCR
Console.WriteLine(Result.Text) ' Output the recognized text
End Using
// Import the IronOcr library// Ensure the Arabic language package is installed via NuGetusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Arabic; // Set language to Arabic// OCR using Arabic languageusing (var input = new OcrInput()){input.AddImage("img/arabic.gif");// Add image filters as needed// This can improve OCR accuracy even with lower quality inputsvarResult = Ocr.Read(input);// Saving Arabic text to file, console may not display correctlyResult.SaveAsTextFile("arabic.txt");}
// Import the IronOcr library
// Ensure the Arabic language package is installed via NuGet
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Arabic; // Set language to Arabic
// OCR using Arabic language
using (var input = new OcrInput())
{
input.AddImage("img/arabic.gif");
// Add image filters as needed
// This can improve OCR accuracy even with lower quality inputs
var Result = Ocr.Read(input);
// Saving Arabic text to file, console may not display correctly
Result.SaveAsTextFile("arabic.txt");
}
' Import the IronOcr library' Ensure the Arabic language package is installed via NuGetImportsIronOcr' Create an instance of IronTesseract for OCR processingDimOcrAs New IronTesseract()Ocr.Language = OcrLanguage.Arabic' Set language to Arabic' OCR using Arabic languageUsing input As New OcrInput() input.AddImage("img/arabic.gif") ' Add image filters as needed ' This can improve OCR accuracy even with lower quality inputs DimResult = Ocr.Read(input) ' Saving Arabic text to file, console may not display correctlyResult.SaveAsTextFile("arabic.txt")EndUsing
' Import the IronOcr library
' Ensure the Arabic language package is installed via NuGet
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Dim Ocr As New IronTesseract()
Ocr.Language = OcrLanguage.Arabic ' Set language to Arabic
' OCR using Arabic language
Using input As New OcrInput()
input.AddImage("img/arabic.gif")
' Add image filters as needed
' This can improve OCR accuracy even with lower quality inputs
Dim Result = Ocr.Read(input)
' Saving Arabic text to file, console may not display correctly
Result.SaveAsTextFile("arabic.txt")
End Using
多语言示例
也可以同时使用多种语言进行OCR。 这确实可以帮助获取Unicode文档中的英语元数据和URL。
// Import the IronOcr library// Ensure the Chinese Simplified and other required languages are installed via NuGetusing IronOcr;// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.ChineseSimplified;Ocr.AddSecondaryLanguage(OcrLanguage.Chinese);// You can add multiple secondary languages// OCR multi-language documentusing (var input = new OcrInput()){input.Add("multi-language.pdf");varResult = Ocr.Read(input);Result.SaveAsTextFile("results.txt"); // Save results}
// Import the IronOcr library
// Ensure the Chinese Simplified and other required languages are installed via NuGet
using IronOcr;
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.ChineseSimplified;
Ocr.AddSecondaryLanguage(OcrLanguage.Chinese);
// You can add multiple secondary languages
// OCR multi-language document
using (var input = new OcrInput())
{
input.Add("multi-language.pdf");
var Result = Ocr.Read(input);
Result.SaveAsTextFile("results.txt"); // Save results
}
' Import the IronOcr library' Ensure the Chinese Simplified and other required languages are installed via NuGetImportsIronOcr' Create an instance of IronTesseract for OCR processingDimOcrAs New IronTesseract()Ocr.Language = OcrLanguage.ChineseSimplifiedOcr.AddSecondaryLanguage(OcrLanguage.Chinese)' You can add multiple secondary languages' OCR multi-language documentUsing input As New OcrInput() input.Add("multi-language.pdf") DimResult = Ocr.Read(input)Result.SaveAsTextFile("results.txt") ' Save resultsEndUsing
' Import the IronOcr library
' Ensure the Chinese Simplified and other required languages are installed via NuGet
Imports IronOcr
' Create an instance of IronTesseract for OCR processing
Dim Ocr As New IronTesseract()
Ocr.Language = OcrLanguage.ChineseSimplified
Ocr.AddSecondaryLanguage(OcrLanguage.Chinese)
' You can add multiple secondary languages
' OCR multi-language document
Using input As New OcrInput()
input.Add("multi-language.pdf")
Dim Result = Ocr.Read(input)
Result.SaveAsTextFile("results.txt") ' Save results
End Using
// Import the IronOcr libraryusing IronOcr;using System.Drawing; // Ensure assembly reference is added// Create an instance of IronTesseract for OCR processingvarOcr = new IronTesseract();Ocr.Language = OcrLanguage.Chinese; // Set language to ChineseOcr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm; // Use both Tesseract and LSTMOcr.Configuration.ReadBarCodes = true; // Enable barcode reading// OCR processingusing (varInput = new OcrInput(@"images\sample.tiff")){OcrResultResult = Ocr.Read(Input);varPages = Result.Pages;varWords = Pages[0].Words;varBarcodes = Result.Barcodes;// Explore detailed API options here:// - Pages, Blocks, Paragraphs, Lines, Words, Characters// - Image Export, Font Coordinates, Statistics}
// Import the IronOcr library
using IronOcr;
using System.Drawing; // Ensure assembly reference is added
// Create an instance of IronTesseract for OCR processing
var Ocr = new IronTesseract();
Ocr.Language = OcrLanguage.Chinese; // Set language to Chinese
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm; // Use both Tesseract and LSTM
Ocr.Configuration.ReadBarCodes = true; // Enable barcode reading
// OCR processing
using (var Input = new OcrInput(@"images\sample.tiff"))
{
OcrResult Result = Ocr.Read(Input);
var Pages = Result.Pages;
var Words = Pages[0].Words;
var Barcodes = Result.Barcodes;
// Explore detailed API options here:
// - Pages, Blocks, Paragraphs, Lines, Words, Characters
// - Image Export, Font Coordinates, Statistics
}
' Import the IronOcr libraryImportsIronOcrImportsSystem.Drawing' Ensure assembly reference is added' Create an instance of IronTesseract for OCR processingDimOcrAs New IronTesseract()Ocr.Language = OcrLanguage.Chinese' Set language to ChineseOcr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm' Use both Tesseract and LSTMOcr.Configuration.ReadBarCodes = True ' Enable barcode reading' OCR processingUsingInputAs New OcrInput("images\sample.tiff") DimResultAsOcrResult = Ocr.Read(Input) DimPages = Result.Pages DimWords = Pages(0).Words DimBarcodes = Result.Barcodes ' Explore detailed API options here: ' - Pages, Blocks, Paragraphs, Lines, Words, Characters ' - Image Export, Font Coordinates, StatisticsEndUsing
' Import the IronOcr library
Imports IronOcr
Imports System.Drawing ' Ensure assembly reference is added
' Create an instance of IronTesseract for OCR processing
Dim Ocr As New IronTesseract()
Ocr.Language = OcrLanguage.Chinese ' Set language to Chinese
Ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm ' Use both Tesseract and LSTM
Ocr.Configuration.ReadBarCodes = True ' Enable barcode reading
' OCR processing
Using Input As New OcrInput("images\sample.tiff")
Dim Result As OcrResult = Ocr.Read(Input)
Dim Pages = Result.Pages
Dim Words = Pages(0).Words
Dim Barcodes = Result.Barcodes
' Explore detailed API options here:
' - Pages, Blocks, Paragraphs, Lines, Words, Characters
' - Image Export, Font Coordinates, Statistics
End Using
Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapılandırılmış, görsel olarak çekici kılavuzlar oluşturmayı seviyor.