vs2013 Asprise OCR C# 调用心得


这几天研究了下ORC 文字识别,大概了解了三种识别方式:

1、通过微软的控件调用Microsoft Office Document Imaging。

2、是通过AspriseOCR 调用

3、是Tesseract ORC

本人刚接触编程不久,基本功不好,走了很多弯路,先把自己的一些体会写下来,留着以后复习用

 

先讲 AspriseOCR 调用,这个是官网免费版,就是调用的时候会弹出对话框,让你访问官网

看了官网的SDK,欺负我E文不好,大概能看懂就行

http://asprise.com/ocr/docs/html/asprise-ocr-library-csharp-vb.net-component.html#option-1-pm-install-package-asprise-ocr-api

下载

实例文件和API类库

http://asprise.com/royalty-free-library/c%23-sharp.net-ocr-for-windows-mac-linux-download.html

 

新建一个c#项目:

导入asprise-ocr-api 这个项目

把里面的  demo文件夹中 aocr.dll, aocr_x64.dll 复制到项目的跟目录下

在自己新建的代码中添加如下代码:

using asprise_ocr_api; AspriseOCR.SetUp(); AspriseOCR ocr = new AspriseOCR(); ocr.StartEngine("eng", AspriseOCR.SPEED_FASTEST); string s = ocr.Recognize("C:\path\img.jpg", -1, -1, -1, -1, -1, AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); Console.WriteLine("OCR Result: " + s); // process more images here ... ocr.StopEngine();

项目完成

--------------------------------------------------------------------------------------------------------------------------------------------

华丽的分隔符

下面讲破解版的asprise 的使用

先从网上下载  破解文件,包含三个文件:AspriseOCR.dll、DevIL.dll、ILU.dll。

把这3个文件复制 生成可执行文件的跟目录下,在项目属性----生成-----目标平台 设置  x86平台,否者一直报错。!!!!   .Net 2.0 平台

 

 

其中需要使用的3个dll是AspriseOCR.dll、DevIL.dll、ILU.dll。 

需要注意的是这几个.dll是vc写的引用要在程序中用DllImport引用,关键代码:

在类的开头引入如下代码:

[DllImport("AspriseOCR.dll", EntryPoint = "OCR", CallingConvention = CallingConvention.Cdecl)]

public static extern IntPtr OCR(string file, int type);

[DllImport("AspriseOCR.dll", EntryPoint = "OCRpart", CallingConvention = CallingConvention.Cdecl)]

static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height);

[DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes", CallingConvention = CallingConvention.Cdecl)]

static extern IntPtr OCRBarCodes(string file, int type);

[DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes", CallingConvention = CallingConvention.Cdecl)]

static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height);

 

调用代码很简单只有一句:

MessageBox.Show(Marshal.PtrToStringAnsi(OCRpart(img_path, -1, startX, startY, width, height)));

其中img_path:为图片路径,startX、startY坐标均为0即可,width、height图片的宽和高。

 

 

破解方法教程参考:http://m.blog.csdn.net/blog/scys1217/19809855

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM