资源简介
该程序采用VS2010 通过OCR来识别0-9 包含小数点的数字识别。程序中包含样图。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using tessnet2;
using System.Drawing.Imaging;
using System.IO;
namespace OCRText
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
textBox1.Text = ““;
Bitmap s;
Bitmap img = ZoomAuto(textBox2.Text 1000 1000 out s) as Bitmap;
pictureBox1.Image = s;
Tesseract ocr = new Tesseract();
ocr.SetVariable(“tessedit_char_whitelist“ “0123456789.“);
ocr.Init(AppDomain.CurrentDomain.baseDirectory + “Language“ “eng“ false);
List result = ocr.DoOCR(img Rectangle.Empty);
foreach (Word item in result)
{
textBox1.Text += item.Text;
}
img.Dispose();
}
///
/// 等比例缩放图片
///
///
///
///
///
///
public static Image ZoomAuto(string fromFile System.Double targetWidth System.Double targetHeight out Bitmap img)
{
//原始图片(获取原始图片创建对象,并使用流中嵌入的颜色管理信息)
System.Drawing.Image initImage = Image.FromFile(fromFile);
img = new Bitmap(initImage);
double newWidth = initImage.Width;
double newHeight = initImage.Height;
//宽大于高或宽等于高(横图或正方)
if (initImage.Width >= initImage.Height)
{
newWidth = targetWidth;
newHeight = initImage.Height * (targetWidth / initImage.Width);
}
//高大于宽(竖图)
else
{
newHeight = targetHeight;
newWidth = initImage.Width * (targetHeight / initImage.Height);
}
//生成新图
//新建一个bmp图片
System.Drawing.Image newImage = new System.Drawing.Bitmap((int)newWidth (int)newHeight);
//新建一个画板
System.Drawing.Graphics newG = System.Drawing.Graphics.FromImage(newImage);
//设置质量
newG.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
newG.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//置背景色
newG.Clear(Color.White);
//画图
newG.DrawImage(initImage new System.Drawing.Rectangle(0 0 newImage.Width newImage.Height) new System.Drawing.Rectangle(0 0 initImage.Width initImage.Height) System.Drawing.GraphicsUnit.Pixel);
newG.
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1525 2019-10-21 13:19 obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6926 2019-10-21 13:20 obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 898 2013-03-13 14:55 obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
文件 1338 2013-03-13 14:55 obj\x86\Debug\GenerateResource-ResGen.write.1.tlog
文件 3541 2019-10-21 13:20 obj\x86\Debug\OCRText.csproj.FileListAbsolute.txt
文件 774 2019-10-21 13:20 obj\x86\Debug\OCRText.csproj.GenerateResource.Cache
文件 7466 2019-10-21 13:16 obj\x86\Debug\OCRText.csprojResolveAssemblyReference.cache
文件 10752 2019-10-21 13:20 obj\x86\Debug\OCRText.exe
文件 180 2019-10-21 13:20 obj\x86\Debug\OCRText.Form1.resources
文件 26112 2019-10-21 13:20 obj\x86\Debug\OCRText.pdb
文件 180 2019-10-21 13:20 obj\x86\Debug\OCRText.Properties.Resources.resources
文件 2 2013-03-13 14:55 obj\x86\Debug\ResGen.read.1.tlog
文件 2 2013-03-13 14:55 obj\x86\Debug\ResGen.write.1.tlog
文件 8605 2013-03-13 14:55 obj\x86\Debug\ResolveAssemblyReference.cache
文件 4608 2019-10-21 15:17 obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 1370 2012-05-31 17:12 Properties\AssemblyInfo.cs
文件 2854 2019-10-21 13:20 Properties\Resources.Designer.cs
文件 5612 2012-05-31 17:14 Properties\Resources.resx
文件 1107 2019-10-21 13:20 Properties\Settings.Designer.cs
文件 249 2012-05-31 17:12 Properties\Settings.settings
文件 146 2013-02-22 00:57 实例图片\1.png
文件 164 2013-02-22 00:58 实例图片\2.png
文件 274 2013-02-22 01:31 实例图片\3.png
文件 142 2013-02-22 01:25 实例图片\4.png
文件 159 2013-02-22 01:25 实例图片\5.png
文件 165 2013-02-20 01:00 实例图片\6.png
文件 117 2019-10-21 13:20 app.config
文件 3307 2019-10-21 11:06 Form1.cs
文件 5443 2019-10-21 11:06 Form1.Designer.cs
文件 5817 2019-10-21 11:06 Form1.resx
............此处省略33个文件信息
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
评论
共有 条评论