交通信号灯控制主要是利用检测技术和传感技术来检测交通参数,以此为基础进行控制。在交通压力日渐增大的背景下,各个路口车流量不均衡的问题逐渐凸显出来,往往一边路口车流量较小而绿灯开启时间长,另一路口车流量较大而绿灯开启时间短,这种不合理的控制严重影响了城市交通的顺畅性,如何实现交通信号灯的智能控制越来越受到关注。对交通灯的识别主要基于对交通灯的色彩及形状特征.基于信号灯的亮度对其进行分割,提取,并设置了一种自动最优选择阈值的方法.再由HIS彩色空间的H信息识别颜色.最后根据二值化的交通灯的横坐标和纵坐标方向的投影进行形状匹配识别.
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
[1]李佳阳, 刘奇. 基于MATLAB的交通信号灯识别方法[J]. 甘肃科技, 2016, 32(23):4.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。