This article was reproduced from: http://blog.csdn.net/ap1005834/article/details/51340831
First, preface
This article refers to the automatic license plate recognition project in the deep understanding of OPENCV practical Computer Vision Project analysis, and then carries on the practice after understanding the method. The difficulty of accurately identifying the sequence of the characters in the license plate area is to realize the exact location of the license plate area. So the final recognition effect is still to be further improved.
second, the procedure flow
The program flow is as follows:
The corresponding main function is as follows
[CPP] View plain copy print? #include "Carid_detection.h" int main () { mat img_input = imread ("testcarid.jpg"); //If read-in image fails if (Img_input.empty ()) { fprintf (stderr, "Can not load image %s\n ", " testcarid.jpg "); return -1; } Mat hsvImg ; cvtcolor (IMG_INPUT,HSVIMG,CV_BGR2HSV); vector<Mat> planes; split ( Hsvimg,planes); &NBSP;&NBSP;&NBSP;&NBSP;MAT&NBSP;SIMG;&NBSP;&NBSp simg = planes[1]; //get red component Blur (Simg,simg,size (3,3)) //3*3 Gaussian filter vector < rotatedrect> rects_simg; posdetect (SIMG&NBSP;,RECTS_SIMG); mat grayimg; rgbconvtogray (img_input ,grayimg); medianblur (grayimg,grayimg,3); //3*3 median filter vector <RotatedRect> rects_grayImg; posdetect (grayimg ,rects_grayimg); vector < ROTATEDRECT>&NBSP;&NBSP;RECTS_CLOSEIMG;&NBSP;&NBSP;//license plate area closer to posdetect_ Closeimg (SIMG&NBSP;,RECTS_CLOSEIMG); vector <RotatedRect> rects_optimal; optimposdetect (rects_simg,rects_grayimg,rects_closeimg , rects_optimal); vector <Mat> output_area; normalposarea (Img_input ,rects_optimal,output_area); // Get 144*33 's candidate license plate area output_area CvSVM svmClassifier; svm_train (svmclassifier) //use SVM to train positive and negative samples vector<mat> plates_svm; //need to use the candidate plate area Output_area each pixel in the image as a line feature vector, and then make predictions. for (Int i=0;i< output_area.size (); ++i) { Mat img = output_area[i]; mat p = img.reshape (; ) p.convertto (P,CV_32FC1); int response = (int) svmclassifier.predict ( p );