資源簡介
作者歷經(jīng)小半年的調(diào)試 才把程序調(diào)試好 完全可以實(shí)現(xiàn)車牌的字符識(shí)別,分割,提取,采用了SVM分類器和ANN神經(jīng)網(wǎng)絡(luò),若下載后實(shí)現(xiàn)不了相應(yīng)的功能,可以找作者把積分退還給大家

代碼片段和文件信息
#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??)???//3?2??òμ?oò????óò?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??·?×??ˉ??μ??D?μ
Mat?element?=?getStructuringElement(MORPH_RECT?Size(17?3));??//±?D?ì??§μ??á11?a??
morphologyEx(img_threshold?img_thresholdCV_MOP_CLOSEelement);??//D?ì??§??àí
morphologyEx(img_threshold?img_thresholdMORPH_OPENelement);
//?°?ò3μ????óòμ???àa
vector?>?contours;
findContours(img_threshold?contoursCV_RETR_EXTERNAL?CV_CHAIN_APPROX_NONE);//???ì2aía??àa
//??oò??μ???àa??DD??ò?2?é???
vector?>?::iterator?itc?=?contours.begin();
while(?itc?!=?contours.end())
{
RotatedRect?mr?=?minAreaRect(Mat(?*itc?));?//·μ????????àaμ?×?D?óD????D???óò
?? if(!verifySizes_closeImg(mr))??//?D????D???àaê?·?·?o?òa?ó
{
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;?//3€?í±è
int?min?=?20*aspect*20;?//×?D???óò
int?max?=?180*aspect*180;??//×??ó??óò
float?rmin?=?aspect?-?aspect*error;?//?????ó2?oóμ?×?D?3€?í±è
float?rmax?=?aspect?+?aspect*error;?//?????ó2?oóμ?×??ó3€?í±è
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??)???//3?2??òμ?oò????óò?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??·?×??ˉ??μ??D?μ
Mat?element?=?getStructuringElement(MORPH_RECT?Size(17?3));??//±?D?ì??§μ??á11?a??
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();
//?°?ò3μ????óòμ???àa
vector?>?contours;
findContours(img_threshold?contoursCV_RETR_EXTERNAL?CV_CHAI
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????125522??2018-05-24?02:55??車牌識(shí)別最終版\1.jpg
?????文件?????164788??2018-05-24?02:55??車牌識(shí)別最終版\10.jpg
?????文件?????152372??2018-05-24?02:55??車牌識(shí)別最終版\11.jpg
?????文件?????171524??2018-05-24?02:55??車牌識(shí)別最終版\12.jpg
?????文件?????192436??2018-05-24?02:55??車牌識(shí)別最終版\13.jpg
?????文件?????109126??2018-05-24?02:55??車牌識(shí)別最終版\14.jpg
?????文件?????293362??2018-05-24?02:55??車牌識(shí)別最終版\15.jpg
?????文件?????318958??2018-05-24?02:55??車牌識(shí)別最終版\16.jpg
?????文件?????153084??2018-05-24?02:55??車牌識(shí)別最終版\17.jpg
?????文件?????345177??2018-05-24?02:55??車牌識(shí)別最終版\18.jpg
?????文件?????187703??2018-05-24?02:55??車牌識(shí)別最終版\19.jpg
?????文件?????168293??2018-05-24?02:55??車牌識(shí)別最終版\2.jpg
?????文件?????197126??2018-05-24?02:55??車牌識(shí)別最終版\20.jpg
?????文件?????176264??2018-05-24?02:55??車牌識(shí)別最終版\21.jpg
?????文件?????144435??2018-05-24?02:55??車牌識(shí)別最終版\22.jpg
?????文件?????135291??2018-05-24?02:55??車牌識(shí)別最終版\23.jpg
?????文件?????119776??2018-05-24?02:55??車牌識(shí)別最終版\24.jpg
?????文件?????335158??2018-05-24?02:55??車牌識(shí)別最終版\25.jpg
?????文件?????180912??2018-05-24?02:55??車牌識(shí)別最終版\26.jpg
?????文件?????105402??2018-05-24?02:55??車牌識(shí)別最終版\27.jpg
?????文件?????158370??2018-05-24?02:55??車牌識(shí)別最終版\28.jpg
?????文件?????202602??2018-05-24?02:55??車牌識(shí)別最終版\3.jpg
?????文件?????121013??2018-05-24?02:55??車牌識(shí)別最終版\4.jpg
?????文件?????232989??2018-05-24?02:55??車牌識(shí)別最終版\5.jpg
?????文件?????154374??2018-05-24?02:55??車牌識(shí)別最終版\6.jpg
?????文件?????370419??2018-05-24?02:55??車牌識(shí)別最終版\7.jpg
?????文件?????137046??2018-05-24?02:55??車牌識(shí)別最終版\8.jpg
?????文件?????200607??2018-05-24?02:55??車牌識(shí)別最終版\9.jpg
?????文件??????13186??2018-05-24?02:55??車牌識(shí)別最終版\a.jpg
?????文件?????795336??2018-05-24?02:55??車牌識(shí)別最終版\ann_xm
............此處省略2008個(gè)文件信息
評(píng)論
共有 條評(píng)論