資源簡介
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?>?contours;
findContours(img_threshold?contoursCV_RETR_EXTERNAL?CV_CHAIN_APPROX_NONE);//只檢測外輪廓
//對候選的輪廓進行進一步篩選
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??max)?||?(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?>?contours;
findContours(img_threshold?contoursCV_RETR_EXTERNAL?CV_CHAIN_APPROX_NONE);//只檢測外輪廓
//對候選的輪廓進行進一步篩選
vector
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????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_xm
?????文件??????61946??2018-03-25?15:30??carNumber\ann_xm
?????文件??????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個文件信息
- 上一篇:機械制造工藝學課程設計指導書及習題
- 下一篇:地面氣象電碼手冊 PDF
評論
共有 條評論