一、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.NamedWindow("beyond", WindowFlags.Normal);Cv2.ImShow("beyond",img1);Cv2.WaitKey(0);}}
}
选择Release启动哈,这样的话启动速度快,不会加载一些Debug的内容
 
 运行效果
 
六、可能遇到的问题
运行的时候出现下面的警告,选择继续调试即可
 
 解决方法:
 右击项目,选择属性
 
 找到生成,取消勾选优化编码,记得保存下哈
 