資源簡介
使用svm和BP神經網絡進行車牌的OCR識別
代碼片段和文件信息
/*****************************************************************************
*???Number?Plate?Recognition?using?SVM?and?Neural?Networks
******************************************************************************
*???by?David?Mill醤?Escriv??5th?Dec?2012
*???http://blog.damiles.com
******************************************************************************
*???Ch5?of?the?book?“Mastering?OpenCV?with?Practical?Computer?Vision?Projects“
*???Copyright?Packt?Publishing?2012.
*???http://www.packtpub.com/cool-projects-with-opencv/book
*****************************************************************************/
#include?“DetectRegions.h“
void?DetectRegions::setFilename(string?s)
{
????????filename=s;
}
DetectRegions::DetectRegions()
{
????showSteps=false;
????saveRegions=false;
}
bool?DetectRegions::verifySizes(RotatedRect?mr)
{
float?error?=?(float)0.4;
????//Spain?car?plate?size:?52x11?aspect?47272
float?aspect?=?(float)4.7272;
????//Set?a?min?and?max?area.?All?other?patchs?are?discarded
int?min?=?(int)(15*aspect?*?15);?//?minimum?area
int?max?=?(int)(125?*?aspect?*?125);?//?maximum?area
????//Get?only?patchs?that?match?to?a?respect?ratio.
????float?rmin=?aspect-aspect*error;
????float?rmax=?aspect+aspect*error;
int?area?=?(int)(mr.size.height?*?mr.size.width);
????float?r=?(float)mr.size.width?/?(float)mr.size.height;
????if(r<1)
????????r=?(float)mr.size.height?/?(float)mr.size.width;
????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(hsv?hsvSplit);
????????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;
????//convert?image?to?gray
????Mat?img_gray;
????cvtColor(input?img_gray?CV_BGR2GRAY);
????blur(img_gray?img_gray?Size(55));????
????//Finde?vertical?lines.?Car?plates?have?high?density?of?vertical?lines
????Mat?img_sobel;
????Sobel(img_gray?img_sobel?CV_8U?1?0?3?1?0?BORDER_DEFAULT);
????if(showSteps)
????????imshow(“Sobel“?img_sobel);
????//threshold?image
????Mat?img_threshold;
????threshold(img_sobel?img_threshold?0?255?CV_THRESH_OTSU+CV_THRESH_BINARY);
????if(showSteps)
????????imshow(“Threshold“?img_threshold);
????//Morphplogic?operation?close
????Mat?element?=?getStructuringElement(MORPH_RECT?Size(17?3)?);
????morphologyEx(img_threshold?img_threshold?CV_MOP_CLOSE?element);
????if(showSteps)
????????imshow(“Close“?img_threshold);
????//Find?contours?of?possibles?plates
????vector?>?contours;
????findContours(img_threshold
????????????contours?//?a?vector?of?contours
?????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????293009??2012-12-29?04:28??車牌檢測\opencv_3.0模板\3028BYS.JPG
?????文件?????393261??2012-12-29?04:28??車牌檢測\opencv_3.0模板\3154FFY.JPG
?????文件?????319706??2012-12-29?04:28??車牌檢測\opencv_3.0模板\3266CNT.JPG
?????文件?????281617??2012-12-29?04:28??車牌檢測\opencv_3.0模板\3732FWW.JPG
?????文件????????851??2012-12-29?04:28??車牌檢測\opencv_3.0模板\CMakeLists.txt
?????文件???????2184??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.log
?????文件???????1254??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\cl.command.1.tlog
?????文件??????31766??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\CL.read.1.tlog
?????文件????????886??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\CL.write.1.tlog
?????文件??????????2??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\li
?????文件??????????2??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\li
?????文件??????????2??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\li
?????文件????????169??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\opencv_3.0模板.lastbuildstate
?????文件??????????0??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\opencv_3.0模板.tlog\unsuccessfulbuild
?????文件?????691200??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\vc120.idb
?????文件?????716800??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\vc120.pdb
?????文件?????201819??2016-11-16?14:07??車牌檢測\opencv_3.0模板\Debug\模板.obj
?????文件???????8143??2017-03-12?21:35??車牌檢測\opencv_3.0模板\DetectRegions.cpp
?????文件???????1170??2017-03-11?21:52??車牌檢測\opencv_3.0模板\DetectRegions.h
?????文件?????365670??2012-12-29?04:28??車牌檢測\opencv_3.0模板\DSC_0562.jpg
?????文件?????386667??2012-12-29?04:28??車牌檢測\opencv_3.0模板\DSC_0566.jpg
?????文件???????2670??2017-03-17?15:15??車牌檢測\opencv_3.0模板\evalOCR.cpp
?????文件????1043456??2016-12-12?21:20??車牌檢測\opencv_3.0模板\libfacedetect-x64.dll
?????文件???????4191??2017-12-07?15:48??車牌檢測\opencv_3.0模板\main.cpp
?????文件??????10539??2017-03-17?13:50??車牌檢測\opencv_3.0模板\OCR.cpp
?????文件???????1973??2017-03-16?19:00??車牌檢測\opencv_3.0模板\OCR.h
?????文件????3392688??2012-12-29?04:28??車牌檢測\opencv_3.0模板\OCR.xm
?????文件???????9644??2017-12-07?15:51??車牌檢測\opencv_3.0模板\opencv_3.0模板.vcxproj
?????文件???????2287??2017-03-12?21:22??車牌檢測\opencv_3.0模板\opencv_3.0模板.vcxproj.filters
?????文件????????165??2016-12-13?19:21??車牌檢測\opencv_3.0模板\opencv_3.0模板.vcxproj.user
............此處省略69個文件信息
- 上一篇:自主泊車算法
- 下一篇:紅外弱小目標測試集合
評論
共有 條評論