第一步:下载老马哥的从 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. 为什么要编译Linux内核?

    新的内核修订了旧内核的bug,并增加了许多新的特性.如果用户想要使用这些新特性,或想根据自己的系统度身定制一个更高效,更稳定的内核,就需要重新编译Linux内核. 通常,更新的内核会支持更多的硬件,具 ...

  2. Linux学习之Vim/Vi使用(十三)

    Linux学习之Vim/Vi使用 Vim/Vi简介 Vim/Vi工作模式 Vim/Vi基本使用 Vim/Vi应用技巧 Vim/Vi简介 Vim/Vi是一个功能强大的全屏幕文本编辑器,是Linux/UN ...

  3. Linux学习之常用文件处理命令(一)

    (一)文件命名规则 (二)常用文件处理命令 1.ls命令 2.cd命令 3.pwd命令 4.mkdir命令 5.touch命令 6.cp命令 7.mv命令 8.rm命令 9.cat命令 10.more ...

  4. css实现幻灯片播放效果

    用css实现幻灯片播放是最基础的,闲下来没事就试着写了一下,如果有不够完善或者方法不好的地方还请指点.下面我就用两种方法实现css花灯片效果. 方法1:定位.通过position属性改变left值 h ...

  5. 机器学习数据处理时label错位对未来数据做预测

    这篇文章继上篇机器学习经典模型简单使用及归一化(标准化)影响,通过将测试集label(行)错位,将部分数据作为对未来的预测,观察其效果. 实验方式 以不同方式划分数据集和测试集 使用不同的归一化(标准 ...

  6. Java—集合框架详解

    一.描述Java集合框架 集合,在Java语言中,将一系类的对象看成一个整体. 首先查看jdk中的Collection类的源码后会发现Collection是一个接口类,其继承了java迭代接口Iter ...

  7. VB.NET 编程元素支持更改总结

    Visual Basic 2005 更改了它支持各种编程元素的方式,主要是为了提供与公共语言运行库的互操作性.许多 Visual Basic 6.0 元素被重新命名,重新分类或与 Visual Bas ...

  8. 【漏洞复现】ES File Explorer Open Port Vulnerability - CVE-2019-6447

    漏洞描述 在受影响的ES文件浏览器上,会启用59777/tcp端口作为HTTP服务器,攻击者只需要构造恶意的json请求就可以对受害者进行文件下载,应用打开.更可以用过漏洞进行中间人(MITM)攻击. ...

  9. docker 安装 nginx

    docker pull nginx docker run -d -p 80:80 -v /opt/nginx/www/:/usr/share/nginx/html/  --name webserver ...

  10. android textview使用ttf字体显示图片

    最近在研究一个组件时,发现使用textview显示了一张图片,原以为android原生支持,仔细研究了下,是用ttf字体实现的,记录下 网上的介绍文章很多,这里就不啰嗦了,链接 https://www ...