本文主要是介绍C# OpenCvSharp 车牌颜色识别,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
C# OpenCvSharp 车牌颜色识别
目录
效果
项目
代码
下载
效果
项目
代码
using OpenCvSharp;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace OpenCvSharp_Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string fileFilter = "图片|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";
string image_path = "";
Mat image;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = fileFilter;
ofd.InitialDirectory = Application.StartupPath + "\\test_img";
if (ofd.ShowDialog() != DialogResult.OK) return;
pictureBox1.Image = null;
image_path = ofd.FileName;
pictureBox1.Image = new Bitmap(image_path);
textBox1.Text = "";
image = new Mat(image_path);
}
private void Form1_Load(object sender, EventArgs e)
{
image_path = "test_img/1.jpg";
pictureBox1.Image = new Bitmap(image_path);
image = new Mat(image_path);
}
PlateColorCls plateColorCls = new PlateColorCls();
private void button3_Click(object sender, EventArgs e)
{
if (image_path == "")
{
return;
}
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
string plateColor = plateColorCls.GetPlateColor(image);
stopwatch.Stop();
textBox1.Text = "耗时:\t\t" + stopwatch.ElapsedMilliseconds + "ms\r\n";
textBox1.Text += "号牌颜色:\t" + plateColor + "\r\n";
textBox1.Text += "-----------------------------\r\n";
textBox1.Text += plateColorCls.GetPixelCountInfo();
}
}
}
using OpenCvSharp;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;namespace OpenCvSharp_Demo
{public partial class Form1 : Form{public Form1(){InitializeComponent();}string fileFilter = "图片|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string image_path = "";Mat image;private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;ofd.InitialDirectory = Application.StartupPath + "\\test_img";if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;image_path = ofd.FileName;pictureBox1.Image = new Bitmap(image_path);textBox1.Text = "";image = new Mat(image_path);}private void Form1_Load(object sender, EventArgs e){image_path = "test_img/1.jpg";pictureBox1.Image = new Bitmap(image_path);image = new Mat(image_path);}PlateColorCls plateColorCls = new PlateColorCls();private void button3_Click(object sender, EventArgs e){if (image_path == ""){return;}Stopwatch stopwatch = new Stopwatch();stopwatch.Start();string plateColor = plateColorCls.GetPlateColor(image);stopwatch.Stop();textBox1.Text = "耗时:\t\t" + stopwatch.ElapsedMilliseconds + "ms\r\n";textBox1.Text += "号牌颜色:\t" + plateColor + "\r\n";textBox1.Text += "-----------------------------\r\n";textBox1.Text += plateColorCls.GetPixelCountInfo();}}
}
下载
源码下载
这篇关于C# OpenCvSharp 车牌颜色识别的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!