赞
踩
今天开始学习LeadTools
官网:leadtools.gcpowertools.com.cn
官网是纯英文的,废了不少劲,终于看个大概,先建立个demo测试下
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using Leadtools;
-
- using Leadtools.Ocr;
- using Leadtools.Document.Writer;
- using Leadtools.Codecs;
-
- namespace OMR_Demo
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- SetLicense();
- }
-
- static void SetLicense()
- {
- string license = @"C:\Users\a\Downloads\LEADTOOLS.v22\Support\Common\License\LEADTOOLS.LIC";
- string key = File.ReadAllText(@"C:\Users\a\Downloads\LEADTOOLS.v22\Support\Common\License\LEADTOOLS.LIC.KEY");
- RasterSupport.SetLicense(license, key);
- if (RasterSupport.KernelExpired)
- MessageBox.Show("License file invalid or expired.");
- else
- MessageBox.Show("License file set successfully");
- string workDir = @"C:\MyApp\OcrTemp";
- RasterCodecs codecs = new RasterCodecs();
- // Directory.Delete(workDir, true);
-
-
- using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD))
- {
- Console.WriteLine("Before calling Startup, IsStarted = " + ocrEngine.IsStarted);
- ocrEngine.Startup(codecs, null, workDir, LEAD_VARS.OcrLEADRuntimeDir);
- //ocrEngine.Shutdown();
-
- }
-
- }
- }
- static class LEAD_VARS
- {
- public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
- public const string OcrLEADRuntimeDir = @"D:\system\group-office-automation\";
- }
- }

运行的结果SetLicense是成功的,但是在启动Ocr引擎的时候一直提示:
名称 | 值 | 类型 | |
---|---|---|---|
◢ | $exception | {"OCR component missing"} | Leadtools.Ocr.OcrException |
查询官网发现错误是:缺少OCR组件,卡住了,猜想是肯定少安装了组件,有大神知道了欢迎支招,我先翻看官网研究吧.....
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。