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

C# PaddleDetection yolo 印章检测

效果

项目

代码

using OpenCvSharp;
using OpenCvSharp.Extensions;
using Sdcb.PaddleDetection;
using Sdcb.PaddleInference;
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;namespace PaddleDetection印章检测
{public partial class Form1 : Form{public Form1(){InitializeComponent();}Bitmap bmp;string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string img = "";double fontScale = 4D;int thickness = 4;LineTypes lineType = LineTypes.Link4;PaddleConfig paddleConfig;PaddleDetector d;String startupPath;float confidence = 0.90f;DateTime dt1 = DateTime.Now;DateTime dt2 = DateTime.Now;StringBuilder sb = new StringBuilder();private void Form1_Load(object sender, EventArgs e){startupPath = Application.StartupPath;paddleConfig = PaddleConfig.FromModelDir(startupPath + "\\model\\");string configYmlPath = startupPath + "\\model\\infer_cfg.yml";d = new PaddleDetector(paddleConfig, configYmlPath, PaddleDevice.Mkldnn());}private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;img = ofd.FileName;bmp = new Bitmap(img);pictureBox1.Image = new Bitmap(img);textBox1.Text = "";}private void button2_Click(object sender, EventArgs e){if (img == ""){return;}sb.Clear();Mat src = Cv2.ImRead(img);dt1 = DateTime.Now;DetectionResult[] r = d.Run(src);dt2 = DateTime.Now;Scalar scalar;for (int i = 0; i < r.Length; i++){if (r[i].Confidence > confidence){scalar = Scalar.RandomColor();Cv2.Rectangle(src, r[i].Rect, scalar, 4, LineTypes.Link8, 0);Cv2.PutText(src, r[i].LabelName + "(" + r[i].Confidence + ")", new OpenCvSharp.Point(r[i].Rect.X + r[i].Rect.Width / 2, r[i].Rect.Y + r[i].Rect.Height / 2), HersheyFonts.HersheyComplex, fontScale, scalar, thickness, lineType, false);sb.AppendLine(string.Format("{0}({1}) ({2},{3},{4},{5})",r[i].LabelName, r[i].Confidence, r[i].Rect.Left, r[i].Rect.Top, r[i].Rect.Right, r[i].Rect.Bottom));}}sb.AppendLine("耗时:" + (dt2 - dt1).TotalMilliseconds + "ms");textBox1.Text = sb.ToString();pictureBox2.Image = BitmapConverter.ToBitmap(src);}}
}

Demo下载

http://www.lryc.cn/news/150533.html

相关文章:

  • 常用框架分析(7)-Flutter
  • 清空 Docker 容器的日志文件
  • 01-虚拟机安装Windows Server操作系统
  • 应用案例 | 基于三维机器视觉的机器人麻袋拆垛应用解决方案
  • 1018 Public Bike Management 结题记录(dfs剪枝)
  • C++ deque底层原理
  • 打破对ChatGPT的依赖以及如何应对ChatGPT的错误和幻觉
  • 【git】【IDEA】在idea中使用git
  • 【设计模式】装饰者模式
  • open cv快速入门系列---数字图像基础
  • 基础知识回顾:借助 SSL/TLS 和 NGINX 进行 Web 流量加密
  • iPhone 14 Plus与iPhone 14 Pro:你应该买哪一款
  • 操作系统清华同步笔记:定义概述+计算机内存和硬盘布局+启动流程顺序+中断、异常和系统调用
  • uniapp 配置并使用 VueX
  • vue v-on 艾特@
  • 【Ajax】发送跨域的POST请求时,浏览器会先发送一次OPTIONS请求,然后才发送原本的POST请求
  • np.numpy, np.reshape, np.cumsum方法速查
  • 七、Kafka-Kraft 模式
  • jvm开启远程调试功能;idea远程debug
  • 视频汇聚/视频云存储/视频监控管理平台EasyCVR视频平台添加萤火云设备的具体操作步骤
  • vue 加载图片不显示
  • Java for循环每次都通过list.size()和 string.length()获取大小性能
  • 面试题 08.01. 三步问题
  • springboot添加SSL证书,支持https与http
  • 【AI】《动手学-深度学习-PyTorch版》笔记(二十):图像增强、微调
  • Vulnhub: Ragnar Lothbrok: 1靶机
  • Ubuntu 20.04 Server配置网络
  • jmeter 线程组
  • springboot集成logback
  • 【从互联网商业思维的角度分析商业模式在国内各大互联网产品的运用】