本示例演示如何通过选择图像的特定区域在.NET中进行光学字符识别 (OCR) 来提高OCR速度。 这些被称为ContentAreas或CropAreas。
如何在 C# 中裁剪图像的特定区域
- 下载一个C#库以裁剪图像的特定区域
- 实例化
IronTesseract类。 - 使用指定区域实例化
Rectangle对象。 - 使用
LoadImage方法添加图像及裁剪详细信息。 - 使用
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
Dim ocrTesseract = New IronTesseract()
Using ocrInput = New OcrInput()
' A 41% improvement on speed by specifiying a pixel region
Dim 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)
End UsingImports IronOcr
Imports IronSoftware.Drawing
Imports System
Dim ocrTesseract = New IronTesseract()
Using ocrInput = New OcrInput()
' A 41% improvement on speed by specifiying a pixel region
Dim 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)
End Using本示例演示如何通过选择图像的特定区域在.NET中进行光学字符识别 (OCR) 来提高OCR速度。 这些被称为ContentAreas或CropAreas。
IronTesseract类。Rectangle对象。LoadImage方法添加图像及裁剪详细信息。Read方法从指定区域读取数据。NuGet 下载量 6,411,693|版本:2026.11刚刚发布