ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【图像识别】基于模板匹配交通标志识别matlab代码

2021-12-19 11:34:35  阅读:188  来源: 互联网

标签:图像识别 gui global hObject handles matlab trsUI eventdata 交通标志


1 简介

交通标志的检测与识别是智能车无人驾驶的重要组成部分,它也是解决交通安全问题的一种有效方法。在现实中由于分辨率,气象条件,照明强度和运动模糊等干扰,交通标志的图像质量通常很差,很难被检测,所以如何排除以上干扰,提高交通标志的检测和识别准确率是当前这一领域亟待解决的问题。交通标志的检测与识别问题主要包括两个部分:如何在获取的图像中准确找到交通标志,如何对提取的交通标志图片实现准确识别或分类。本文采用不变矩特征模板匹配算法实现交通标志识别。

2 部分代码

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

% Last Modified by GUIDE v2.5 19-Feb-2021 15:53:44

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

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

% Update handles structure
guidata(hObject, handles);

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


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

global I1;
global mb1;
global mb2;
global x;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
   %m_file_open (hObject, eventdata, handles);
  [FileName,PathName ]= uigetfile({'*.bmp';'*.png';'*.jpg';'*.*'},'Select an image');
   axes(handles.axes1);%用axes命令设定当前操作的坐标轴是axes_src
   fpath=[PathName FileName];%将文件名和目录名组合成一个完整的路径
   %I1 = imread(FileName);
   global I1;
   I1 = imread(FileName);
   imshow(I1);

% 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)


% Hint: edit 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 pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
   global I;
   global mb1;
   global mb2;
   I=imread('禁止停车.bmp');
   mb1=tuxiangchuli(I);
   I=imread('禁止驶入.bmp');
   mb2=tuxiangchuli(I);
   

% 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)


% --- 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)
   global I1;
   global x;
   x=tuxiangshibie(I1);
   set(handles.xData,'string',num2str(x));
   guidata(hObject, handles);   
   drawnow;


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
   global mb1;
   global mb2;
   global x;
   d1=oushijuli(mb1,x);
   d2=oushijuli(mb2,x);
   if(d1<2)
       resultData='禁止车辆临时或长时停放标志';
       set(handles.mbData,'string',num2str(mb1));
   %end
   else if(d2<2)
       resultData='禁止驶入标志';
       set(handles.mbData,'string',num2str(mb2));
   else 
       resultData='无法识别';
       end
   end
   
   set(handles.result,'string',resultData);
   guidata(hObject, handles);   
   drawnow;
   

   

% 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)



function edit2_Callback(hObject, eventdata, handles)
% hObject   handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%       str2double(get(hObject,'String')) returns contents of edit2 as a double


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

% Hint: edit 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



function edit3_Callback(hObject, eventdata, handles)
% hObject   handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%       str2double(get(hObject,'String')) returns contents of edit3 as a double


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

% Hint: edit 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

3 仿真结果

4 参考文献

[1]韩毅, 景琳浪, 谷昭斌. 基于MATLAB的交通标志自动识别装置[J].  2012.

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

图片

 

标签:图像识别,gui,global,hObject,handles,matlab,trsUI,eventdata,交通标志
来源: https://blog.csdn.net/qq_59747472/article/details/122021794

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有