第一步:下载老马哥的从 office和sharepoint 提取出来的注册表和dll http://115.com/file/dpa4qrt2
或者直接安装office和sharepoint2007
第二步:下载我的demo http://files.cnblogs.com/0banana0/OCR.zip
***识别度不是百分之百的 当然需要校准啦 在 编辑器里边修改错误的东西 !
第三步:发布
本地环境无措 发布到iis包错 “Object hasn't been initialized and can't be used yet”
解决办法:Go to IIS->ApplicatioPools->Default Applicationpool->Identity->custom account->Give the user name and password.
****发布的时候 iis还报一个错:Compiler Error Message: CS0016拒绝访问
解决办法:给c:\windows\temp 加上 network service (只加这个我的不行)和 iis_iusrs(后来加上和这个才行)权限
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using System.IO;
using System.Text;
using ContractManage.DAL;
using System.Threading;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; namespace ContractManage.uploadify
{
/// <summary>
/// Summary description for OCR
/// </summary>
public class OCR : IHttpHandler
{
private MODI.Document _document;
private MODI.Images _images;
private MODI.Image _image;
private MODI.Layout _layout;
private ManualResetEvent _completedOCR = new ManualResetEvent(false);
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (!string.IsNullOrEmpty(context.Request.QueryString["cid"]))
{
string cid = context.Request.QueryString["cid"];
string sPath = context.Server.MapPath("uploadify");
string path = sPath.Substring(, sPath.Length - ) + "\\OCRFile\\" + cid;
CheckFileType(path, cid);
}
context.Response.Write(" ");
} public void CheckFileType(string directoryPath, string cid)
{
IEnumerator files = Directory.GetFiles(directoryPath).GetEnumerator();
while (files.MoveNext())
{
//get file extension
string fileExtension = Path.GetExtension(Convert.ToString(files.Current)); //get file path without extenstion
string filePath = Convert.ToString(files.Current).Replace(fileExtension, string.Empty); //get fileName
string fileName = Path.GetFileName(Convert.ToString(files.Current));
//Check for JPG File Format
if (fileExtension == ".jpg" || fileExtension == ".JPG" || fileExtension == ".tif" || fileExtension == ".tiff") // or // ImageFormat.Jpeg.ToString()
{
try
{
//OCR Operations ...
MODI.Document _document = new MODI.Document();
_document.OnOCRProgress += new MODI._IDocumentEvents_OnOCRProgressEventHandler(_document_OnOCRProgress);
_document.Create(Convert.ToString(files.Current));
_document.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true); _completedOCR.WaitOne();
//_document.Save(); _images = _document.Images;
_image = (MODI.Image)_images[];
//FileStream createFile = new FileStream(filePath + ".txt", FileMode.CreateNew);
//StreamWriter writeFile = new StreamWriter(createFile);
_layout = _image.Layout;
string strContent = _layout.Text;
_document.Close(false);
//string strPath = "uploadify/OCRFile/" + cid + "/" + fileName;
//string strContent = "没有内容";
string strPath = "uploadify/OCRFile/" + cid + "/" + fileName;
SaveDate(strPath, strContent, cid);
//writeFile.Write(strContent);
//writeFile.Close(); }
catch (Exception ex)
{
throw ex;
//MessageBox.Show("This Image hasn't a text or has a problem",
//"OCR Notifications",
//MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
} }
}
}
void _document_OnOCRProgress(int Progress, ref bool Cancel)
{
if (Progress == )
{
_completedOCR.Set();
}
}
private static void SetComObjectToNull(params object[] objects)
{
for (int i = ; i < objects.Length; i++)
{
object o = objects[i];
if (o != null)
{
Marshal.FinalReleaseComObject(o);
o = null;
}
}
} [MethodImpl(MethodImplOptions.NoInlining)]
public void Dispose()
{
SetComObjectToNull(_layout, _image, _images, _document);
GC.Collect();
GC.WaitForPendingFinalizers();
} public void SaveDate(string strPath, string strContent, string cid)
{
try
{
Pt_ContractImg img = new Pt_ContractImg();
img.Content = strContent;
img.Path = strPath;
img.ContractID = Convert.ToInt32(cid);
Pt_ContractImg_DAO.Insert(img);
}
catch (Exception ex)
{ }
finally
{ }
}
public bool IsReusable
{
get
{
return false;
}
} }
}
利用OCR识别扫描的jpg、tif文件的文字的更多相关文章
-
基于Python实现对PDF文件的OCR识别
http://www.jb51.net/article/89955.htm https://pythontips.com/2016/02/25/ocr-on-pdf-files-using-pytho ...
-
【程序员的吃鸡大法】利用OCR文字识别+百度算法搜索,玩转冲顶大会、百万英雄、芝士超人等答题赢奖金游戏
[先上一张效果图]: 一.原理: 其实原理很简单: 1.手机投屏到电脑: 2.截取投屏画面的题目部分,进行识别,得到题目和三个答案: 3.将答案按照一定的算法,进行搜索,得出推荐答案: 4.添加了一些 ...
-
深入学习OpenCV文档扫描及OCR识别(文档扫描,图像矫正,透视变换,OCR识别)
如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice 下面 ...
-
利用OCR文字识别+百度算法搜索,玩转冲顶大会、百万英雄、芝士超人等答题赢奖金游戏
[先上一张效果图]: 一.原理: 其实原理很简单: 1.手机投屏到电脑: 2.截取投屏画面的题目部分,进行识别,得到题目和三个答案: 3.将答案按照一定的算法,进行搜索,得出推荐答案: 4.添加了一些 ...
-
身份证扫描识别/身份证OCR识别的正确姿势,你get到了吗?
自从国家规定电信实名制之后,实名制已经推广到各个领域:办理通信业务需要实名制.银行开户需要实名制.移动支付需要实名制,就连注册个自媒体账户都需要实名制. 而实名制的背后,就是身份证信息的采集和录入验证 ...
-
汽车VIN码识别/汽车车架号OCR识别,移动端VIN码识别,OCR扫描工具
本文推荐了一项汽车VIN码自动识别技术,用户通过手机“扫一扫”的简单操作,就可以快速识别VIN码,查询到车辆的详细信息,为汽修汽配.二手车交易.车辆监管.查勘理赔提高工作效率. VIN是英文Vehic ...
-
全能扫描王(一款识别率超高的OCR识别APP)
前言 无论是在工作还是日常生活中,我们都会经常遇到,需要将一些纸质资料上的文字内容变成电子文档进行编辑.这个时候就需要拥有一款好用的手机扫描+OCR文字识别功能的应用了. 随着人工智能的兴起,我们都在 ...
-
基于Tesseract的OCR识别小程序
一.背景 先说下开发背景,今年有次搬家找房子(2020了应该叫去年了),发现每天都要对着各种租房广告打很多电话.(当然网上也找了实地也找),每次基本都是对着墙面看电话号码然后拨打,次数一多就感觉非常麻 ...
-
发票OCR识别/票据OCR自动识别
对于一些大的集团公司来说,分散式财务管理模式管理效率不高,管理成本相对较高,同时也制约了集团企业发展战略的实施,因而需要建设财务共享中心.一个企业想建造财务共享中心,面临的难题是大量的数据采集和信息处 ...
随机推荐
-
从零开始学iPhone开发(1)——工具的使用
前提:已经具备了苹果电脑或者iMac,或者安装好了x86苹果而且已经联网. 苹果系统版本要求是:Max OS X Lion,或者 Mountain Lion 我们对iPhone进行使用的工具是XCod ...
-
QR二维码生成器源码(中间可插入小图片)
二维码终于火了,现在大街小巷大小商品广告上的二维码标签都随处可见,而且大都不是简单的纯二维码,而是中间有个性图标的二维码. 我之前做了一个使用google开源项目zxing实现二维码.一维码编码解码的 ...
-
[Flex] as3xls读取excel,修改保存单表(二)
这个方法仅用了as3xls读取excel的功能,修改保存独立出来了. <?xml version="1.0" encoding="utf-8"?> ...
-
oracle创建索引后sqlldr导入错误
SQL*Loader-: Error calling once/load initialization ORA-: Table TABLE_LOG has index defined upon it. ...
-
Nginx之负载均衡
转自:http://www.360doc.com/content/13/1114/12/7694408_329125489.shtml 注,大家可以看到,由于我们网站是发展初期,nginx只代理了后端 ...
-
Emacs入门快捷键
打开emacs开始一个程序最基本操作: 1.打开Emacs,执行 $ emacs 2.建立一个新的程序文件. 按C-x C-f 然后在屏幕的底部出现minibuffer,光标提示你输入文件名称, 文件 ...
-
python_冒泡算法
什么是冒泡算法? -- 像鱼吐泡泡一样,每次都是向上冒出一个水泡 如何逻辑整理? -- 先拿第一个值和剩下的值,一一比较,必能找到最大的或者最小的 -- 比较过程中,第一个值小于剩下的某个值,交换位置 ...
-
SqlServer 语法
四. Ranking 排序与排名是我们最为常用的统计方式,比如对班级的学生根据成员进行排名,或者按照成绩高低把学生划分成若干梯队:比如最好成绩的10名学生属于第一梯队,后10名又 ...
-
centos6中搭建tomcat
一.安装jdk [root@tomcat ~]# yum -y list java* Loaded plugins: fastestmirror, security Loading mirror sp ...
-
gerp , sed , awk
gerp 查找, sed 编辑, awk 根据内容分析并处理. awk(关键字:分析&处理) 一行一行的分析处理 awk '条件类型1{动作1}条件类型2{动作2}' filename, aw ...