Class AsposeOcr
Namespace: Aspose.OCR
Assembly: Aspose.OCR.dll (25.1.0)
Aspose OCR 库的主要 API
public class AsposeOcr
继承
继承成员
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
构造函数
AsposeOcr()
public AsposeOcr()
方法
CalculateSkew(OcrInput)
计算图像的倾斜角度。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public List<skewoutput> CalculateSkew(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
List<SkewOutput>
以度为单位的倾斜角度列表 Aspose.OCR.SkewOutput。
CompareImageTexts(string, string, RecognitionSettings, bool)
检查两张图像是否包含相同的文本。
public bool CompareImageTexts(string fullPath1, string fullPath2, RecognitionSettings settings = null, bool ignoreCase = true)
参数
fullPath1
string
第一张图像的路径。
fullPath2
string
第二张图像的路径。
settings
RecognitionSettings
识别设置。
ignoreCase
bool
True - 表示不区分大小写的搜索。
返回
如果图像具有相同的文本(90% 相似性),则为 True。
CorrectSpelling(string, SpellCheckLanguage, string)
纠正文本(替换拼写错误的单词)。
public string CorrectSpelling(string text, SpellCheckLanguage language = SpellCheckLanguage.Eng, string dictionaryPath = null)
参数
text
string
待纠正的文本。
language
SpellCheckLanguage
要使用的字典。
dictionaryPath
string
可选。用户字典的完整路径(频率字典)。 字典文件格式: UTF-8 编码的纯文本文件。 单词和单词频率用空格或制表符分隔。默认情况下,单词应在第一列,频率在第二列。 每个单词-频率对在单独的一行中。行定义为字符序列后跟换行符("\n")、回车符("\r"), 或回车符后紧跟换行符("\r\n")。 每个单词应为小写。
返回
替换单词后的文本。
DetectDefects(OcrInput, DefectType)
自动查找图像中可能会显著影响 OCR 准确性的有问题区域。 支持以文件、流或像素数组形式提供的 PNG、JPEG、BMP、TIFF、JFIF 和 GIF 图像。支持批量识别。
public List<defectoutput> DetectDefects(OcrInput images, DefectType defectType)
参数
images
OcrInput
源图像 Aspose.OCR.OcrInput
defectType
DefectType
要识别的缺陷类型 Aspose.OCR.DefectType
返回
List<DefectOutput>
检测到的图像缺陷或如果未找到缺陷则为空集合 Aspose.OCR.DefectOutput。
DetectRectangles(OcrInput)
检测图像上的文本区域。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public List<rectangleoutput> DetectRectangles(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
List<RectangleOutput>
检测到的文本区域或行的 Aspose.OCR.RectangleOutput 列表。
DetectRectangles(OcrInput, AreasType, bool)
检测图像上的文本区域。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public List<rectangleoutput> DetectRectangles(OcrInput images, AreasType areasType, bool detectAreas = true)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
areasType
AreasType
确定返回哪些矩形 - 行或段落。
detectAreas
bool
启用自动文本区域检测。
返回
List<RectangleOutput>
检测到的文本区域或行的 Aspose.OCR.RectangleOutput 列表。
ImageHasText(string, string, RecognitionSettings, bool, bool)
检查图像是否包含提供的文本片段。
public bool ImageHasText(string fullPath, string text, RecognitionSettings settings = null, bool ignoreCase = true, bool autoSkew = true)
参数
fullPath
string
图像的路径。
text
string
要在图像上搜索的文本片段。
settings
RecognitionSettings
识别设置。
ignoreCase
bool
True - 表示不区分大小写的搜索。
autoSkew
bool
启用自动图像倾斜校正。
返回
如果图像包含文本片段,则为 True。False - 图像不包含文本片段。
备注
识别图像并能够指定 Aspose.OCR.RecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF。
ImageHasText(string, Regex, RecognitionSettings, bool)
检查图像文本是否与提供的正则表达式匹配。
public bool ImageHasText(string fullPath, Regex regex, RecognitionSettings settings = null, bool autoSkew = true)
参数
fullPath
string
图像的路径。
regex
Regex
带有提供的模式和选项的 System.Text.RegularExpressions 对象。
settings
RecognitionSettings
识别设置。
autoSkew
bool
启用自动图像倾斜校正。
返回
如果图像文本与提供的正则表达式匹配,则为 True。
备注
识别图像并能够指定 Aspose.OCR.RecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF。
ImageTextDiff(string, string, RecognitionSettings, bool, bool)
比较两张图像上的文本并返回一个数字,表示它们的相似度(0 到 1)。
public float ImageTextDiff(string fullPath1, string fullPath2, RecognitionSettings settings = null, bool ignoreCase = true, bool autoSkew = true)
参数
fullPath1
string
第一张图像的路径。
fullPath2
string
第二张图像的路径。
settings
RecognitionSettings
识别设置。
ignoreCase
bool
True - 表示不区分大小写的搜索。
autoSkew
bool
启用自动图像倾斜校正。
返回
0 表示文本完全不同;1 表示文本相同。
Recognize(OcrInput)
识别图像/文档上的文本。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
public OcrOutput Recognize(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
Recognize(OcrInput, RecognitionSettings, CancellationToken)
识别图像/文档上的文本。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
public OcrOutput Recognize(OcrInput images, RecognitionSettings settings, CancellationToken cancellationToken)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
RecognitionSettings
识别设置 Aspose.OCR.RecognitionSettings。
cancellationToken
CancellationToken
CancellationToken 对象。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
Recognize(OcrInput, RecognitionSettings)
识别图像/文档上的文本。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
public OcrOutput Recognize(OcrInput images, RecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
RecognitionSettings
识别设置 Aspose.OCR.RecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
RecognizeCarPlate(OcrInput)
识别车牌上的文本。
public OcrOutput RecognizeCarPlate(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别车牌并能够指定 Aspose.OCR.CarPlateRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeCarPlate(OcrInput, CarPlateRecognitionSettings)
识别车牌上的文本。
public OcrOutput RecognizeCarPlate(OcrInput images, CarPlateRecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
CarPlateRecognitionSettings
识别设置 Aspose.OCR.CarPlateRecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别车牌并能够指定 Aspose.OCR.CarPlateRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeCharacters(OcrInput)
检测图像上的符号。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public List<characterrecognitionresult> RecognizeCharacters(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
List<CharacterRecognitionResult>
包含检测到的符号数据的 Aspose.OCR.CharacterRecognitionResult 列表。
RecognizeCharacters(OcrInput, DetectAreasMode, Language)
检测图像上的符号。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public List<characterrecognitionresult> RecognizeCharacters(OcrInput images, DetectAreasMode detectAreasMode = DetectAreasMode.UNIVERSAL, Language language = Language.Latin)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
detectAreasMode
DetectAreasMode
确定用于区域检测的神经网络类型。
language
Language
用于 OCR 的语言。
返回
List<CharacterRecognitionResult>
包含检测到的符号数据的 Aspose.OCR.Character 列表。
RecognizeFast(OcrInput)
识别图像/文档上的文本。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
public List<string> RecognizeFast(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的字符串列表。
RecognizeHandwrittenText(OcrInput)
识别图像上的手写文本。
public OcrOutput RecognizeHandwrittenText(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeIDCard(OcrInput)
识别身份证上的文本。
public OcrOutput RecognizeIDCard(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别身份证并能够指定 Aspose.OCR.IDCardRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeIDCard(OcrInput, IDCardRecognitionSettings)
识别身份证上的文本。
public OcrOutput RecognizeIDCard(OcrInput images, IDCardRecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
IDCardRecognitionSettings
识别设置 Aspose.OCR.IDCardRecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别身份证并能够指定 Aspose.OCR.IDCardRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeInvoice(OcrInput)
识别发票上的文本。
public OcrOutput RecognizeInvoice(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别发票并能够指定 Aspose.OCR.InvoiceRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeInvoice(OcrInput, InvoiceRecognitionSettings)
识别发票上的文本。
public OcrOutput RecognizeInvoice(OcrInput images, InvoiceRecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
InvoiceRecognitionSettings
识别设置 Aspose.OCR.InvoiceRecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别发票并能够指定 Aspose.OCR.InvoiceRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeLines(OcrInput)
识别包含单行文本的图像。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public OcrOutput RecognizeLines(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
RecognizeLines(OcrInput, RecognitionSettings)
识别包含单行文本的图像。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、文件夹、数组、档案。
public OcrOutput RecognizeLines(OcrInput images, RecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
RecognitionSettings
识别设置 Aspose.OCR.RecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
RecognizePassport(OcrInput)
识别护照上的文本。
public OcrOutput RecognizePassport(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别护照并能够指定 Aspose.OCR.PassportRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizePassport(OcrInput, PassportRecognitionSettings)
识别护照上的文本。
public OcrOutput RecognizePassport(OcrInput images, PassportRecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
PassportRecognitionSettings
识别设置 Aspose.OCR.PassportRecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别护照并能够指定 Aspose.OCR.PassportRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeReceipt(OcrInput)
识别收据上的文本。
public OcrOutput RecognizeReceipt(OcrInput images)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别发票并能够指定 Aspose.OCR.ReceiptRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
RecognizeReceipt(OcrInput, ReceiptRecognitionSettings)
识别收据上的文本。
public OcrOutput RecognizeReceipt(OcrInput images, ReceiptRecognitionSettings settings)
参数
images
OcrInput
源的容器。Aspose.OCR.OcrInput
settings
ReceiptRecognitionSettings
识别设置 Aspose.OCR.ReceiptRecognitionSettings。
返回
包含图像识别结果的 Aspose.OCR.RecognitionResult 对象列表。
备注
识别发票并能够指定 Aspose.OCR.ReceiptRecognitionSettings。 支持 GIF、PNG、JPEG、BMP、TIFF、JFIF、流、目录、数组、档案。
SaveMultipageDocument(string, SaveFormat, List<recognitionresult>, string, PdfOptimizationMode)
允许从 RecognitionResult 对象列表中获取多页文档
public static void SaveMultipageDocument(string fullFileName, SaveFormat saveFormat, List<recognitionresult> results, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
参数
fullFileName
string
保存识别结果的文件名及路径,格式为所选格式。
saveFormat
SaveFormat
文档格式(Docx、Txt、Pdf、Xlsx、Rtf、Json、Xml)。
results
List<RecognitionResult>
Aspose.OCR.RecognitionResult 对象列表。
embeddedFontPath
string
可选。用户字体的完整路径。
optimizePdf
PdfOptimizationMode
通过降低背景图像的质量来减少 PDF 文件大小。默认情况下,保留原始图像质量。
SaveMultipageDocument(string, SaveFormat, List<recognitionresult>, bool, SpellCheckLanguage, string, string, PdfOptimizationMode)
允许从 RecognitionResult 对象列表中获取多页文档
public static void SaveMultipageDocument(string fullFileName, SaveFormat saveFormat, List<recognitionresult> results, bool applySpellingCorrection, SpellCheckLanguage language = SpellCheckLanguage.Eng, string dictionaryPath = null, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
参数
fullFileName
string
保存识别结果的文件名及路径,格式为所选格式。
saveFormat
SaveFormat
文档格式(Docx、Txt、Pdf、Xlsx、Rtf、Json、Xml)。
results
List<RecognitionResult>
Aspose.OCR.RecognitionResult 对象列表。
applySpellingCorrection
bool
设置为 true 以纠正识别结果中的拼写错误(如果有)。
language
SpellCheckLanguage
拼写检查的字典(可选)。
dictionaryPath
string
可选。用户字典的完整路径,格式为 .txt。格式为 [word - space - frequence(number)]。 示例:the 23135851162\nthat 3400031103\n
embeddedFontPath
string
可选。用户字体的完整路径。
optimizePdf
PdfOptimizationMode
通过降低背景图像的质量来减少 PDF 文件大小。默认情况下,保留原始图像质量。
SaveMultipageDocument(MemoryStream, SaveFormat, List<recognitionresult>, string, PdfOptimizationMode)
允许从 RecognitionResult 对象列表中获取多页文档
public static void SaveMultipageDocument(MemoryStream stream, SaveFormat saveFormat, List<recognitionresult> results, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
参数
stream
MemoryStream
用于保存识别结果的 MemoryStream,格式为所选格式。
saveFormat
SaveFormat
文档格式(Docx、Txt、Pdf、Xlsx、Rtf、Json、Xml)。
results
List<RecognitionResult>
Aspose.OCR.RecognitionResult 对象列表。
embeddedFontPath
string
可选。用户字体的完整路径。
optimizePdf
PdfOptimizationMode
通过降低背景图像的质量来减少 PDF 文件大小。默认情况下,保留原始图像质量。
SaveMultipageDocument(MemoryStream, SaveFormat, List<recognitionresult>, bool, SpellCheckLanguage, string, string, PdfOptimizationMode)
允许从 RecognitionResult 对象列表中获取多页文档
public static void SaveMultipageDocument(MemoryStream stream, SaveFormat saveFormat, List<recognitionresult> results, bool applySpellingCorrection, SpellCheckLanguage language = SpellCheckLanguage.Eng, string dictionaryPath = null, string embeddedFontPath = null, PdfOptimizationMode optimizePdf = PdfOptimizationMode.MAXIMUM_QUALITY)
参数
stream
MemoryStream
用于保存识别结果的 MemoryStream,格式为所选格式。
saveFormat
SaveFormat
文档格式(Docx、Txt、Pdf、Xlsx、Rtf、Json、Xml)。
results
List<RecognitionResult>
Aspose.OCR.RecognitionResult 对象列表。
applySpellingCorrection
bool
设置为 true 以纠正识别结果中的拼写错误(如果有)。
language
SpellCheckLanguage
拼写检查的字典(可选)。
dictionaryPath
string
可选。用户字典的完整路径,格式为 .txt。格式为 [word - space - frequence(number)]。 示例:the 23135851162\nthat 3400031103\n
embeddedFontPath
string
可选。用户字体的完整路径。
optimizePdf
PdfOptimizationMode
通过降低背景图像的质量来减少 PDF 文件大小。默认情况下,保留原始图像质量。
OcrProgress
用于跟踪多页图像识别进度的事件。
public event OcrRecognizeEventHandler OcrProgress