C#图片文字识别
来源:互联网 发布:什么下载软件 编辑:程序博客网 时间:2024/05/19 10:41
本文介绍两种比较主流和成熟的识别方式:
方式一、Asprise-OCR实现。
方式二、Microsoft Office Document Imaging(Office 2007) 组件实现。
方式一、Asprise-OCR的使用。
Asprise-OCR下载地址:
http://asprise.com/product/ocr/download.php?lang=csharp
其中需要使用的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图片的宽和高。
方式二、Microsoft Office Document Imaging(Office 2007) 组件实现。
在使用之前需要给大家说的是Imaging 组件的兼容性不是很好,使用win 7 office 2007的时必须打上office 2007 sp1或者sp2补丁,读取中文才行。
sp1补丁地址(226M) :
http://download.microsoft.com/download/1/6/5/1659d607-8696-4001-8072-efaedd70dd30/office2007sp1-kb936982-fullfile-zh-cn.exe
sp2补丁地址(301 MB):
http://download.microsoft.com/download/A/3/9/A39E919E-AFA8-4128-9249-51629206C70F/office2007sp2-kb953195-fullfile-zh-cn.exe
给项目添加组件引用,如图:
使用代码:
MODI.Document doc = new MODI.Document();
doc.Create(img_Path);
MODI.Image image;
MODI.Layout layout;
doc.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true); // 识别简体中文
for (int i = 0; i < doc.Images.Count; i++)
{
image = (MODI.Image)doc.Images[i];
layout = image.Layout;
sb.Append(layout.Text);
}
MessageBox.Show(sb.ToString());
其中img_Path为图片路径,MODI.MiLANGUAGES为读取图片的文字类型枚举。
本文源码下载地址:http://files.cnblogs.com/stone_w/OCR.rar
本文出自:钱大宝的博客地,地址:http://www.qiandabao.com/cxrs/1173.html,转载须注明!
- C#图片文字识别
- C#图片文字识别
- 图片文字识别
- 图片文字识别
- Tess4J图片文字识别
- Java 图片文字识别
- 识别图片中的文字
- java图片识别文字
- 图片文字识别的问题
- 用CAJViewer识别图片文字
- 如何识别图片中的文字
- Android 图片识别文字APP
- 如何识别图片中的文字
- java图片文字识别技术
- tess4j识别图片中的文字
- tess_two Android图片文字识别
- Tesseract-ocr-图片文字识别
- 互联网图片文字识别 互联网图片识别 彩信识别 彩信图片文字识别
- osx下信号量和锁无法使用的替代品
- 如何通俗理解递归
- 汇编从0开始(7)
- Matlab 图像平移、旋转、缩放、镜像
- 众觅,让支付宝『到位』全国到位!共享经济下人人互助
- C#图片文字识别
- IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)
- 【C#小工具】百度网盘不限速下载工具。源码下载
- 自定义Dialog
- Session().getCriteriaBuilder()
- 如何将arm log从usb切换到uart出来(展讯)
- 最清晰的Android多屏幕适配方案
- 输入输出流-实现复制文件
- spring mvc 返回json中去除null字段