Hello everyone.
After executing the code below (which is an .m file):
!!!!! CODE ISNT MINE !!!!!
function digits = CarNumberRecognition(filename, verbosedrawing) digits = {-1,-1,-1}; digits = cell2mat(digits); digareas = struct; %load ideal numbers
idealnum = struct(); for i=0:9 idealnum(i+1).Image = imread(['ideals/num' num2str(i) '.bmp']); end srcI = imread(filename); srcImod = srcI; colors = 'rgb'; srcImod = imadjust(srcImod); srcImod = medfilt2(srcImod,[3 3]); filt = fspecial('log',[7 7], 0.3); srcImod = imfilter(srcImod,filt); srcImod = srcImod(:,:,:) < 150; srcImod = imopen(srcImod,strel('disk',2)); srcImod = bwlabel(srcImod,8); Idata = regionprops(srcImod,'Area','Image','Orientation','BoundingBox','ConvexArea'); k = 1; for i=1:length(Idata) ratio = Idata(i).BoundingBox(3)/Idata(i).BoundingBox(4); if Idata(i).ConvexArea > 500 && ratio < 7 && ratio > 2.5 bound = floor(Idata(i).BoundingBox); numbers(k) = Idata(i); numbers(k).Image = imcrop(srcI,bound); k = k + 1; end end %k = k-1; %
count = k - 1; % - 1
k = 1; for i=1:count srcImod = imrotate(numbers(i).Image, -numbers(i).Orientation, 'bicubic','crop'); srcIres = imresize(srcImod,[400 NaN]); srcImod = imadjust(srcImod); filt = fspecial('log',[7 7], 0.32); srcIlog = imfilter(srcImod,filt); srcImod = srcIlog; srcImod = imresize(srcImod,[400 NaN]); srcImod = srcImod (:,:,:) > 150; sl = strel('disk',4); % 4
srcImod = imopen(srcImod,sl); sl = strel('disk',4); % 4 srcImod = imclose(srcImod,sl); probdigits = regionprops(srcImod,'Area','Orientation', 'Image', 'ConvexArea','BoundingBox'); PlateBounds = floor([numbers(i).BoundingBox(1),numbers(i).BoundingBox(2),0,0]); for i=1:length(probdigits) ratio = probdigits(i).BoundingBox(3)/probdigits(i).BoundingBox(4); if probdigits(i).Area > 2200 && ratio < 0.7 && ratio > 0.1 ImageToTest = imresize(probdigits(i).Image,[200 200]); c = zeros(); for j=1:10, c(j)= corr2 (ImageToTest,idealnum(j).Image); end c = abs(c); maxid = 3; for j=2:10, if c(j) > c(maxid), maxid = j; end, end if c(maxid) > 0.55 digits(k) = (maxid-1); digareas(k).bound = PlateBounds + probdigits(i).BoundingBox; k = k + 1; end if k==4, break, end end end end if verbosedrawing imshow(srcIres); hold on; for i=1:k-1 rect = rectangle('Position',digareas(i).bound,'EdgeColor',colors(i)); plot (rect) end endend
im having this error:
Error using plotNot enough input arguments.Error in CarNumberRecognition (line 80) plot (rect)
Im executing code by using next command in Command window:
digits = CarNumberRecognition('957.bmp', 1)
All this staff must recognize numbers on license plates, but i can recognize only one (see picture below). Any suggestions how to recognize all three and get rid of an error?
P.S. – attaching my result, code and couple pictures of plates
Best Answer