Can I use IP Cam application to recognize license plates?

1 次查看(过去 30 天)
Hey guy, I use IP Cam on Xiaomi Redmi Note 9 Pro
I have a code for license plate recognition, but when I take a photo, I can't recognize it, any new ideas?
%chup hinh xe ra va nhan dien bien so xe ra
axes(handles.axes5);
load ('imgfildata.mat')
load('bien.mat')
load('bien1.mat')
load imgfildata;
% cao=webcam;
% preview(cao);
% vid= handles.vid;
camm1 = ipcam('http://192.168.0.102:8080/video');
preview(cam1);
e = getsnapshot(cam1);
imshow(e);
e=imresize(e,[300 500]);
[~,cc]=size(e);
if size(e,3)==3
e=rgb2gray(e);
end
% se=strel('rectangle',[5,5]);
% a=imerode(picture,se);
% figure,imshow(a);
% b=imdilate(a,se);
threshold = graythresh(e);
e =~im2bw(e,threshold);
e = bwareaopen(e,30);
% imshow(picture)
if cc>2000
picture1=bwareaopen(e,3500);
else
picture1=bwareaopen(e,3000);
end
% figure,imshow(picture1)
picture2=e-picture1;
% figure,imshow(picture2)
picture2=bwareaopen(picture2,200);
% figure,imshow(picture2)
[L,Ne]=bwlabel(picture2);
propied=regionprops(L,'BoundingBox');
hold on
pause(1)
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
% figure
final_output=[];
t=[];
for n=1:Ne
[r,c] = find(L==n);
n1=e(min(r):max(r),min(c):max(c));
n1=imresize(n1,[42,24]);
% imshow(n1)
pause(0.2)
x=[ ];
totalLetters=size(imgfile,2);
for k=1:totalLetters
y=corr2(imgfile{1,k},n1);
x=[x y];
end
t=[t max(x)];
if max(x)>.45
z=find(x==max(x));
out=cell2mat(imgfile(2,z));
final_output=[final_output out];
% pathname='C:\Users\LHN\Desktop\Vehicle number plate recognition\test images\test images';
% filename = [pathname num2str(cc+k*(size(e,1))) '.png'];
% imwrite(e,filename);
end
end
biendem1=biendem1+1;
save('bien1.mat','biendem1')
if biendem<biendem1
a=clock;
s1=sprintf('%d - %d - %d',a(3),a(2),a(1));
s2=sprintf('%d:%d:%d',a(4),a(5),round(a(6)));
load('dulieu.mat');
data{biendem,1}=s1;
data{biendem,2}=s2;
data{biendem,3}=final_output;
save('dulieu.mat','data');
load('dulieu.mat')
biendem=biendem+1;
save('bien.mat','biendem')
set(handles.uitable3,'Data',data);data
end
Thank all.

回答(1 个)

Walter Roberson
Walter Roberson 2021-9-7
Generally speaking, if your connection to the ipcam is able to bring in images, and the characters in the images are at least as large as about 9 pixels tall, then it is probably possible to read the license plates. More pixels might be requires if non-English characters need to be read.
However, your code has
if cc>2000
picture1=bwareaopen(e,3500);
else
picture1=bwareaopen(e,3000);
end
which discards image areas that are less than 3000 pixels in area. It would be common for text to be smaller than that, so you might be throwing away too much when you do that.
I notice that you reshape extracted areas to 42 x 24, which is 1008 pixels in area. That suggests that your cut-off of 3000 or 3500 pixels in area might be stricter than is needed.
  2 个评论
Diec Thuan
Diec Thuan 2021-9-7
When I press the button to take a photo, it can only take pictures but not recognize, any new ideas?
Walter Roberson
Walter Roberson 2021-9-7
It should not matter, but you can write your code better.
Change
x=[ ];
totalLetters=size(imgfile,2);
for k=1:totalLetters
y=corr2(imgfile{1,k},n1);
x=[x y];
end
t=[t max(x)];
if max(x)>.45
z=find(x==max(x));
out=cell2mat(imgfile(2,z));
final_output=[final_output out];
% pathname='C:\Users\LHN\Desktop\Vehicle number plate recognition\test images\test images';
% filename = [pathname num2str(cc+k*(size(e,1))) '.png'];
% imwrite(e,filename);
end
to
totalLetters = size(imgfile, 2);
x = zeros(1,totalLetters);
for k = 1 : totalLetters
x(k) = corr2(imgfile{1,k},n1);
end
[maxx, z] = max(x);
t(n) = maxx;
if maxx > 0.45
final_output{n} = imgfile{2,z};
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by