OCR图像的某一区域
此示例通过选择图像的特定区域在 .NET 中执行 OCR,实现了 41% 的速度提升。
这些称为ContentAreas
或CropAreas
。
How to Crop Specific Area of Image in C#
- 下载用于裁剪图像特定区域的C#库
- 实例化
IronTesseract
类。 - 使用指定的区域实例化
CropRectangle
对象 - 使用
AddImage
方法添加图像和裁剪详细信息。 - 使用
Read
方法从指定区域读取
using IronOcr; using IronSoftware.Drawing; using System; var ocrTesseract = new IronTesseract(); using var ocrInput = new OcrInput(); // A 41% improvement on speed by specifiying a pixel region var ContentArea = new Rectangle(x: 215, y: 1250, width: 1335, height: 280); ocrInput.LoadImage("img/example.png", ContentArea); var ocrResult = ocrTesseract.Read(ocrInput); Console.WriteLine(ocrResult.Text);
Imports IronOcr Imports IronSoftware.Drawing Imports System Private ocrTesseract = New IronTesseract() Private ocrInput = New OcrInput() ' A 41% improvement on speed by specifiying a pixel region Private ContentArea = New Rectangle(x:= 215, y:= 1250, width:= 1335, height:= 280) ocrInput.LoadImage("img/example.png", ContentArea) Dim ocrResult = ocrTesseract.Read(ocrInput) Console.WriteLine(ocrResult.Text)
Install-Package IronOcr
此示例通过选择图像的特定区域在 .NET 中执行 OCR,实现了 41% 的速度提升。
这些称为ContentAreas
或CropAreas
。
IronTesseract
类。CropRectangle
对象AddImage
方法添加图像和裁剪详细信息。Read
方法从指定区域读取