Why am I getting this error?
5 views (last 30 days)
Show older comments
function letter=readLetter(snap)
load NewTemplates
snap = imresize(snap,[42 24]);
rec=[ ];
for n=1:length(NewTemplates)
cor=corr2(NewTemplates{1,n},snap);
rec=[rec cor];
end
ind=find(rec==max(rec));
display(ind);
% Alphabets listings.
if ind==1 || ind==2
letter='A';
elseif ind==3 || ind==4
letter='B';
elseif ind==5
letter='C';
elseif ind==6 || ind==7
letter='D';
elseif ind==8
letter='E';
elseif ind==9
letter='F';
elseif ind==10
letter='G';
elseif ind==11
letter='H';
elseif ind==12
letter='I';
elseif ind==13
letter='J';
elseif ind==14
letter='K';
elseif ind==15
letter='L';
elseif ind==16
letter='M';
elseif ind==17
letter='N';
elseif ind==18 || ind==19
letter='O';
elseif ind==20 || ind==21
letter='P';
elseif ind==22 || ind==23
letter='Q';
elseif ind==24 || ind==25
letter='R';
elseif ind==26
letter='S';
elseif ind==27
letter='T';
elseif ind==28
letter='U';
elseif ind==29
letter='V';
elseif ind==30
letter='W';
elseif ind==31
letter='X';
elseif ind==32
letter='Y';
elseif ind==33
letter='Z';
%*-*-*-*-*
% Numerals listings.
elseif ind==34
letter='1';
elseif ind==35
letter='2';
elseif ind==36
letter='3';
elseif ind==37 || ind==38
letter='4';
elseif ind==39
letter='5';
elseif ind==40 || ind==41 || ind==42
letter='6';
elseif ind==43
letter='7';
elseif ind==44 || ind==45
letter='8';
elseif ind==46 || ind==47 || ind==48
letter='9';
else
letter='0';
end
end
The error I am getting is
Not enough input arguments.
Error in Letter_detection (line 4)
snap = imresize(snap,[42 24]);
6 Comments
Walter Roberson
on 17 Oct 2020
Uh huh. So look at the section there
Number Plate Detection
Here is the third and final code file named Plate_detection.m
and observe that it contains the code
for i=1:count
ow = length(Iprops(i).Image(1,:));
oh = length(Iprops(i).Image(:,1));
if ow<(h/2) & oh>(h/3)
letter=Letter_detection(Iprops(i).Image);
noPlate=[noPlate letter]
end
end
Notice that line
letter=Letter_detection(Iprops(i).Image);
that invokes the function Letter_detection, passing in a sub-image extracted from the plate image.
The code that circuitdigest provided does not invoke Letter_detection by clicking on the green Run button, and you should not be clicking on the green Run button in file Letter_detection either. You should be invoking Plate_detection. It is okay to switch to Plate_detection.m and press the green Run button there because that is a script rather than a function.
Answers (1)
Walter Roberson
on 17 Oct 2020
By the way:
letters = 'AABBCDDEFGHIJKLMNOOPQRRSTUVWXYZ1234456667889990';
if ind > length(letters)
letter = '0';
else
letter = letters(ind);
end
11 Comments
Walter Roberson
on 11 Apr 2021
The posted template creation code does not build the .mat that is available there. The code to match input against the templates uses the templates that are actually present in the .mat.
The difference between the posted template creation code and the templates in the .mat file is that the real templates in the .mat file have an extra entry for each letter that has an interior "hole", such as "D" or "O".
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!