-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.m
245 lines (206 loc) · 7.29 KB
/
Settings.m
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
function varargout = Settings(varargin)
%% Initialization code.
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Settings_OpeningFcn, ...
'gui_OutputFcn', @Settings_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
function Settings_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
if strcmp(get(hObject,'Visible'),'off')
initial = imread('initialsp1.png'); % application logo print in axes1
imagesc(initial);
axis off;
end
function varargout = Settings_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case 1
case 2
case 3
refimg = imread('refcam3.jpg');
imagesc(refimg)
axis off;
case 4
refimg = imread('refcam4.jpg');
imagesc(refimg)
axis off;
end
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
set(hObject, 'String', {'INComing','OUTGoing','Camera3', 'Camera4'});
%%% Button Update Reference Image
% this will start the selected camera, take 3 consecutive images and sum
% them all to form a single image as reference image and save it
function pushbutton1_Callback(hObject, eventdata, handles)
axes(handles.axes1);
cla;
load('slots.mat');
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case 1
try
vid = ipcam(camurl1);
catch E
msgbox({'Configure The Cam Correctly!',' ',E.message},'CAM INFO')
end
case 2
try
vid = ipcam(camurl2);
catch E
msgbox({'Configure The Cam Correctly!',' ',E.message},'CAM INFO')
end
case 3
try
vid = ipcam(camurl3);
catch E
msgbox({'Configure The Cam Correctly!',' ',E.message},'CAM INFO')
end
case 4
try
vid = ipcam(camurl4);
catch E
msgbox({'Configure The Cam Correctly!',' ',E.message},'CAM INFO')
end
end
guidata(hObject, handles);
img = snapshot(vid);
handles.vid=vid;
hImage = image( zeros(size(img)) );
preview(handles.vid, hImage)
pause(5)
img1 = snapshot(vid); pause(1)
img2 = snapshot(vid); pause(1)
img3 = snapshot(vid); pause(1)
closePreview(vid)
bk_img = double(img1)+double(img2)+double(img3);
mean_img = uint8(bk_img / 3);
switch popup_sel_index
case 1
%imwrite(mean_img,'refcam1.jpg','jpg');
case 2
%imwrite(mean_img,'refcam2.jpg','jpg');
case 3
imwrite(mean_img,'refcam3.jpg','jpg');
case 4
imwrite(mean_img,'refcam4.jpg','jpg');
end
imagesc(mean_img);
axis off;
%%% Button Add slots
% This will openup the saved refence image and will provide with an option
% to select the parking spots
function pushbutton2_Callback(hObject, eventdata, handles)
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case 1
%do nothing
case 2
%do nothing
case 3
imageObj = imread('refcam3.jpg');
imageHandle = imagesc(imageObj);
axis off;
[clicked_col clicked_row rgb_info] = impixel
corcam3 = zeros(length(clicked_col),2);
if ~isempty(clicked_col)
for x=1:1:length(clicked_col)
corcam3(x,1) = clicked_col(x);
corcam3(x,2) = clicked_row(x);
end
end
save('slots.mat', 'corcam3','-append')
set(handles.listbox1, 'String',num2str(corcam3(:,:)));
case 4
imageObj = imread('refcam4.jpg');
imageHandle = imagesc(imageObj);
axis off;
[clicked_col clicked_row rgb_info] = impixel
corcam4 = zeros(length(clicked_col),2);
if ~isempty(clicked_col)
for x=1:1:length(clicked_col)
corcam4(x,1) = clicked_col(x);
corcam4(x,2) = clicked_row(x);
end
end
save('slots.mat', 'corcam4','-append')
set(handles.listbox1, 'String',num2str(corcam4(:,:)));
end
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%%% Button Camera Configuration
% will jump to cameraconfig function
function pushbutton3_Callback(hObject, eventdata, handles)
cameraconfig()
%%% Parameter Tweaking options
% will provide editboxes to typein parameters and will save them after
% pressing save button
function edit1_Callback(hObject, eventdata, handles)
% does nothing
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
a=load('slots.mat', 'hsize');
set(hObject,'String',num2str(a.hsize));
function edit2_Callback(hObject, eventdata, handles)
% does nothing
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
a=load('slots.mat', 'sigma');
set(hObject,'String',num2str(a.sigma));
function edit3_Callback(hObject, eventdata, handles)
% does nothing
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
a=load('slots.mat', 'eliminate');
set(hObject,'String',num2str(a.eliminate));
function edit4_Callback(hObject, eventdata, handles)
% does nothing
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
a=load('slots.mat', 'thres');
set(hObject,'String',num2str(a.thres));
% Save button
function pushbutton4_Callback(hObject, eventdata, handles)
hsize = get(handles.edit1,'String');
save('slots.mat', 'hsize','-append')
sigma = get(handles.edit2,'String');
save('slots.mat', 'sigma','-append')
eliminate = get(handles.edit3,'String');
save('slots.mat', 'eliminate','-append')
thres = get(handles.edit4,'String');
save('slots.mat', 'thres','-append')