【图像识别】基于计算机视觉实现红绿灯识别含Matlab代码
?1 簡介
交通信號燈控制主要是利用檢測技術和傳感技術來檢測交通參數,以此為基礎進行控制。在交通壓力日漸增大的背景下,各個路口車流量不均衡的問題逐漸凸顯出來,往往一邊路口車流量較小而綠燈開啟時間長,另一路口車流量較大而綠燈開啟時間短,這種不合理的控制嚴重影響了城市交通的順暢性,如何實現交通信號燈的智能控制越來越受到關注。對交通燈的識別主要基于對交通燈的色彩及形狀特征.基于信號燈的亮度對其進行分割,提取,并設置了一種自動最優選擇閾值的方法.再由HIS彩色空間的H信息識別顏色.最后根據二值化的交通燈的橫坐標和縱坐標方向的投影進行形狀匹配識別.
2 部分代碼
function varargout = Maindeng(varargin)
% MAINDENG MATLAB code for Maindeng.fig
% ? ? ?MAINDENG, by itself, creates a new MAINDENG or raises the existing
% ? ? ?singleton*.
%
% ? ? ?H = MAINDENG returns the handle to a new MAINDENG or the handle to
% ? ? ?the existing singleton*.
%
% ? ? ?MAINDENG('CALLBACK',hObject,eventData,handles,...) calls the local
% ? ? ?function named CALLBACK in MAINDENG.M with the given input arguments.
%
% ? ? ?MAINDENG('Property','Value',...) creates a new MAINDENG or raises the
% ? ? ?existing singleton*. ?Starting from the left, property value pairs are
% ? ? ?applied to the GUI before Maindeng_OpeningFcn gets called. ?An
% ? ? ?unrecognized property name or invalid value makes property application
% ? ? ?stop. ?All inputs are passed to Maindeng_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 Maindeng
% Last Modified by GUIDE v2.5 21-Jun-2022 22:14:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', ? ? ? mfilename, ...
? ? ? ? ? ? ? ? ? ?'gui_Singleton', ?gui_Singleton, ...
? ? ? ? ? ? ? ? ? ?'gui_OpeningFcn', @Maindeng_OpeningFcn, ...
? ? ? ? ? ? ? ? ? ?'gui_OutputFcn', ?@Maindeng_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 Maindeng is made visible.
function Maindeng_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 Maindeng (see VARARGIN)
% Choose default command line output for Maindeng
handles.output = hObject; ? ? ?%下面全部為設定作圖區域屬性
handles.cd0 = cd;
handles.Color = 0;
handles.I = [];
axes(handles.axes1);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes2);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes3);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
axes(handles.axes4);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Maindeng wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Maindeng_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 button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject ? ?handle to radiobutton3 (see GCBO)
% eventdata ?reserved - to be defined in a future version of MATLAB
% handles ? ?structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
Y=[Y(1,:),Y(2,:)]; ?Y=minmax(Y);
GI=GI(x1:x2,Y(1):Y(2)); ? ? ? ? %定位圖像區域
a=handles.sin;
a=a(x1:x2,Y(1):Y(2),:); ?handles.image=a;
axes(handles.axes4);
imshow(GI);
title('圖像分割');?
handles.GI = GI; ? ? ? %將當前的圖像數據傳遞給全局句柄
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 text2.
function text2_ButtonDownFcn(hObject, eventdata, handles)
% hObject ? ?handle to text2 (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.string);
? ?set(handles.text2,'string',handles.string);?
end
?
3 仿真結果
4 參考文獻
[1]李佳陽, 劉奇. 基于MATLAB的交通信號燈識別方法[J]. 甘肅科技, 2016, 32(23):4.
博主簡介:擅長智能優化算法、神經網絡預測、信號處理、元胞自動機、圖像處理、路徑規劃、無人機等多種領域的Matlab仿真,相關matlab代碼問題可私信交流。
部分理論引用網絡文獻,若有侵權聯系博主刪除。
總結
以上是生活随笔為你收集整理的【图像识别】基于计算机视觉实现红绿灯识别含Matlab代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 格式工厂DIVX、AVC、HEVC三个格
- 下一篇: 《我的成功可以复制》读后感