想通过svm实现多字符的分类,可以通过一对其它的方式,例如1,2,3,4,5个数,创造出四个向量机,分别是1对2-5,2对3-5,3对4和5,4对5。
注意事项:
1.对训练对象进行图像的预处理,使大小保持一致且都已经二值化。
2.因为车牌中不含有英文字母I和O,可以直接用contious跳过当前循环。
void CancelSamples()
{
for (int j = 0; j <=36;j++)
{
if(j==10||char(j+54)=='O'||char(j+54)=='I')
{
cout<<"skip cancelling "<< j<< "samples"<<endl;
continue;
}
for(int i=0;i<=13;i++)
{
string imgName;
if(j<10)
imgName=format("samples/sample_%d/%d.jpg",j,(i+1));
else
imgName=format("samples/sample_%c/%d.jpg",(j+54),(i+1));
Mat srcImage=imread(imgName);
if(srcImage.empty())
{
cout<<"failed to get the Image"<<imgName<<endl;
}
else {
Mat resized;
resize(srcImage,resized,Size(80,150));
blur(resized,resized,Size(3,3));
cvtColor(resized,resized,CV_BGR2GRAY);
threshold(resized,resized,140,255,CV_THRESH_BINARY);
vector