欢迎来到传世资源网!
加载中...
正在加载,请耐心等待...
本站为收藏、学习站,如有侵权,请联系管理员删除!

OCR 图片识别

介绍 评论 失效链接反馈

OCR 图片识别.rar AspriseOCR 4.0破解dll,最后一个图的实现 需要客户机安装office
OCR 图片识别 C#图形和图像处理-第1张
OCR 图片识别 C#图形和图像处理-第2张

OCR 图片识别 C#图形和图像处理-第3张
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 ToText{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } #region DllImport [DllImport("AspriseOCR.dll", EntryPoint = "OCR", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr OCR(string file, int type); [DllImport("AspriseOCR.dll", EntryPoint = "OCRpart", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height); [DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr OCRBarCodes(string file, int type); [DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height); #endregion #region 转换按钮事件 // 转换按钮事件 private void button2_Click(object sender, EventArgs e) { int startX = 0; int startY = 0; int width = -1; int height = -1; string img_path = txt_imgpath.Text; // 图片路径 if (String.IsNullOrEmpty(img_path)) // 图片非空验证 { MessageBox.Show("请先选择图片!"); return; } try { Image img = Image.FromFile(img_path); width = img.Width; height = img.Height; } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } txt_result.Text = Marshal.PtrToStringAnsi(OCRpart(img_path, -1, startX, startY, width, height)); } #endregion #region 浏览事件 // 浏览事件 private void btn_imgpath_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); txt_imgpath.Text = openFileDialog1.FileName; } // 浏览图片 private void txt_imgpath_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); txt_imgpath.Text = openFileDialog1.FileName; } #endregion private void btnChange_Click(object sender, EventArgs e) { try { System.Drawing.Image image = System.Drawing.Bitmap.FromFile(txt_imgpath.Text); txt_result.Text = Marshal.PtrToStringAnsi(OCRBarCodes(txt_imgpath.Text, -1)); //将返回string,并以"\r\n"结尾!!; } catch (Exception ex) { this.txt_result.Text = ex.Message; } } }}

下载声明:

本站资源均有第三方用户自行上传分享推荐,非本站自制,仅供玩家做交流学习之用!切勿用于商业用途!游戏作品版权归原作者享有,如有版权问题,请附带版权证明至邮件,本平台将应您的要求删除。
相关推荐:

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复