车牌识别基于matlab GUI停车计费系统含Matlab源码 735期

Posted 唐门佛怒唐莲

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了车牌识别基于matlab GUI停车计费系统含Matlab源码 735期相关的知识,希望对你有一定的参考价值。

一、简介

随着汽车数量的增加,城市交通状 况日益受到人们的重视,如何进行有效的交通管理更是成为了人们关注的焦点。智能交 通系统通过车辆检测装置对过往的车辆实施检测,提取有关交通数据,达到监控、管理和指挥交通的 目的。因此,它已成为世界交通领域研究的重要课题。 车牌识别系统作为智能交通系统的一个重要组成部分,已在高速公路、城市交通和停车场等项目的管理中占有无可取代的重要地位。它在不影响汽车状态的情况下,由计算机自动完成车牌的识别,从而降低交通管理工作的复杂度。
拟定的课题名称为基于MATLAB的汽车出入库计时计费系统,带有丰富的人机交互GUI界面。传统的车牌识别,仅仅是对车牌照片进行识别,显得中规中矩

二、源代码

function varargout = Main(varargin)
% MAIN MATLAB code for Main.fig
%      MAIN, by itself, creates a new MAIN or raises the existing
%      singleton*.
%
%      H = MAIN returns the handle to a new MAIN or the handle to
%      the existing singleton*.
%
%      MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN.M with the given input arguments.
%
%      MAIN('Property','Value',...) creates a new MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Main_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Main

% Last Modified by GUIDE v2.5 12-May-2009 23:58:18

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Main_OpeningFcn, ...
                   'gui_OutputFcn',  @Main_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Main is made visible.
function Main_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Main (see VARARGIN)

% Choose default command line output for Main
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Main wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Main_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox2


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
%----------------------入停车场-----------------------------
[filename,filepath]=uigetfile('.jpg','采集入库车牌');% 直接自动读入%
file=strcat(filepath,filename); %strcat函数:连接字符串;把filepath的字符串与filename的连接,即路径/文件名
I=imread(file);
axes(handles.axes1)
imshow(I)
title('原图')
I1=rgb2gray(I);  
I2=edge(I1,'roberts',0.15,'both');  
se=[1;1;1];  
I3=imerode(I2,se);  
se=strel('rectangle',[25,25]);  
I4=imclose(I3,se);  
I5=bwareaopen(I4,2000);  
[y,x,z]=size(I5);  
myI=double(I5);  
tic
 white_y=zeros(y,1);  
 for i=1:y  
    for j=1:x  
             if(myI(i,j,1)==1)   
                white_y(i,1)= white_y(i,1)+1;   
            end    
     end         
 end  
 [temp MaxY]=max(white_y);  
 PY1=MaxY;  
 while ((white_y(PY1,1)>=5)&&(PY1>1))  
        PY1=PY1-1;  
 end      
 PY2=MaxY;  
 while ((white_y(PY2,1)>=5)&&(PY2<y))  
        PY2=PY2+1;  
 end  
 IY=I(PY1:PY2,:,:);  
 white_x=zeros(1,x);  
 for j=1:x  
     for i=PY1:PY2  
            if(myI(i,j,1)==1)  
                white_x(1,j)= white_x(1,j)+1;                 
            end    
     end         
 end  
    
 PX1=1;  
 while ((white_x(1,PX1)<3)&&(PX1<x))  
       PX1=PX1+1;  
 end      
 PX2=x;  
 while ((white_x(1,PX2)<3)&&(PX2>PX1))  
        PX2=PX2-1;  
 end  
 PX1=PX1-2;  
 PX2=PX2+3;  
 dw=I(PY1:PY2-8,PX1:PX2,:);  
 axes(handles.axes2)
 imshow(dw)
 title('车牌定位')
 t=toc;  %识别时间    
a=dw;  %定位的车牌
b=rgb2gray(a);   
g_max=double(max(max(b)));  
g_min=double(min(min(b)));  
T=round(g_max-(g_max-g_min)/3); % T 为二值化的阈值  
[m,n]=size(b);  
d=(double(b)>=T);  % d:二值图像  

% 滤波  
h=fspecial('average',3);  
d=im2bw(round(filter2(h,d)));  
axes(handles.axes3)
imshow(d)
title('车牌区域二值化')

三、运行结果

在这里插入图片描述

四、备注

完整代码或代写添加QQ 1564658423

以上是关于车牌识别基于matlab GUI停车计费系统含Matlab源码 735期的主要内容,如果未能解决你的问题,请参考以下文章

车牌识别基于matlab GUI模板匹配车牌识别含Matlab源码 1215期

车牌识别基于matlab GUI模板匹配车牌识别门禁系统含Matlab源码 1091期

车牌识别基于matlab GUI模板匹配车牌库识别含Matlab源码 416期

车牌识别基于matlab GUI模板匹配新能源轿车货车车牌识别含Matlab源码 2169期

车牌识别基于matlab GUI字符匹配车牌识别(18省份)含Matlab源码 1617期

图像识别基于模板匹配车牌识别matlab源码含GUI