[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

相关推荐
geovindu1 分钟前
CSharp: Template Method Pattern
开发语言·后端·c#·.net·模板方法模式·行为模式
专注API从业者3 分钟前
Open‑Claw 实战|无需逆向,快速搭建电商商品监控与数据分析系统
开发语言·数据结构·数据库·数据分析·php
西西弗Sisyphus11 分钟前
Qt 无边框窗口自己实现拖拽与缩放
开发语言·qt
CSDN_RTKLIB15 分钟前
SetImpliedSelection
c#
狮子雨恋15 分钟前
anaconda python环境和QT python环境不一致如何解决
开发语言·python·qt
软件黑马王子23 分钟前
1.non-MonoBehaviour 单例模式泛型基类
unity·前端框架·c#
独立开发之道25 分钟前
【three.js教程】Three.js 矩阵变换:position/quaternion/scale 和 matrix 到底怎么配合
开发语言·javascript·矩阵
纪念 22925 分钟前
数据结构排序(四)
开发语言·数据结构
IvanCodes28 分钟前
Python 基础语法(四):循环结构与流程控制
开发语言·python
OPEN-F29 分钟前
C++工程化:编译链接、调试与性能优化
开发语言·c++