找回密码
 立即注册

QQ登录

只需一步,快速开始

williamxuj

注册会员

1

主题

5

帖子

85

积分

注册会员

积分
85

微信认证勋章

最新发帖
williamxuj
注册会员   /  发表于:2016-8-3 19:02  /   查看:4341  /  回复:3
本帖最后由 williamxuj 于 2016-8-4 19:04 编辑

我在试用OCR,然后报Leadtools.RasterException异常,Message:TIF codec is needed to use this feature
环境C# 4.5,Windows10,vs2015
报错在ocrDocument.Pages.AddPages(@"C:\Users\Public\Documents\LEADTOOLS Images\OCR1.tif", 1, -1, null);这行
代码如下:
            // Assuming you added "using Leadtools.Codecs;", "using Leadtools.Forms.Ocr;" and "using Leadtools.Forms.DocumentWriters;" 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 Advantage engine and use it in the same process
            IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false);

            // *** Step 2: Startup the engine.

            // Use the default parameters
            ocrEngine.Startup(null, null, null, @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime");

            // *** Step 3: Create an OCR document with one or more pages.

            IOcrDocument ocrDocument = ocrEngine.DocumentManager.CreateDocument();

            // Add all the pages of a multi-page TIF image to the document
            ocrDocument.Pages.AddPages(@"C:\Users\Public\Documents\LEADTOOLS Images\OCR1.tif", 1, -1, null);

            // *** Step 4: Establish zones on the page(s), either manually or automatically

            // Automatic zoning
            ocrDocument.Pages.AutoZone(null);

            // *** Step 5: (Optional) Set the active languages to be used by the OCR engine

            // Enable English and German languages
            ocrEngine.LanguageManager.EnableLanguages(new string[] { "en", "de" });

            // *** Step 6: (Optional) Set the spell checking engine

            // Enable the spell checking system
            ocrEngine.SpellCheckManager.SpellCheckEngine = OcrSpellCheckEngine.Native;

            // *** Step 7: (Optional) Set any special recognition module options

            // Change the zone method for the first zone in the first page to be Graphics so it will not be recognized
            OcrZone ocrZone = ocrDocument.Pages[0].Zones[0];
            ocrZone.ZoneType = OcrZoneType.Graphic;
            ocrDocument.Pages[0].Zones[0] = ocrZone;

            // *** Step 8: Recognize

            ocrDocument.Pages.Recognize(null);

            // *** Step 9: Save recognition results

            // Save the results to a PDF file
            ocrDocument.Save(@"C:\Users\Public\Documents\LEADTOOLS Images\Document.pdf", DocumentFormat.Pdf, null);
            ocrDocument.Dispose();

            // *** Step 10: Shut down the OCR engine when finished
            ocrEngine.Shutdown();
            ocrEngine.Dispose();

论坛以前也没人提过这个异常
请问这个怎么解?

3 个回复

倒序浏览
williamxuj
注册会员   /  发表于:2016-8-3 19:07:36
沙发
补充:我的Leadtools版本是EVAL 19.160526.053910
回复 使用道具 举报
williamxuj
注册会员   /  发表于:2016-8-4 19:04:06
板凳
解决:add reference Leadtools.codecs.Tif.dll
回复 使用道具 举报
AvoCaDolol活字格认证 Wyn认证
社区贡献组   /  发表于:2016-8-12 13:39:46
地板
williamxuj 发表于 2016-8-4 19:04
解决:add reference Leadtools.codecs.Tif.dll

是的,缺少TIF的Codec引用。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部