11、车牌识别

该程序旨在通过计算机视觉技术识别行驶中的车牌,采用OpenCV库结合预先训练的XML分类器,检测并保存车牌的.png图片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本程序的目的是为了识别行驶过程中的车牌,并且通过.png文件将车牌照片保存在对应路径中。首先分类器导入对应xml文件接着借助分类器的detectMultiScale函数来检测车牌。

具体代码如下:

#include <iostream>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/objdetect.hpp>
#include <opencv2/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
	VideoCapture cap(0);
	Mat img;
	CascadeClassifier platecascades;
	string path = "resources/haarcascade_russian_plate_number.xml";
	platecascades.load(path); // 载入俄罗斯车牌识别xml
	if (platecascades.empty() == true) // 判别xml文件是否为空
		cout << "XML file not loaded." << endl;
	vector<Rect> plates; // 以便显示被检测对象的边框
	while (true)
	{
		cap.read(img);
		platecascades.detectMultiScale(img, plates);
		for (int i = 0; i < plates.size(); i++)
		{
			Mat imgCrop = img(plates[i]); // 裁剪图像
			rectangle(img, plates[i], Scalar(0, 255, 0), 2);
			//imshow(to_string(i), imgCrop); im
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值