当前位置:网站首页>[traffic light identification] traffic light identification based on Matlab GUI [including Matlab source code 1908]

[traffic light identification] traffic light identification based on Matlab GUI [including Matlab source code 1908]

2022-06-24 00:09:00 Poseidon light

One 、 Introduction to traffic light identification

By 2015 year , The prevalence of blind people worldwide is 0.49%, There are about 3600 Ten thousand blind people , In our country 50 Blind people over the age of 532 ten thousand . Blind people have many difficulties in traveling . At present, there are not many researches on traffic light recognition for blind people in the market , The image recognition technology of identifying traffic lights is often applied to driverless technology . In this paper, we design a histogram threshold segmentation method HSV Traffic light recognition method for color recognition .

Threshold segmentation is a common image processing method , Because of its fast calculation speed 、 Implement a simple , So it is widely used in image processing . This method mainly calculates the corresponding criterion function according to the probability distribution of histogram , At the same time, intelligent optimization algorithm is used to speed up the threshold search , Thus, the appropriate threshold is selected for segmentation . among , Histogram threshold method is based on image histogram , Analyze it to realize image segmentation .HSV Color spatial 3 The components are relatively independent , and H and S The component is little affected by light and shadow occlusion . Use HSV Color space , Using different color threshold to recognize traffic light color , Eliminate most external environmental interference , Accurate and reliable .

1 Preprocessing
The street view image naturally captured by the camera contains complex and tedious graphics , And the change of external light affects the clarity of the image 、 The resolution has some influence . The preprocessing of street view image mainly includes image enhancement , Simple preprocessing methods include graying 、 Image enhancement and other steps . Han Zheng et al. Proposed an image binarization enhancement algorithm based on Monte Carlo simulation . At this stage , The accuracy of machine vision is insufficient . In practical industrial applications , The accuracy of machine vision is far lower than the experimental results , When the measuring environment changes , There will be a large deviation in the results , Poor adaptability to the environment . Changes in the external environment affect the shooting effect of street view images , It interferes with the location and identification of traffic lights . In order to reduce the interference of external environmental factors , Grayscale the image 、 Sharpen and enhance noise reduction . The pretreatment process is shown in the figure 1 Shown .
 Insert picture description here
chart 1 Pretreatment process
2 Location of traffic lights
For a grayscale image , Histogram of the image [8] It can be regarded as an approximation of the probability density distribution function of pixel gray value . Suppose an image contains only the target object and the background , Then the histogram distribution of the image can be regarded as the probability density distribution of pixels with only the target object and the background .
Suppose that the gray level range of the histogram of a gray-scale image is i=0,1,2……k, Then the total pixels of this image are :
 Insert picture description here
Gray scale i The probability of occurrence is :
 Insert picture description here
Using histogram threshold segmentation algorithm to achieve image segmentation , Put forward hyperbolic two-dimensional Otsu Threshold segmentation algorithm , Using fuzzy histogram model to track moving objects , This paper uses histogram threshold segmentation method , It is suitable for simple traffic light segmentation . According to the histogram of gray image, the segmentation threshold of image can be analyzed , For grayscale images with obvious peaks and troughs , This method is accurate . The traffic light segmentation and positioning results are shown in the figure 2 Shown . chart 2 The first image in is the image after the first segmentation , It can be seen that its outline is blurred , It is not conducive to subsequent accurate positioning . Carry out corrosion operation on it , The outline is clearer than before . You can see , There are scattered noises in the second binary image , Use median filter to reduce noise , Get the final binary image . The chassis color of traffic lights is black , And in the images taken in real time , The traffic lights are usually located in the upper middle of the image , In the resulting image , Find the smallest element in the image matrix , The corresponding row is the row with the most black pixels in the binary image . Because in daily life , Whether it is a horizontal traffic light or a vertical traffic light , Length of traffic lights 、 The width and area are fixed , Thus, the position of the traffic light in the image can be determined .

3 Traffic light color recognition
RGB Color space :RGB Color mode is the most commonly used mode in industry , These include red (R)、 green (G) And blue (B). An image from this 3 It consists of two channels .HSV Color space :HSV The parameter of color in the model is hue (H)、 saturation (S) And brightness (V).

RGB Model is the most familiar color model , but RGB 3 High correlation of components , Cannot be used to separate two areas of similar color .HSV The model is also a color model ,HSV(hue,saturation,value) They represent hues 、 Saturation and lightness ,HSV Model ratio RGB The model is closer to people's perception of color ;HSV The model eliminates 3 Correlation between components , It has a better effect when dealing with images with similar colors .

about HSV Image color recognition , Through red, green and red 3 Colored HSV Values are different , Judge the color of the traffic light at the moment . First , take RGB Color is converted to HSV Model , Use the difference between the two models for numerical conversion . Red, yellow and green 3 Colored HSV Each are not identical , According to the red HSV The number , Set red respectively 、 green 、 yellow HSV Upper and lower limits of values . besides , Considering that there may be some differences in the color of traffic lights , For example, the red light of some traffic lights is more orange , Green tends to be cyan , And in the environment of strong light and weak light, the light also shows white , Set up HSV Numerical time , Put orange, cyan and white HSV The upper and lower bounds are added to the algorithm . Extract the traffic light image after segmentation HSV The value of three channels , According to the set HSV threshold , Determine which color components in the image occupy the majority , You can judge the status of the traffic lights at the moment .

Two 、 Partial source code

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;      % The following is all about setting the attributes of the drawing area 
handles.cd0 = cd;
handles.Color = 0;
handles.I = [];

axes(handles.axes1);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;

3、 ... and 、 Running results

 Insert picture description here
 Insert picture description here

Four 、matlab Edition and references

1 matlab edition
2014a

2 reference
[1] Cai Limei .MATLAB The image processing —— theory 、 Algorithm and example analysis [M]. tsinghua university press ,2020.
[2] Yang Dan , Zhao Haibin , Long Zhe .MATLAB Detailed explanation of image processing examples [M]. tsinghua university press ,2013.
[3] Zhou pin .MATLAB Image processing and graphical user interface design [M]. tsinghua university press ,2013.
[4] Liu Chenglong . Master MATLAB The image processing [M]. tsinghua university press ,2015.
[5] GUI Xinyue , Li Zhenwei , Wuchenchen , Liyanyue . be based on MATLAB Research on traffic light recognition system based on [J]. Electronic Design Engineering . 2020,28(16)

3 remarks
This part of the introduction is taken from the Internet , For reference only , If infringement , Contact deletion

原网站

版权声明
本文为[Poseidon light]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206232143063199.html