码迷,mamicode.com
首页 > Windows程序 > 详细

vs2013 Asprise OCR C# 调用心得

时间:2015-06-15 12:31:33      阅读:1853      评论:0      收藏:0      [点我收藏+]

标签:

这几天研究了下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

 

vs2013 Asprise OCR C# 调用心得

标签:

原文地址:http://www.cnblogs.com/jywhypr/p/4576519.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!