一、Visual Studio 创建新项目

二、选择Windows窗体应用(.NET Framework)
直接搜索模板:Windows窗体应用(.NET Framework)
 记得是C#哈,别整成VB(Visual Basic)了
 
PS:若搜索搜不到,直接点击安装多个工具和功能
 

亦或者,随便选择一个项目模板创建,然后在工具下找到获取工具和功能进行安装即可
 


三、输入项目名称、保存位置和框架版本

四、安装OpenCvSharp4和OpenCvSharp4.runtime.win拓展包

 
1,安装OpenCvSharp4拓展包

 
2,安装OpenCvSharp4.runtime.win拓展包

 
五、验证
using System;
using System.Windows.Forms;
using OpenCvSharp;
namespace opencv_test1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Mat img1 = new Mat("F:\\XPU\\beyond.jpg", ImreadModes.Color);
            Cv2.ImShow("beyond",img1);
            Cv2.WaitKey(0);
        }
    }
}
启动
 
 运行效果
 










