3 Star 12 Fork 1

明月心/OpenCvSharpStudy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Form1.cs 1.93 KB
一键复制 编辑 原始数据 按行查看 历史
明月心 提交于 2022-12-16 21:21 . 调整界面
using OpenCvSharp;
using System.Security.Cryptography;
namespace OpenCvSharpStudy
{
public partial class MainForm : Form
{
private string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
private Mat mat { get; set; }
public MainForm()
{
InitializeComponent();
this.Text = "OpencvSharp学习 by 饶玉田,公众号:明月心技术学堂,QQ群:318860399";
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ShowMat(Mat result)
{
pictureBox2.BackgroundImage = new Bitmap(result.ToMemoryStream());
}
private void 打开文件ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = fileFilter;
if (ofd.ShowDialog() != DialogResult.OK) return;
mat = OpencvHelper.LoadFile(ofd.FileName);
pictureBox1.BackgroundImage = new Bitmap(mat.ToMemoryStream());
}
private void 转灰ToolStripMenuItem_Click(object sender, EventArgs e)
{
var result = OpencvHelper.ToGray(mat);
ShowMat(result);
}
private void 调整尺寸ToolStripMenuItem_Click(object sender, EventArgs e)
{
var result = OpencvHelper.Resize(mat);
ShowMat(result);
}
private void 二值化ToolStripMenuItem_Click(object sender, EventArgs e)
{
var result = OpencvHelper.ConvertToBlackBinary(mat);
ShowMat(result);
}
private void 颜色分割ToolStripMenuItem_Click(object sender, EventArgs e)
{
var result = OpencvHelper.GetColor(mat);
ShowMat(result);
}
private void 霍夫直线ToolStripMenuItem_Click(object sender, EventArgs e)
{
var result = OpencvHelper.GetHoughLinesP(mat);
ShowMat(result);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/raoyutian/OpenCvSharpStudy.git
git@gitee.com:raoyutian/OpenCvSharpStudy.git
raoyutian
OpenCvSharpStudy
OpenCvSharpStudy
master

搜索帮助