当前位置:   article > 正文

LeadTools图像处理C#阅卷系统、OCR、OMR学习之路(一)_c#中调用leadtools

c#中调用leadtools

今天开始学习LeadTools

官网:leadtools.gcpowertools.com.cn

官网是纯英文的,废了不少劲,终于看个大概,先建立个demo测试下

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using Leadtools;
  11. using Leadtools.Ocr;
  12. using Leadtools.Document.Writer;
  13. using Leadtools.Codecs;
  14. namespace OMR_Demo
  15. {
  16. public partial class Form1 : Form
  17. {
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. SetLicense();
  22. }
  23. static void SetLicense()
  24. {
  25. string license = @"C:\Users\a\Downloads\LEADTOOLS.v22\Support\Common\License\LEADTOOLS.LIC";
  26. string key = File.ReadAllText(@"C:\Users\a\Downloads\LEADTOOLS.v22\Support\Common\License\LEADTOOLS.LIC.KEY");
  27. RasterSupport.SetLicense(license, key);
  28. if (RasterSupport.KernelExpired)
  29. MessageBox.Show("License file invalid or expired.");
  30. else
  31. MessageBox.Show("License file set successfully");
  32. string workDir = @"C:\MyApp\OcrTemp";
  33. RasterCodecs codecs = new RasterCodecs();
  34. // Directory.Delete(workDir, true);
  35. using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD))
  36. {
  37. Console.WriteLine("Before calling Startup, IsStarted = " + ocrEngine.IsStarted);
  38. ocrEngine.Startup(codecs, null, workDir, LEAD_VARS.OcrLEADRuntimeDir);
  39. //ocrEngine.Shutdown();
  40. }
  41. }
  42. }
  43. static class LEAD_VARS
  44. {
  45. public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
  46. public const string OcrLEADRuntimeDir = @"D:\system\group-office-automation\";
  47. }
  48. }

运行的结果SetLicense是成功的,但是在启动Ocr引擎的时候一直提示:

名称类型
$exception{"OCR component missing"}Leadtools.Ocr.OcrException

查询官网发现错误是:缺少OCR组件,卡住了,猜想是肯定少安装了组件,有大神知道了欢迎支招,我先翻看官网研究吧.....

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/730166
推荐阅读
相关标签
  

闽ICP备14008679号