[C#]使用OpenCvSharp实现二维码图像增强超分辨率

【官方框架地址】

github.com/shimat/opencvsharp

【算法介绍】

借助于opencv自带sr.prototxt和sr.caffemodel实现对二维码图像增强

【效果展示】

【实现部分代码】

复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FIRC;
using OpenCvSharp;

namespace FIRC
{
    public partial class Form1 : Form
    {
        Mat src = new Mat();
        QRManager qm = new QRManager();

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "图文件(*.*)|*.jpg;*.png;*.jpeg;*.bmp";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Multiselect = false;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
              
                src = Cv2.ImRead(openFileDialog.FileName);
                pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src);


            }


        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(pictureBox1.Image==null)
            {
                return;
            }
            var resultMat = qm.Inference(src);
            pictureBox2.Image= OpenCvSharp.Extensions.BitmapConverter.ToBitmap(resultMat); //Mat转Bitmap
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           
        }
    }
}

【源码下载】

https://download.csdn.net/download/FL1623863129/88705091

【测试环境】

vs2019 netframework4.7.2和opencvsharp4.8.0

相关推荐
呼啦啦啦啦啦啦啦啦6 分钟前
synchronized锁,ReentrantLock 锁
开发语言·
听风的码1 小时前
Vue2封装Axios
开发语言·前端·javascript·vue.js
素界UI设计2 小时前
建筑行业变革:用Three.js构建BIM数据可视化孪生平台
开发语言·javascript·信息可视化
王廷胡_白嫖帝2 小时前
Qt个人通讯录项目开发教程 - 从零开始构建联系人管理系统
开发语言·qt
疯狂的代M夫3 小时前
C++对象的内存布局
开发语言·c++
mit6.8244 小时前
Linux下C#项目构建
开发语言·c#
群联云防护小杜4 小时前
从一次 DDoS 的“死亡回放”看现代攻击链的进化
开发语言·python·linq
霸敛4 小时前
好家园房产中介网后台管理完整(python+flask+mysql)
开发语言·python·flask
Momentary_SixthSense4 小时前
RESP协议
java·开发语言·javascript·redis·后端·python·mysql
Nita.5 小时前
.NET 中的延迟初始化:Lazy<T> 与LazyInitializer
c#·.net