第一步:下载老马哥的从 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文件的文字的更多相关文章

  1. 基于Python实现对PDF文件的OCR识别

    http://www.jb51.net/article/89955.htm https://pythontips.com/2016/02/25/ocr-on-pdf-files-using-pytho ...

  2. 【程序员的吃鸡大法】利用OCR文字识别+百度算法搜索,玩转冲顶大会、百万英雄、芝士超人等答题赢奖金游戏

    [先上一张效果图]: 一.原理: 其实原理很简单: 1.手机投屏到电脑: 2.截取投屏画面的题目部分,进行识别,得到题目和三个答案: 3.将答案按照一定的算法,进行搜索,得出推荐答案: 4.添加了一些 ...

  3. 深入学习OpenCV文档扫描及OCR识别(文档扫描,图像矫正,透视变换,OCR识别)

    如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice 下面 ...

  4. 利用OCR文字识别+百度算法搜索,玩转冲顶大会、百万英雄、芝士超人等答题赢奖金游戏

    [先上一张效果图]: 一.原理: 其实原理很简单: 1.手机投屏到电脑: 2.截取投屏画面的题目部分,进行识别,得到题目和三个答案: 3.将答案按照一定的算法,进行搜索,得出推荐答案: 4.添加了一些 ...

  5. 身份证扫描识别/身份证OCR识别的正确姿势,你get到了吗?

    自从国家规定电信实名制之后,实名制已经推广到各个领域:办理通信业务需要实名制.银行开户需要实名制.移动支付需要实名制,就连注册个自媒体账户都需要实名制. 而实名制的背后,就是身份证信息的采集和录入验证 ...

  6. 汽车VIN码识别/汽车车架号OCR识别,移动端VIN码识别,OCR扫描工具

    本文推荐了一项汽车VIN码自动识别技术,用户通过手机“扫一扫”的简单操作,就可以快速识别VIN码,查询到车辆的详细信息,为汽修汽配.二手车交易.车辆监管.查勘理赔提高工作效率. VIN是英文Vehic ...

  7. 全能扫描王(一款识别率超高的OCR识别APP)

    前言 无论是在工作还是日常生活中,我们都会经常遇到,需要将一些纸质资料上的文字内容变成电子文档进行编辑.这个时候就需要拥有一款好用的手机扫描+OCR文字识别功能的应用了. 随着人工智能的兴起,我们都在 ...

  8. 基于Tesseract的OCR识别小程序

    一.背景 先说下开发背景,今年有次搬家找房子(2020了应该叫去年了),发现每天都要对着各种租房广告打很多电话.(当然网上也找了实地也找),每次基本都是对着墙面看电话号码然后拨打,次数一多就感觉非常麻 ...

  9. 发票OCR识别/票据OCR自动识别

    对于一些大的集团公司来说,分散式财务管理模式管理效率不高,管理成本相对较高,同时也制约了集团企业发展战略的实施,因而需要建设财务共享中心.一个企业想建造财务共享中心,面临的难题是大量的数据采集和信息处 ...

随机推荐

  1. 洛谷 P1757 通天之分组背包 【分组背包】

    题目链接:https://www.luogu.org/problemnew/show/P1757#sub 题目描述 自01背包问世之后,小A对此深感兴趣.一天,小A去远游,却发现他的背包不同于01背包 ...

  2. lintcode 最大子数组III

    题目描述 给定一个整数数组和一个整数 k,找出 k 个不重叠子数组使得它们的和最大.每个子数组的数字在数组中的位置应该是连续的. 返回最大的和. 注意事项 子数组最少包含一个数 样例 给出数组 [-1 ...

  3. Excel获取第一个表名

    Excel.Worksheet wsheet1 = (Excel.Worksheet)excelSql.Worksheets.get_Item(); wsheet1.Name获取sheet名称

  4. BZOJ.1935.[SHOI2007]Tree园丁的烦恼(CDQ分治 三维偏序)

    题目链接 矩形查询可以拆成四个点的前缀和查询(树套树显然 但是空间不够) 每个操作表示为(t,x,y),t默认有序,对x分治,y用树状数组维护 初始赋值需要靠修改操作实现. //119964kb 43 ...

  5. 微信企业号开发之weixin://preInjectJSBridge/fail

    最近几天遇到个奇怪的问题,目前只有在Andriod平台上出现:weixin://preInjectJSBridge/fail 不止我一个人遇到这个问题,群里也有好几个问了这个问题.这个问题直接导致我们 ...

  6. Oracle 11g透明网关连接Sqlserver 2000(转)

    Oracle 11g透明网关连接Sqlserver 2000: http://www.cnblogs.com/lightnear/archive/2013/02/03/2890858.html 透明网 ...

  7. Oozie分布式工作流——从理论和实践分析使用节点间的参数传递

    Oozie支持Java Action,因此可以自定义很多的功能.本篇就从理论和实践两方面介绍下Java Action的妙用,另外还涉及到oozie中action之间的参数传递. 本文大致分为以下几个部 ...

  8. java知识思维图解

  9. C# Dictionary, SortedDictionary, SortedList

    就我个人觉得Dictionary, SortedDictionary, SortedList 这几个类的使用是比较简单的,只要稍微花点时间在网上查找一点资料,然后在阅读以下源码就理解的很清楚了.为什么 ...

  10. .net源码调试 http://referencesource.microsoft.com/

    其实关于.net源码调试 网上的资料已经很多了,我以前转载的文章有 VS2010下如何调试Framework源代码(即FCL) 和 如何使你的应用程序调试进.NET Framework 4.5源代码内 ...