当前位置: 首页 > wzjs >正文

怎么做网站公司宣传资料外贸推广营销公司

怎么做网站公司宣传资料,外贸推广营销公司,南京企业网站建设,做网站 0元代理一、前言 通过查看网络资料以及书籍资料,发现大多数OCR识别功能都是基于Python语言开发的,对于习惯使用C# 开发语言的程序猿们,岂不是一件很苦恼的事!当然想学习Python,掌握多一项技能也并不是坏事!为了方…

一、前言

通过查看网络资料以及书籍资料,发现大多数OCR识别功能都是基于Python语言开发的,对于习惯使用C# 开发语言的程序猿们,岂不是一件很苦恼的事!当然想学习Python,掌握多一项技能也并不是坏事!为了方便使用,想使用C# 的往下看(或需要使用当作工作辅助也行,资源下载在最后有链接)。

二、开发要求

1、图形处理库Clipper、Emgu.CV
2、高性能推理引擎 Microsoft.ML.OnnxRuntime
3、借用PaddleOCR模型
4、现有功能,选择照片识别、截图识别,选择PDF文件识别

三、部分代码

using Emgu.CV;
using OcrDemo.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace OcrDemo
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private string fileFilter = "所有文件 (*.*)|*.*|bmp|*.bmp|jpg|*.jpg|jpeg|*.jpeg|png|*.png";private Bitmap bmp;  private string outPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "output");private Stopwatch stopwatch = new Stopwatch();private string filePath = "";private int threadNum = 4;private OcrLite ocrEngin;private void Form1_Load(object sender, EventArgs e){try{if (!Directory.Exists(outPath)){Directory.CreateDirectory(outPath);}splitContainer1.SplitterDistance = (int)(splitContainer1.Width * 0.5);splitContainer2.SplitterDistance = (int)(splitContainer2.Width * 0.5);string appPath = AppDomain.CurrentDomain.BaseDirectory;string appDir = Directory.GetParent(appPath).FullName;}catch (Exception ex){SetMessge(ex.Message);}}private void SetMessge(string info, int infoType = 0){//info = DataHelper.DateFormat(DateTime.Now) + "" + info + "\n";info =  info + "\n";if (this.InvokeRequired){// 如果需要跨线程调用,则使用 Invoke 方法this.Invoke(new Action(() =>{rTB_Message.AppendText(info);// 滚动文本框以使光标所在位置可见//rTB_ResultInfo.ScrollToCaret();// 选中插入点rTB_Message.Focus();}));}else{// 如果在 UI 线程中,则直接更新控件rTB_Message.AppendText(info);// 滚动文本框以使光标所在位置可见//rTB_ResultInfo.ScrollToCaret();// 选中插入点rTB_Message.Focus();}}private void tool_bt_select_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() == DialogResult.OK){Application.DoEvents();filePath = ofd.FileName;var imagebyte = File.ReadAllBytes(filePath);bmp = new Bitmap(new MemoryStream(imagebyte));pictureBox1.Image = bmp;rTB_Message.Clear();if (bmp == null) return;stopwatch.Restart();OcrResult ocrResult = ocrEngin.Detect(filePath, padding, imgResize, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle);stopwatch.Stop();SetMessge(ocrResult.StrRes);SetMessge("------------------------------");//SetMessge(ocrResult.ToString());SetMessge($"--------------耗时: {stopwatch.ElapsedMilliseconds} 毫秒----------------");pictureBox2.Image = ocrResult.BoxImg.ToBitmap();}}private void tool_bt_screenshot_Click(object sender, EventArgs e){this.Hide();System.Threading.Thread.Sleep(200);Application.DoEvents();ScreenCapturer.ScreenCapturerTool screenCapturer = new ScreenCapturer.ScreenCapturerTool();if (screenCapturer.ShowDialog() == DialogResult.OK){bmp = (Bitmap)screenCapturer.Image;string newFiles = outPath+"\\" + DataHelper.GetTimestamp() + ".jpg";bmp.Save(newFiles, ImageFormat.Jpeg);pictureBox1.Image = bmp;try{stopwatch.Restart();OcrResult ocrResult = ocrEngin.Detect(newFiles, padding, imgResize, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle);stopwatch.Stop();SetMessge(ocrResult.StrRes);SetMessge($"--------------耗时: {stopwatch.ElapsedMilliseconds} 毫秒----------------");//SetMessge(ocrResult.ToString());pictureBox2.Image = ocrResult.BoxImg.ToBitmap();}catch (Exception ex){SetMessge(ex.Message);}}this.Show();}private void tool_bt_PDF_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = "所有文件 (*.*)|*.*|PDF|*.pdf";if (ofd.ShowDialog() == DialogResult.OK){string pdfPath = ofd.FileName;// 1. 解析PDF获取页面图像using (var document = PdfDocument.Load(pdfPath)){string firstFiles = "";stopwatch.Restart();for (int pageIndex = 0; pageIndex < document.PageCount; pageIndex++){// 渲染PDF页面为图像using (var image = document.Render(pageIndex, 400, 800, false)){string newFiles = outPath + "\\" + DataHelper.GetTimestamp() + ".jpg";if (pageIndex == 0){firstFiles = newFiles;}image.Save(newFiles, ImageFormat.Jpeg);OcrResult ocrResult = ocrEngin.Detect(newFiles, padding, imgResize, boxScoreThresh, boxThresh, unClipRatio, doAngle, mostAngle);stopwatch.Stop();SetMessge(ocrResult.StrRes);}}if (firstFiles.Length > 0){var imagebyte = File.ReadAllBytes(firstFiles);pictureBox1.Image = new Bitmap(new MemoryStream(imagebyte));}//SetMessge(ocrResult.ToString());SetMessge($"--------------耗时: {stopwatch.ElapsedMilliseconds} 毫秒----------------");}}}}
}

四、效果展示

C#之OCR识别

(图一为屏幕截图识别,图二为动车票信息识别)

五、资源下载

链接:https://download.csdn.net/download/weixin_42148410/90827048

http://www.dtcms.com/wzjs/287284.html

相关文章:

  • 温州网站专业制作全网搜索软件下载
  • wordpress阅读随机增加许昌正规网站优化公司
  • 网站不备案不能用吗手机网页链接制作
  • 郑州做网站公司 汉狮网络专业百度指数怎么提升
  • 怎样弄一个自己的网站网站建立
  • 微商城网站建设方案浙江网站建设制作
  • 一品威客网精选seo技术最新黑帽
  • 网站建设 by祥云平台好网站制作公司
  • 零基础短视频制作培训系统优化app最新版
  • 郑州+高端网站建设百度集团总部在哪里
  • 怎么注册网自己的网站网络营销的重要性
  • 企业网站建设市场报价百度推广开户多少钱
  • 潜山网站建设谷歌浏览器app
  • 什么建站平台好seo推广方案
  • 自己做的网站怎么爬数据惠州百度seo排名
  • 网站建设与改善规划短期培训就业学校
  • 重庆网站建设就选承越如何搜索网页关键词
  • 上海企业网站建设制海外广告投放公司
  • 郑州网站开发比较好的网络公司千锋教育前端学费多少
  • 网站支付怎么做安全吗seo怎么才能优化好
  • 建设银行网站登录首页百度账号查询
  • 做网站哪个便宜seo排名的影响因素有哪些
  • 做公众号用什么网站吗北京最新疫情
  • wordpress博客福利网整站源码免费合作推广
  • 苏州知名高端网站建设网络公司长春seo排名
  • 如何让网站不被收录seo优化轻松seo优化排名
  • 泗水做网站seo优化排名技术百度教程
  • wordpress 插件 前端win7优化工具哪个好用
  • 广州网站优化系统域名注册信息查询
  • 啥网站都能看的浏览器快手seo