function varargout = guipic(varargin)
% GUIPIC MATLAB code for guipic.fig
% GUIPIC, by itself, creates a new GUIPIC or raises the existing
% singleton*.
%
% H = GUIPIC returns the handle to a new GUIPIC or the handle to
% the existing singleton*.
%
% GUIPIC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUIPIC.M with the given input arguments.
%
% GUIPIC('Property','Value',...) creates a new GUIPIC or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before guipic_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to guipic_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 guipic
% Last Modified by GUIDE v2.5 29-Mar-2019 19:44:18
% Simon's Road
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @guipic_OpeningFcn, ...
'gui_OutputFcn', @guipic_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 guipic is made visible.
function guipic_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 guipic (see VARARGIN)
% Choose default command line output for guipic
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes guipic wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = guipic_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 ok.
function ok_Callback(hObject, eventdata, handles)
% hObject handle to ok (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 读取图像
global im
%选择图片路径
[filename,pathname]=...
uigetfile({'*.jpg';'*.bmp';'*.png'},'选择图片');
%合成路径加文件名
str=[pathname filename];
%读取图片
Image = imread(str);
[m,n,d] = size(Image);
% 3024*4032
if m >2900
Image = imresize(Image,0.1786);
% 1920*1440
else if m >1400
Image = imresize(Image,0.3750);
end
end
im = Image;
%使用第一个AXES
axes(handles.axes9);
%显示图片
imshow(im);
title('输入原图')
% --- 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)
% 退出
close(gcf)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 清除
% axes(handles.axes1);
% cla;
cla(handles.axes9,'reset');
axes(handles.axes9);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
cla(handles.axes14,'reset');
axes(handles.axes14);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
cla(handles.axes15,'reset');
axes(handles.axes15);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
cla(handles.axes16,'reset');
axes(handles.axes16);
set(gca,'Xtick',[]);
set(gca,'Ytick',[]);
box on;
set(handles.edit7,'String',' ');
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
% --- Executes during object creation, after setting all properties.
function axes4_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes4
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im
%% 识别
image = im;
%% 交通标志检测
% 转化到hsv颜色空间
imgHSV = rgb2hsv(image);
% 提取标志 按照颜色来分
% 分离颜色通道 + 中值滤波
imgV = medfilt2(imgHSV(:,:,3));
imgS = medfilt2(imgHSV(:,:,2));
% 初始化标志空间
sz = size(imgHSV(:,:,1));
% imgSignR = zeros(sz,'logical');
% hsv颜色空间分割
imgSignR = imgS >= 0.32 & imgV >= 0.5;
% 图像下1/3部分不会出现红绿灯
[m,n] = size(imgSignR);
imgSignR(2*round(m/3):end,:) = 0*imgSignR(2*round(m/3):end,:) ;
axes(handles.axes14);
imshow(imgSignR);
title('HSV颜色空间分割')
% 二值化图像形态学处理
imgSignR = bwareaopen(imgSignR,1);
imgSignR = imfill(imgSignR,'holes');
seYR = strel('disk' ,2);
imgSignR = imclose(imgSignR,seYR);
imgSignR = imfill(imgSignR,'holes');
axes(handles.axes15);
imshow(imgSignR);
title('形态学处理后')
% 提取标志
blobR = BlobSignR(imgSignR);
% 显示结果
count = 0;alltitle = [] ;
axes(handles.axes16);
imshow(image);
% z载入svm模型
load model.mat
% 框处标志
if max(size(blobR)) ~= 0
for j = 1 : max(size(blobR))
II = imcrop( image, blobR(j).BoundingBox );
imwrite(II,['./output/' num2str(clock) '.jpg'])
%%%%% 1 颜色矩 %% %%%%%% 1*225
feature1=colorMom(II);
% 灰度化
if size(II,3) >1
II = rgb2gray(II);
end
%%%%% 3 gabor纹理 %%%%%% 1*160
image0 = imresize(II,[32 32]);
feature2 = Gabor_palm(image0);
feature = [feature1,feature2];
[p_svm, accuracy_svm, p_svm_prob] = svmpredict(1,double(feature), model_svm);
if p_svm~=1
rectangle('Position',blobR(j).BoundingBox,'EdgeColor','b','LineWidth',2);
text(blobR(j).BoundingBox(1),blobR(j).BoundingBox(2), Name{p_svm}, 'color','b','fontsize', 12);
alltitle = [alltitle ' ' Name{p_svm}] ;
end
count = count + 1;
end
end
title(alltitle)
% 显示识别结果
set(handles.edit7,'String',alltitle);
set(handles.edit7,'ForegroundColor',[0,0,1]);
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2doubl
没有合适的资源?快使用搜索试试~ 我知道了~
基于Matlab红绿灯识别系统
共2000个文件
jpg:1984个
m:10个
mexw64:2个
需积分: 5 11 下载量 150 浏览量
2023-09-15
14:41:19
上传
评论 2
收藏 294.73MB RAR 举报
温馨提示
使用SVM分类算法对红绿灯颜色、纹理进行识别 GUI界面
资源推荐
资源详情
资源评论
收起资源包目录
基于Matlab红绿灯识别系统 (2000个子文件)
libsvm.dll 156KB
svm-predict.exe 123KB
84.jpg 71KB
2021 4 22 10 33 18.696.jpg 6KB
30_12.jpg 6KB
80_21.jpg 4KB
17_11.jpg 3KB
2021 4 22 10 33 19.174.jpg 3KB
30_23.jpg 3KB
2021 4 21 16 51 41.068.jpg 2KB
27_18.jpg 2KB
2021 4 21 15 51 8.653.jpg 2KB
2021 4 21 15 48 38.452.jpg 2KB
17_8.jpg 2KB
17_2.jpg 2KB
4_1.jpg 2KB
80_23.jpg 2KB
2021 4 21 17 12 12.491.jpg 2KB
2021 4 22 10 20 46.486.jpg 2KB
75_0.jpg 2KB
2021 4 21 9 30 3.975.jpg 2KB
2021 5 1 11 23 42.361.jpg 2KB
27_16.jpg 2KB
2021 4 22 9 41 1.186.jpg 2KB
2021 4 29 10 57 20.47.jpg 2KB
2021 4 22 9 24 50.058.jpg 2KB
80_16.jpg 2KB
69_8.jpg 2KB
80_26.jpg 2KB
52_11.jpg 2KB
52_0.jpg 2KB
85_9.jpg 2KB
2021 4 21 15 51 8.542.jpg 2KB
72_2.jpg 2KB
80_27.jpg 2KB
2021 4 21 15 51 8.889.jpg 1KB
12_2.jpg 1KB
80_24.jpg 1KB
2021 4 21 16 9 10.58.jpg 1KB
2021 4 21 11 53 12.372.jpg 1KB
2021 4 21 11 56 58.405.jpg 1KB
2021 4 21 16 11 35.264.jpg 1KB
6_5.jpg 1KB
2021 4 22 9 24 49.972.jpg 1KB
39_15.jpg 1KB
39_7.jpg 1KB
2021 4 21 17 2 32.08.jpg 1KB
2021 4 21 17 12 12.654.jpg 1KB
5_4.jpg 1KB
53_14.jpg 1KB
2021 4 22 9 43 9.016.jpg 1KB
2021 4 22 9 45 22.93.jpg 1KB
2021 4 29 10 58 19.669.jpg 1KB
8_4.jpg 1KB
2021 4 28 10 2 0.072.jpg 1KB
19_6.jpg 1KB
52_10.jpg 1KB
2021 4 21 16 29 55.256.jpg 1KB
11_4.jpg 1KB
43_4.jpg 1KB
2021 4 21 16 32 22.553.jpg 1KB
2021 4 21 15 51 8.851.jpg 1KB
2021 4 21 15 48 38.653.jpg 1KB
21_3.jpg 1KB
2021 4 21 11 53 12.426.jpg 1KB
2021 4 21 16 9 10.63.jpg 1KB
2021 4 21 16 11 35.316.jpg 1KB
2021 4 21 11 56 58.462.jpg 1KB
2021 4 22 9 52 0.528.jpg 1KB
2021 4 22 10 51 41.426.jpg 1KB
85_15.jpg 1KB
85_17.jpg 1KB
9_0.jpg 1KB
75_13.jpg 1KB
2021 4 21 16 54 2.67.jpg 1KB
80_11.jpg 1KB
2021 4 22 9 24 50.194.jpg 1KB
30_30.jpg 1KB
2021 4 22 10 33 19.452.jpg 1KB
2021 4 21 16 32 22.51.jpg 1KB
1_2.jpg 1KB
2021 4 21 17 21 42.65.jpg 1KB
2021 4 29 10 53 24.529.jpg 1KB
20_25.jpg 1KB
2021 4 21 16 29 55.119.jpg 1KB
69_7.jpg 1KB
85_24.jpg 1KB
13_0.jpg 1KB
2021 4 22 10 33 19.494.jpg 1KB
30_31.jpg 1KB
69_2.jpg 1KB
2021 4 22 10 17 17.233.jpg 1KB
4_2.jpg 1KB
85_27.jpg 1KB
2021 4 22 9 24 50.153.jpg 1KB
2021 4 22 10 9 54.214.jpg 1KB
80_25.jpg 1KB
12_1.jpg 1KB
2021 4 21 15 45 21.307.jpg 1KB
2021 4 21 11 41 17.803.jpg 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
光头勇
- 粉丝: 13
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功