[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

相关推荐
阿旭超级学得完1 分钟前
C++11包装器(function和bind)
java·开发语言·c++·算法·哈希算法·散列表
輕華1 分钟前
uv工具详解——Python包与项目管理器完全指南
开发语言·python·uv
念何架构之路23 分钟前
Go语言常见并发模式
开发语言·后端·golang
祀爱29 分钟前
Asp.net core+ Layui 项目中编辑按钮传递数据的方法
前端·c#·asp.net·layui
磊 子44 分钟前
多态类原理+四种类型转换+异常处理
开发语言·c++·算法
脆皮炸鸡7551 小时前
库制作与原理~动态链接
linux·开发语言·经验分享·笔记·学习方法
XMYX-01 小时前
26 - Go recover 捕获错误:优雅恢复的真正意义
开发语言·golang
小白学大数据1 小时前
基于大模型的Python智能爬虫:语义识别与数据清洗实践
开发语言·爬虫·python·数据分析
迷渡1 小时前
聊一聊 Bun 用 Rust 重写这件事
开发语言·后端·rust