代码拉取完成,页面将自动刷新
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);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。