Why it is showing error?

2 views (last 30 days)
Kartikey Rai
Kartikey Rai on 11 Oct 2019
Commented: Walter Roberson on 10 Apr 2021
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(find(rec == max(rec)));
% 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
Screenshot (39).png

Answers (1)

Geoff Hayes
Geoff Hayes on 11 Oct 2019
Kartikey - there appears to be a hidden character at your line 70 which is the "blank" line in
% Numerals listings.
elseif ind == 34
If, on Linux, I do a cat -t readLetter.m, I see a question mark at the blank line
elseif ind == 33
letter = 'Z';
?
% Numerals listings.
elseif ind == 34
Just delete the blank line and the line with the comment to ensure that this special character is removed.
  7 Comments
JIAHONG LIM
JIAHONG LIM on 10 Apr 2021
Hi GeiffHayes and Image Analyst, may I know why some letters need only 1 ind to determine but some need two? Thank you very much
if ind==1 || ind==2
letter='A';
elseif ind==3 || ind==4
letter='B';
elseif ind==5
letter='C';
Walter Roberson
Walter Roberson on 10 Apr 2021
This is taken from https://circuitdigest.com/tutorial/vehicle-number-plate-detection-using-matlab-and-image-processing which has a mismatch between the template building code and the template data file.
The characters that have two entries are the ones that have a "hole" in them. In the first version of the template, the hole is empoty, and in the second version of the template, the hole is filled.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!