请问:如何将本来由字符串生成的图片转成字符串呢? 如:,请问怎样把图片里的价格转成字符串格式呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我勒个去啊,参考各种OCR算法 图像识别http://topic.csdn.net/u/20100622/15/f8c2f833-99a0-495e-b2ab-44fed5314d8a.html http://www.codeproject.com/KB/recipes/OCR-Chain-Code.aspxOCR识别技术 http://www.cnblogs.com/chiname/articles/199856.htmlhttp://download.csdn.net/source/1830710一个源码 光学 o文字 c识别 r 一般的OCR都可以识别这种简单的 我使用的OCR是Google的tessnet2:string results = "";//string datapath = @"D:\temp\tessdata\eng";Bitmap image = new Bitmap("C:\\ctl\\1.png");tessnet2.Tesseract ocr = new tessnet2.Tesseract();ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // 如果只是数字//ocr.Init(datapath, "fra", false); // 使用的语言库ocr.Init(null, "eng", false);List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);foreach (tessnet2.Word word in result) results += string.Format("{0}", word.Text);Response.Write(results);上面的代码基本是按他官方的代码,但还是不能准确识别出来!? 又试用了一下AspriseOCR.dll,还是没有很好的识别出来 我用AspriseOCR测试的非常好,识别数字100%准且,只是没有识别出¥符号~~~ http://space.itpub.net/23109131/viewspace-687685 使用AspriseOCR做了个测试,识别很好。用office组件测试的文件识别率太低!简直无法使用。楼主还是用AspriseOCR来测试吧。附:测试全部代码:窗体上textBox1显示文件名,button1打开文件,picturebox1显示打开的图片,textBox2显示识别的文字。测试正常可用。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 System.Runtime.InteropServices;namespace 测试效果{ public partial class ASOCR : Form { public ASOCR() { InitializeComponent(); } [DllImport("AspriseOCR.dll", EntryPoint = "OCR")] public static extern IntPtr OCR(string file, int type); [DllImport("AspriseOCR.dll", EntryPoint = "OCRpart")] static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height); [DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes")] static extern IntPtr OCRBarCodes(string file, int type); [DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes")] static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height); private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "图像文件(*.jpg,*.bmp,*.gif,*.png,*.tif)|*.jpg;*.bmp;*.gif;*.png;*.tif"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { textBox1.Text = ofd.FileName; pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; pictureBox1.Image = Image.FromFile(ofd.FileName, false); textBox2.Text = Marshal.PtrToStringAnsi(OCR(ofd.FileName, -1)); } } }} 希望能将你的代码放出来?我试了真不不行¥638.00变成了Y 6 n.oo,试了几个也差不多protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetVeryfyCode("C:\\ctl\\1.png"); } } [DllImport("D:\\pd\\Web\\Bin\\AspriseOCR.dll")] static extern string OCR(string file, int type); private void GetVeryfyCode(string _imgPath) { string _veryfyCode; if (File.Exists(_imgPath))//ok now? { try { //this.picbVeryfyCode.Image = System.Drawing.Bitmap.FromFile(_imgPath); _veryfyCode = OCR(_imgPath, -1); //将返回string,并以"\r\n"结尾!! //_veryfyCode = _veryfyCode.Substring(0, 4); this.Label1.Text = _veryfyCode; } catch (Exception e) { //MessageBox.Show(e.Message.ToString()); throw e; } } } 很诡异的画图板问题,你遇到过吗? 写法问题 再问备份远程服务器的数据库到client端,再不使用扩展性型存储过程的前提下,直接备份啊,有高人教教我,很急啊 关于得到应用程序路径的上一级全路径 问题已经发给你了 关于动态生成DataGrid列后的问题 谁能给个利用数字证书,进行数字签名的例子? 十分感谢! foreach 只循环了一次? 无法连接2005数据库 值类型、引用类型与ref关键字 有句话没看懂 请教:有谁遇到过这样的错误 Length cannot be less than zero 已经现有一段视频,该如何开发一个视频页
http://www.cnblogs.com/chiname/articles/199856.html
http://download.csdn.net/source/1830710
一个源码
文字 c
识别 r
//string datapath = @"D:\temp\tessdata\eng";
Bitmap image = new Bitmap("C:\\ctl\\1.png");
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // 如果只是数字
//ocr.Init(datapath, "fra", false); // 使用的语言库
ocr.Init(null, "eng", false);
List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
foreach (tessnet2.Word word in result)
results += string.Format("{0}", word.Text);
Response.Write(results);上面的代码基本是按他官方的代码,但还是不能准确识别出来!?
我用AspriseOCR测试的非常好,识别数字100%准且,只是没有识别出¥符号~~~
用office组件测试的文件识别率太低!简直无法使用。楼主还是用AspriseOCR来测试吧。附:测试全部代码:
窗体上textBox1显示文件名,button1打开文件,picturebox1显示打开的图片,textBox2显示识别的文字。测试正常可用。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 System.Runtime.InteropServices;namespace 测试效果
{
public partial class ASOCR : Form
{
public ASOCR()
{
InitializeComponent();
}
[DllImport("AspriseOCR.dll", EntryPoint = "OCR")]
public static extern IntPtr OCR(string file, int type); [DllImport("AspriseOCR.dll", EntryPoint = "OCRpart")]
static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height); [DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes")]
static extern IntPtr OCRBarCodes(string file, int type); [DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes")]
static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height);
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "图像文件(*.jpg,*.bmp,*.gif,*.png,*.tif)|*.jpg;*.bmp;*.gif;*.png;*.tif";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
textBox1.Text = ofd.FileName;
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBox1.Image = Image.FromFile(ofd.FileName, false);
textBox2.Text = Marshal.PtrToStringAnsi(OCR(ofd.FileName, -1));
}
}
}
}
希望能将你的代码放出来?
我试了真不不行¥638.00变成了Y 6 n.oo,试了几个也差不多
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetVeryfyCode("C:\\ctl\\1.png");
}
}
[DllImport("D:\\pd\\Web\\Bin\\AspriseOCR.dll")]
static extern string OCR(string file, int type);
private void GetVeryfyCode(string _imgPath)
{
string _veryfyCode;
if (File.Exists(_imgPath))//ok now?
{
try
{
//this.picbVeryfyCode.Image = System.Drawing.Bitmap.FromFile(_imgPath);
_veryfyCode = OCR(_imgPath, -1); //将返回string,并以"\r\n"结尾!!
//_veryfyCode = _veryfyCode.Substring(0, 4);
this.Label1.Text = _veryfyCode;
}
catch (Exception e)
{
//MessageBox.Show(e.Message.ToString());
throw e;
}
}
}