zoukankan      html  css  js  c++  java
  • C# opencv Form显示图片

    C# opencv Form显示图片

    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 OpenCvSharp;
    using OpenCvSharp.Extensions;
    
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void selectButton_Click(object sender, EventArgs e)
            {
                string imgName = "";
                OpenFileDialog openFileDialog1 = new OpenFileDialog();
                openFileDialog1.Filter = "图片(*.jpg/*.png/*.gif/*.bmp)|*.jpg;*.png;*.gif;*.bmp";
    
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    imgName = openFileDialog1.FileName;
                    Mat mat = new Mat(imgName, ImreadModes.Unchanged);
                    // mat 转 bitmap
                    Bitmap bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat); 
                    pictureBox1.Image = bitmap;
                }
                else
                {
                    MessageBox.Show("读取图片失败", "提示");
                }
    
            }
        }
    }

    ########################

    QQ 3087438119
  • 相关阅读:
    var 和 let 的区别
    js初步认识变量
    弹性布局
    盒模型
    多重样式优先级深入概念
    层叠机制--比较特殊性
    anroid抓包工具tcpdump的用法
    linux find grep组合使用
    Protect Broadcast 保护广播
    android:exported 属性详解
  • 原文地址:https://www.cnblogs.com/herd/p/14890812.html
Copyright © 2011-2022 走看看