-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMark_Road.m
More file actions
executable file
·335 lines (299 loc) · 11.9 KB
/
Copy pathMark_Road.m
File metadata and controls
executable file
·335 lines (299 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
function varargout = Mark_Road(varargin)
% MARK_ROAD MATLAB code for Mark_Road.fig
% MARK_ROAD, by itself, creates a new MARK_ROAD or raises the existing
% singleton*.
%
% H = MARK_ROAD returns the handle to a new MARK_ROAD or the handle to
% the existing singleton*.
%
% MARK_ROAD('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MARK_ROAD.M with the given input arguments.
%
% MARK_ROAD('Property','Value',...) creates a new MARK_ROAD or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Mark_Road_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Mark_Road_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 Mark_Road
% Last Modified by GUIDE v2.5 01-Jan-2017 18:20:51
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Mark_Road_OpeningFcn, ...
'gui_OutputFcn', @Mark_Road_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 Mark_Road is made visible.
function Mark_Road_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Mark_Road
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Mark_Road wait for user response (see UIRESUME)
% uiwait(handles.figure_mark);
setappdata(handles.figure_mark,'img_src',0);
setappdata(handles.figure_mark,'index',1);
setappdata(handles.figure_mark,'count',1);
setappdata(handles.figure_mark,'pathname',' ');
setappdata(handles.figure_mark,'list',' ');
axes(handles.axes_road);imshow(imread('.\pic\road.png'));
axes(handles.axes_sidewalk);imshow(imread('.\pic\sidewalk.png'));
axes(handles.axes_nopark);imshow(imread('.\pic\nopark.png'));
axes(handles.axes_guide);imshow(imread('.\pic\guide.png'));
axes(handles.axes_police);imshow(imread('.\pic\police.png'));
axes(handles.axes_lane);imshow(imread('.\pic\lane.png'));
axes(handles.axes_stop);imshow(imread('.\pic\stop.png'));
axes(handles.axes_warn_sidewalk);imshow(imread('.\pic\warn_sidewalk.png'));
axes(handles.axes_followme);imshow(imread('.\pic\followme.png'));
axes(handles.axes_stop_wait);imshow(imread('.\pic\stop_wait.png'));
axes(handles.axes_none_vehicle);imshow(imread('.\pic\none_vehicle.png'));
axes(handles.axes_src);
% --- Outputs from this function are returned to the command line.
function varargout = Mark_Road_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------------------------------------------------------
function m_open_Callback(hObject, eventdata, handles)
% hObject handle to m_open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% [filename, pathname] = uigetfile( ...
% {'*.txt','All Files (*.*)'; ...
% '*.*', 'All Files (*.*)'}, ...
% 'Pick an image');
% if isequal(filename,0) || isequal(pathname,0),
% return;
% end
%
% axes(handles.axes_src);
% fpath=[pathname filename];
global path_image; global path_list; global path_save;
global width; global height;
global gt_img; global img;
global list;
index = 1;
path_image = '.\image\';
path_list = '.\list.txt';
path_save = '.\gt\';
list_cell = textread(path_list,'%s');
list = char(list_cell);
img=imread([path_image list(index,:)]);
gt_img = zeros(size(img,1),size(img,2),'uint8');
width = size(img,1);
height = size(img,2);
axes(handles.axes_src);
filename_gt = [path_save 'gt_' list(index,:)];
if ~isempty(dir(filename_gt))
gt_img = imread(filename_gt);
show_mark(gt_img,img);
else
imshow(img);
end
set(findobj('tag','m_index'),'string',int2str(index));
setappdata(handles.figure_mark,'list',list);
setappdata(handles.figure_mark,'count',size(list,1));
setappdata(handles.figure_mark,'index',index);
% --- Executes on button press in m_last.
function m_last_Callback(hObject, eventdata, handles)
global path_image; global path_list; global path_save; global list;
global width; global height;
global gt_img; global img;
index = getappdata(handles.figure_mark,'index');
index = index - 1;
axes(handles.axes_src);
if(index < 1)
index =1;
else
img=imread([path_image list(index,:)]);
filename_gt = [path_save 'gt_' list(index,:)];
if ~isempty(dir(filename_gt))
gt_img = imread(filename_gt);
show_mark(gt_img,img);
else
gt_img(:,:) = 0;
imshow(img);
end
end
set(findobj('tag','m_index'),'string',int2str(index));
setappdata(handles.figure_mark,'index',index);
% --- Executes on button press in m_next.
function m_next_Callback(hObject, eventdata, handles)
global path_image; global path_list; global path_save; global list;
global width; global height;
global gt_img; global img;
index = getappdata(handles.figure_mark,'index');
count = getappdata(handles.figure_mark,'count');
index = index + 1;
if(index > count)
index =count;
else
img=imread([path_image list(index,:)]);
filename_gt = [path_save 'gt_' list(index,:)];
if ~isempty(dir(filename_gt))
gt_img = imread(filename_gt);
show_mark(gt_img,img);
else
gt_img(:,:) = 0;
imshow(img);
end
end
set(findobj('tag','m_index'),'string',int2str(index));
setappdata(handles.figure_mark,'index',index);
% --- Executes on button press in m_road.
function m_road_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 1;
show_mark(gt_img, img);
% --- Executes on button press in m_sidewalk.
function m_sidewalk_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 2;
show_mark(gt_img, img);
% --- Executes on button press in m_nopark.
function m_nopark_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 3;
show_mark(gt_img, img);
% --- Executes on button press in m_guide.
function m_guide_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 4;
show_mark(gt_img, img);
% --- Executes on button press in m_police.
function m_police_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 5;
show_mark(gt_img, img);
% --- Executes on button press in m_lane_w_s.
function m_lane_w_s_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 6;
show_mark(gt_img, img);
% --- Executes on button press in m_lane_w_d.
function m_lane_w_d_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 7;
show_mark(gt_img, img);
% --- Executes on button press in m_lane_y_s.
function m_lane_y_s_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 8;
show_mark(gt_img, img);
% --- Executes on button press in m_lane_y_d.
function m_lane_y_d_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 9;
show_mark(gt_img, img);
% --- Executes on button press in m_stop.
function m_stop_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 10;
show_mark(gt_img, img);
% --- Executes on button press in m_warn_sidewalk.
function m_warn_sidewalk_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 11;
show_mark(gt_img, img);
% --- Executes on button press in m_forward.
function m_forward_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 12;
show_mark(gt_img, img);
% --- Executes on button press in m_left.
function m_left_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 13;
show_mark(gt_img, img);
% --- Executes on button press in m_right.
function m_right_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 14;
show_mark(gt_img, img);
% --- Executes on button press in m_forward_left.
function m_forward_left_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 15;
show_mark(gt_img, img);
% --- Executes on button press in m_forward_right.
function m_forward_right_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 16;
show_mark(gt_img, img);
% --- Executes on button press in m_left_right.
function m_left_right_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 17;
show_mark(gt_img, img);
% --- Executes on button press in m_stop_wait.
function m_stop_wait_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 18;
show_mark(gt_img, img);
% --- Executes on button press in m_none_vehicle.
function m_none_vehicle_Callback(hObject, eventdata, handles)
global width; global height; global gt_img; global img;
imshow(img);
mask = poly(width,height);
gt_img(find(mask ==true)) = 19;
show_mark(gt_img, img);
% --- Executes on button press in m_save.
function m_save_Callback(hObject, eventdata, handles)
global path_save; global gt_img; global list;
index = getappdata(handles.figure_mark,'index');
imwrite(gt_img,[path_save 'gt_' list(index,:)], 'Mode', 'lossless');
% --- Executes on button press in m_delete.
function m_delete_Callback(hObject, eventdata, handles)
global gt_img; global img;
gt_img(:,:) = 0;
show_mark(gt_img, img);