資源簡介
基于SVM與ANN的車牌識別,結合opencv庫使用。

代碼片段和文件信息
#include?“DetectRegions.h“
void?DetectRegions::setFilename(string?s)
{
filename?=?s;
}
DetectRegions::DetectRegions()
{
showSteps?=?false;
saveRegions?=?false;
}
/*對檢測到的區域做一些基本的驗證,這些驗證基于面積與寬高比。
車牌區域:有40%的誤差范圍內,其寬高比為520/110?=?4.727272?*/
bool?DetectRegions::verifySizes?(RotatedRect?candidate)
{
float?error?=?0.4;
//Spain?car?plate?size:?52*11?aspect?47272
const?float?aspect?=?4.7272;
//Set?a?min?and?max?area?All?other?patches?are?discared
int?min?=?15?*?aspect?*?15;?
int?max?=?125?*aspect?*?125;
//Get?only?patches?that?match?to?a?respect?ratio.
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;
}
Mat?DetectRegions::histeq(Mat?in)??//直方圖均衡
{
Mat?out?(in.size()?in.type());
if?(in.channels()?==?3)
{
Mat?hsv;
vector??HsvSplit;
cvtColor(in?hsv?CV_BGR2HSV);
split(hsvHsvSplit);//通道分離
equalizeHist(HsvSplit[2]?HsvSplit[2]);
merge(HsvSplit?hsv);
cvtColor(hsv?out CV_HSV2BGR);
}
else?if(in.channels()?==?1)
equalizeHist(in?out);
return?out;
}
vector??DetectRegions::segment(Mat?input)
{
vector??output;
Mat?img_gray;
cvtColor(input?img_gray?CV_BGR2GRAY);
blur(img_gray?img_gray?Size(55));
Mat?img_sobel;
Sobel(img_gray?img_sobel?CV_8U?1?0?3?1?0?BORDER_DEFAULT);
if(showSteps)
imshow(“Sobel“img_sobel);
Mat?img_threshold;
threshold(img_sobel?img_threshold?0?255 CV_THRESH_OTSU?+?CV_THRESH_BINARY);
if(showSteps)
imshow(“Thershold“img_threshold);
Mat?element?=?getStructuringElement(MORPH_RECT?Size(173));
morphologyEx(img_thresholdimg_threshold?CV_MOP_CLOSE?element);
if(showSteps)
imshow(“Close“?img_threshold);
vector??>?contours;
findContours(img_threshold?contours?CV_RETR_EXTERNAL?CV_CHAIN_APPROX_NONE);
vector??>?::?iterator?itc?=?contours.begin();
vector??rects;
while?(itc?!=?contours.end())
{
RotatedRect?mr?=?minAreaRect(Mat?(*itc));
if(?!verifySizes(mr))
itc?=?contours.erase(itc);
else
{
++itc;
rects.push_back(mr);
}
}
Mat?result;
input.copyTo(result);
drawContours(result?contours?-1?Scalar(255?0?0)?1);
//For?better?rect?cropping?for?each?posible?box
//Make?floodfill?algorithm?because?the?plate?has?white?background
//And?then?we?can?retrieve?more?clearly?the?contour?box
for?(int?i?=?0;?i? {
circle(?result?rects[i].center?3?Scalar(0?255?0)?-1);
float?minSize?=?(rects[i].size.width? minSize?=?minSize?-?minSize?*?0.5;
//initialize?rand?and?get?5?points?around?center?for?flo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????301056??2015-04-30?09:30??testnouse\Debug\testnouse.exe
?????文件????2961740??2015-04-30?09:30??testnouse\Debug\testnouse.ilk
?????文件????3599360??2015-04-30?09:30??testnouse\Debug\testnouse.pdb
?????文件?????196236??2014-06-02?08:20??testnouse\testnouse\2715DTZ.jpg
?????文件???????2390??2015-04-30?09:30??testnouse\testnouse\Debug\cl.command.1.tlog
?????文件??????90756??2015-04-30?09:30??testnouse\testnouse\Debug\CL.read.1.tlog
?????文件???????3490??2015-04-30?09:30??testnouse\testnouse\Debug\CL.write.1.tlog
?????文件????1039376??2015-04-28?20:28??testnouse\testnouse\Debug\DetectRegions.obj
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
?????文件??????????2??2015-04-30?09:30??testnouse\testnouse\Debug\li
............此處省略32個文件信息
- 上一篇:SSD4全部答案Exercise+Quiz
- 下一篇:Eclipse使用詳細教程
評論
共有 條評論