LEADTOOLS OCR功能提供了将光学字符识别(OCR)技术融合到应用程序中的方法。OCR可将位图图像转换为文本。
一旦在系统中安装LEADTOOLS .NET OCR工具包,用户便可以在程序中使用LEADTOOLS OCR。需要注意的是,在用户使用OCR属性,方法和事件之前,必须对OCR功能解锁。
用户可以添加引用到和 组件从而启动LEADTOOLS for .NET OCR。这些组件包含了各种接口、类、结构和委托。
由于LEADTOOLS OCR工具包支持多个引擎,一旦创建了IOcrEngine接口实例,与引擎接口的实际代码便被存储在一个被动态加载的单独程序集中。因此,你必须确保即将使用的引擎程序集位于旁边的组件。如果你需要自动检测依赖关系,你可以将引擎程序集作为引用添加到程序中。
LEADTOOLS提供了实现下列功能的方法:
- 从各种文字、文字处理、数据库或者电子表格文档中识别和导出文本;
- 在单线程或者多线程环境下执行OCR处理;
- 选择需要识别的文档语言,如英语,丹麦语,荷兰语,芬兰语,法语,德语,意大利语,挪威语,葡萄牙语,俄语,西班牙语或瑞典语;
- 自动或手动将复杂页面划分为文本区,图像区,表格区,线,页眉和页脚;
- 识别前,设置精度阈值以控制识别精度;
- 自动检测传真,点阵和其他degraded文档;
- 支持多种文档保存格式,如Adobe PDF、 PDF/A, MS Word, MS Excel和UNICODE文本等等。
- 处理文本和图形。
LEADTOOLS通过OCR手柄与OCR引擎和包含的页面列表的OCR文档进行交互。OCR手柄是安装在系统上的LEADTOOLS OCR和OCR引擎之间的通信会话。OCR手柄是一种内部结构,包含了识别、获取信息、设置信息和文本验证的所有必要信息。
识别单页或多页的步骤如下:
1、选择所需引擎类型并创建IOcrEngine接口实例;
2、利用 方法启动OCR引擎;
3、简单单页或多页OCR文档;
4、手动或自动创建页面区域;
5、设置OCR引擎所需的活动语言;
6、设置拼写检查语言;
7、识别;
8、保存识别结果;
9、关闭OCR引擎。
步骤4,5,6和7可以不必依照顺序进行,只要在OCR引擎启动后和页面识别之间执行这几个步骤即可。
下面的示例展示了如何执行上述步骤:
Visual Basic
' Assuming you added "Imports " and "Imports " at the beginning of this class
' *** Step 1: Select the engine type and create an instance of the IOcrEngine interface.
' We will use the LEADTOOLS OCR Plus engine and use it in the same process
Dim ocrEngine As IOcrEngine = (, False)
' *** Step 2: Startup the engine.
' Use the default parameters
(Nothing, Nothing, Nothing, "C:\LEADTOOLS 18\Bin\Common\OcrAdvantageRuntime")
' *** Step 3: Create an OCR document with one or more pages.
Dim ocrDocument As IOcrDocument = ()
' Add all the pages of a multi-page TIF image to the document
("C:\Users\Public\Documents\LEADTOOLS Images\", 1, -1, Nothing)
' *** Step 4: Establish zones on the page(s), either manually or automatically
' Automatic zoning
(Nothing)
' *** Step 5: (Optional) Set the active languages to be used by the OCR engine
' Enable English and German languages
(New String() {"en", "de"})
' *** Step 6: (Optional) Set the spell checking language
' Enable the spell checking system and set English as the spell language
=
= "en"
' *** Step 7: (Optional) Set any special recognition module options
' Change the fill method for the first zone in the first page to be Omr
Dim ocrZone As OcrZone = (0).Zones(0)
=
(0).Zones(0) = ocrZone
' *** Step 8: Recognize
(Nothing)
' *** Step 9: Save recognition results
' Save the results to a PDF file
("C:\Users\Public\Documents\LEADTOOLS Images\", , Nothing)
()
' *** Step 10: Shut down the OCR engine when finished
()
()
C#
// Assuming you added "using ;", "using ;" and "using ;" at the beginning of this class
// *** Step 1: Select the engine type and create an instance of the IOcrEngine interface.
// We will use the LEADTOOLS OCR Plus engine and use it in the same process
IOcrEngine ocrEngine = (, false);
// *** Step 2: Startup the engine.
// Use the default parameters
(null, null, null, @"C:\LEADTOOLS 18\Bin\Common\OcrAdvantageRuntime");
// *** Step 3: Create an OCR document with one or more pages.
IOcrDocument ocrDocument = ();
// Add all the pages of a multi-page TIF image to the document
(@"C:\Users\Public\Documents\LEADTOOLS Images\", 1, -1, null);
// *** Step 4: Establish zones on the page(s), either manually or automatically
// Automatic zoning
(null);
// *** Step 5: (Optional) Set the active languages to be used by the OCR engine
// Enable English and German languages
(new string[] { "en", "de" });
// *** Step 6: (Optional) Set the spell checking language
// Enable the spell checking system and set English as the spell language
= ;
= "en";
// *** Step 7: (Optional) Set any special recognition module options
// Change the fill method for the first zone in the first page to be default
OcrZone ocrZone = [0].Zones[0];
= ;
[0].Zones[0] = ocrZone;
// *** Step 8: Recognize
(null);
// *** Step 9: Save recognition results
// Save the results to a PDF file
(@"C:\Users\Public\Documents\LEADTOOLS Images\", , null);
();
// *** Step 10: Shut down the OCR engine when finished
();
();