/
Plate_Detection.m
54 lines (45 loc) · 1.53 KB
/
Plate_Detection.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
close all;
clear all;
im = imread('Number Plate Images/image1.png');
imgray = rgb2gray(im);
withoutNoise = wiener2(imgray,[5 5]);
imbin = im2bw(imgray);
im = edge(imgray, 'prewitt');
%Below steps are to find location of number plate
Iprops=regionprops(im,'BoundingBox','Area', 'Image');
area = Iprops.Area;
count = numel(Iprops);
maxa= area;
boundingBox = Iprops.BoundingBox;
for i=1:count
if maxa<Iprops(i).Area
maxa=Iprops(i).Area;
boundingBox=Iprops(i).BoundingBox;
end
end
im = imcrop(imbin, boundingBox);%crop the number plate area
im = bwareaopen(~im, 500); %remove some object if it width is too long or too small than 500
[h, w] = size(im);%get width
imshow(im);
Iprops=regionprops(im,'BoundingBox','Area', 'Image'); %read letter
count = numel(Iprops);
noPlate=[]; % Initializing the variable of number plate string.
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); % Reading the letter corresponding the binary image 'N'.
noPlate=[noPlate letter] % Appending every subsequent character in noPlate variable.
end
end
datasource = 'matlabProject';
password = '12345';
username = 'root';
connection = database(datasource, username,password);
curs = exec(connection, ['SELECT driverdata.numberPlate'...
' , driverdata.name'...
' , driverdata.carModel'...
' FROM matlabproject.driverdata '...
' WHERE driverdata.numberPlate = ''MH12DE1400''']);
curs = fetch(curs);
disp(curs.data);