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();
        }
    }
}

下载

源码下载

相关推荐
凭君语未可8 分钟前
豆包MarsCode:小C点菜问题
算法
C语言魔术师28 分钟前
【小游戏篇】三子棋游戏
前端·算法·游戏
自由自在的小Bird28 分钟前
简单排序算法
数据结构·算法·排序算法
深度混淆3 小时前
C#,入门教程(04)——Visual Studio 2022 数据编程实例:随机数与组合
开发语言·c#
chance_664 小时前
C# ASP.NET MVC项目内使用ApiController
c#
m0_743106465 小时前
【论文笔记】MV-DUSt3R+:两秒重建一个3D场景
论文阅读·深度学习·计算机视觉·3d·几何学
m0_743106465 小时前
【论文笔记】TranSplat:深度refine的camera-required可泛化稀疏方法
论文阅读·深度学习·计算机视觉·3d·几何学
王老师青少年编程7 小时前
gesp(C++五级)(14)洛谷:B4071:[GESP202412 五级] 武器强化
开发语言·c++·算法·gesp·csp·信奥赛
DogDaoDao7 小时前
leetcode 面试经典 150 题:有效的括号
c++·算法·leetcode·面试··stack·有效的括号
Coovally AI模型快速验证8 小时前
MMYOLO:打破单一模式限制,多模态目标检测的革命性突破!
人工智能·算法·yolo·目标检测·机器学习·计算机视觉·目标跟踪