【图像识别】基于模板匹配算法求解车牌识别问题matlab代码

169 阅读4分钟

1 简介

随着经济社会的迅速发展,人民对生活水平的要求也不断提高,从而引起汽车的数量的增加.给出行带来便捷的同时,车辆的管理问题也日益显著.车牌识别系统是指能将监控中运动的车辆的汽车牌照信息从复杂背景中提取并识别的技术,主要包括图像提取,图像预处理,字符识别,车牌定位,字符分割五个主要核心部分.由于计算机技术的飞速发展和信息处理水平的逐渐成熟,先进的计算机技术可以将人力从复杂的人工观察检测中解放出来并提高精确度,智能交通系统成为交通领域研究的重要课题.在这样的背景下车牌识别成为了现代智能交通系统的重要部分之一,车牌识别系统使车辆的管理更加智能化,有效的提升了交通管理的效率.车牌识别系统对于维护交通安全和城市治安,防止交通堵塞,提高人们出行质量,实现现代化交通管理和智能化具有重要的现实意义.

img

2 部分代码

function varargout = Gui_Main(varargin)
% GUI_MAIN MATLAB code for Gui_Main.fig
%     GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
%     singleton*.
%
%     H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
%     the existing singleton*.
%
%     GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%     function named CALLBACK in GUI_MAIN.M with the given input arguments.
%
%     GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
%     existing singleton*. Starting from the left, property value pairs are
%     applied to the GUI before Gui_Main_OpeningFcn gets called. An
%     unrecognized property name or invalid value makes property application
%     stop. All inputs are passed to Gui_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 Gui_Main

% Last Modified by GUIDE v2.5 20-Apr-2011 14:40:49

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
   'gui_Singleton',  gui_Singleton, ...
   'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
   'gui_OutputFcn',  @Gui_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 Gui_Main is made visible.
function Gui_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 Gui_Main (see VARARGIN)

% Choose default command line output for Gui_Main
clc;
axes(handles.axes1); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes2); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
axes(handles.axes4); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
set(handles.text1, 'string''');
handles.output = hObject;
handles.file = [];
handles.Plate = [];
handles.bw = [];
handles.words = [];
% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Gui_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;

guidata(hObject, handles);

% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton1.
function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)
% hObject   handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)



% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject   handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)


% --- Executes on mouse press over axes background.
function axes2_ButtonDownFcn(hObject, eventdata, handles)
% hObject   handle to axes2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)


% --- Executes on mouse press over axes background.
function axes3_ButtonDownFcn(hObject, eventdata, handles)
% hObject   handle to axes3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)


% --- Executes on mouse press over axes background.
function axes4_ButtonDownFcn(hObject, eventdata, handles)
% hObject   handle to axes4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
if isempty(handles.Plate)
   msgbox('请先进行车牌区域标定操作!''提示信息''modal');
   return;
end
bw = Plate_Process(handles.Plate, 0);
axes(handles.axes3); cla reset; box on; set(gca, 'XTickLabel', [], 'YTickLabel', []);
imshow(bw, []); title('车牌区域二值图像''FontWeight''Bold');
figure(4)
imshow(bw, []); title('车牌区域二值图像''FontWeight''Bold');
handles.bw = bw;
guidata(hObject, handles);

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
filename=handles.filename;
if isempty(handles.bw)
   msgbox('请先进行车牌区域二值化操作!''提示信息''modal');
   return;
end


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject   handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
if isempty(handles.words)
   msgbox('请先进行车牌区域字符分割操作!''提示信息''modal');
   return;
end
str = Pattern_Recognition(handles.words,handles.filename);
set(handles.text_result, 'string', str);

3 仿真结果

4 参考文献

[1]龚凯丽, and 崔馨月. "基于改进模板匹配对车牌识别问题的研究." 工程技术与发展 1.5:2.

**部分理论引用网络文献,若有侵权联系博主删除。**​

5 MATLAB代码与数据下载地址

见博客主页