• 大小: 4.23M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-16
  • 语言: 其他
  • 标签: 其他  

资源简介

carNumber.rar

资源截图

代码片段和文件信息

#include “carID_Detection.h“



void RgbConvToGray(const Mat& inputImageMat & outpuImage)  //g = 0.3R+0.59G+0.11B
{
outpuImage = Mat(inputImage.rows inputImage.cols CV_8UC1);  

for (int i = 0 ;i {
uchar *ptrGray = outpuImage.ptr(i); 
const Vec3b * ptrRgb = inputImage.ptr(i);
for (int j = 0 ;j {
ptrGray[j] = 0.3*ptrRgb[j][2]+0.59*ptrRgb[j][1]+0.11*ptrRgb[j][0];
}
}
}

void posDetect_closeImg(Mat &inputImage  vector  & rects  )   //初步找到候选区域 rects
{

Mat img_canny;
Canny(inputImage img_canny 150 220);
Mat img_threshold;
threshold(img_canny  img_threshold0255  CV_THRESH_OTSU+CV_THRESH_BINARY); //otsu算法自动获得阈值

Mat element = getStructuringElement(MORPH_RECT Size(17 3));  //闭形态学的结构元素
morphologyEx(img_threshold img_thresholdCV_MOP_CLOSEelement);  //形态学处理
morphologyEx(img_threshold img_thresholdMORPH_OPENelement);
//寻找车牌区域的轮廓
vector< vector  > contours;
findContours(img_threshold contoursCV_RETR_EXTERNAL CV_CHAIN_APPROX_NONE);//只检测外轮廓
//对候选的轮廓进行进一步筛选
vector< vector  > ::iterator itc = contours.begin();

while( itc != contours.end())
{
RotatedRect mr = minAreaRect(Mat( *itc )); //返回每个轮廓的最小有界矩形区域
   if(!verifySizes_closeImg(mr))  //判断矩形轮廓是否符合要求
{
itc = contours.erase(itc);
}
else     
{

rects.push_back(mr);
++itc;
}      
}

}


bool verifySizes_closeImg(const RotatedRect & candidate)
{
float error = 0.4;
const float aspect = 44/14; //长宽比
int min = 20*aspect*20; //最小区域
int max = 180*aspect*180;  //最大区域
float rmin = aspect - aspect*error; //考虑误差后的最小长宽比
float rmax = aspect + aspect*error; //考虑误差后的最大长宽比

int area = candidate.size.height * candidate.size.width;
float r = (float)candidate.size.width/(float)candidate.size.height;
if(r <1)
r = 1/r;

if( (area < min || area > max) || (r< rmin || r > rmax)  )
return false;
else
return true;
}

void posDetect(Mat &inputImage  vector  & rects  )   //初步找到候选区域 rects
{
Mat img_sobel;
Sobel(inputImage  img_sobel  CV_8U 10310);
//Sobel(img_sobelimg_sobelCV_8U1310);
Mat img_threshold;
threshold(img_sobel  img_threshold0255  CV_THRESH_OTSU+CV_THRESH_BINARY); //otsu算法自动获得阈值

Mat element = getStructuringElement(MORPH_RECT Size(17 3));  //闭形态学的结构元素
morphologyEx(img_threshold img_thresholdCV_MOP_CLOSEelement);  
morphologyEx(img_thresholdimg_thresholdMORPH_OPENelement);

//Sobel(img_thresholdimg_thresholdCV_8U10310);
//morphologyEx(img_threshold img_thresholdCV_MOP_CLOSEelement);  
//morphologyEx(img_thresholdimg_thresholdMORPH_OPENelement);

namedWindow(“img“CV_WINDOW_NORMAL);
imshow(“img“img_threshold);
//waitKey();
//寻找车牌区域的轮廓
vector< vector  > contours;
findContours(img_threshold contoursCV_RETR_EXTERNAL CV_CHAIN_APPROX_NONE);//只检测外轮廓
//对候选的轮廓进行进一步筛选
vector< vecto

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      19538  2018-05-05 10:56  carNumber\1.jpg

     文件      25536  2018-03-18 11:45  carNumber\29.jpg

     文件      26204  2018-05-14 18:49  carNumber\5.jpg

     文件     795336  2017-03-21 15:41  carNumber\ann_xml.xml

     文件      61946  2018-03-25 15:30  carNumber\ann_xml_character.xml

     文件      22492  2018-04-04 16:29  carNumber\carID_Detection.cpp

     文件       2083  2018-04-04 16:23  carNumber\carID_Detection.h

     文件     136491  2018-05-14 18:50  carNumber\carNumber

     文件        790  2018-05-14 18:53  carNumber\char10.jpg

     文件        784  2018-05-14 18:53  carNumber\char11.jpg

     文件        712  2018-05-14 18:53  carNumber\char12.jpg

     文件        796  2018-05-14 18:53  carNumber\char13.jpg

     文件        380  2018-05-14 18:53  carNumber\char14.jpg

     文件        771  2018-05-14 18:53  carNumber\char15.jpg

     文件        797  2018-05-14 18:53  carNumber\char16.jpg

     文件        390  2013-11-05 11:37  carNumber\charSamples\0\0 (1).png

     文件        376  2013-11-07 08:35  carNumber\charSamples\0\0 (10).png

     文件        413  2013-11-10 08:12  carNumber\charSamples\0\0 (11).png

     文件        413  2013-11-09 08:47  carNumber\charSamples\0\0 (12).png

     文件        376  2013-11-06 07:31  carNumber\charSamples\0\0 (13).png

     文件        413  2013-11-07 10:29  carNumber\charSamples\0\0 (14).png

     文件        398  2013-11-07 01:38  carNumber\charSamples\0\0 (15).png

     文件        390  2013-11-09 16:11  carNumber\charSamples\0\0 (16).png

     文件        413  2013-11-05 23:09  carNumber\charSamples\0\0 (17).png

     文件        413  2013-11-04 07:38  carNumber\charSamples\0\0 (18).png

     文件        413  2013-11-10 17:49  carNumber\charSamples\0\0 (19).png

     文件        413  2013-11-04 17:45  carNumber\charSamples\0\0 (2).png

     文件        452  2013-11-07 09:17  carNumber\charSamples\0\0 (20).png

     文件        328  2013-11-09 09:13  carNumber\charSamples\0\0 (21).png

     文件        578  2013-11-06 07:23  carNumber\charSamples\0\0 (22).png

............此处省略1927个文件信息

评论

共有 条评论