[37] | 1 | % By Philip Torr 2002 |
---|
| 2 | % copyright Microsoft Corp. |
---|
| 3 | % |
---|
| 4 | % %designed for the good of the world by Philip Torr based on ideas contained in |
---|
| 5 | % copyright Philip Torr and Microsoft Corp 2002 |
---|
| 6 | % |
---|
| 7 | % @inproceedings{Torr93b, |
---|
| 8 | % author = "Torr, P. H. S. and Murray, D. W.", |
---|
| 9 | % title = "Outlier Detection and Motion Segmentation", |
---|
| 10 | % booktitle = "Sensor Fusion VI", |
---|
| 11 | % editor = "Schenker, P. S.", |
---|
| 12 | % publisher = "SPIE volume 2059", |
---|
| 13 | % note = "Boston", |
---|
| 14 | % pages = {432-443}, |
---|
| 15 | % year = 1993 } |
---|
| 16 | % |
---|
| 17 | % |
---|
| 18 | % @phdthesis{Torr:thesis, |
---|
| 19 | % author="Torr, P. H. S.", |
---|
| 20 | % title="Outlier Detection and Motion Segmentation", |
---|
| 21 | % school=" Dept. of Engineering Science, University of Oxford", |
---|
| 22 | % year=1995} |
---|
| 23 | % |
---|
| 24 | % @inproceedings{Beardsley96a, |
---|
| 25 | % author="Beardsley, P. and Torr, P. H. S. and Zisserman, A.", |
---|
| 26 | % title="{3D} Model Aquisition from Extended Image Sequences", |
---|
| 27 | % booktitle=eccv4.2, |
---|
| 28 | % editor = "Buxton, B. and Cipolla R.", |
---|
| 29 | % publisher = "Springer--Verlag", |
---|
| 30 | % pages={683--695}, |
---|
| 31 | % year=1996} |
---|
| 32 | % |
---|
| 33 | % |
---|
| 34 | % @article{Torr97c, |
---|
| 35 | % author="Torr, P. H. S. and Murray, D. W. ", |
---|
| 36 | % title="The Development and Comparison of Robust Methods for Estimating the Fundamental Matrix", |
---|
| 37 | % journal="IJCV", |
---|
| 38 | % volume = 24, |
---|
| 39 | % number = 3, |
---|
| 40 | % pages = {271--300}, |
---|
| 41 | % year=1997 |
---|
| 42 | % } |
---|
| 43 | % |
---|
| 44 | % |
---|
| 45 | % |
---|
| 46 | % |
---|
| 47 | % @article{Torr99c, |
---|
| 48 | % author = "Torr, P. H. S. and Zisserman, A", |
---|
| 49 | % title ="MLESAC: A New Robust Estimator with Application to Estimating Image Geometry ", |
---|
| 50 | % journal = "CVIU", |
---|
| 51 | % Volume = {78}, |
---|
| 52 | % number = 1, |
---|
| 53 | % pages = {138-156}, |
---|
| 54 | % year = 2000} |
---|
| 55 | % |
---|
| 56 | % %MAPSAC is the Bayesian version of MLESAC, and it is easier to pronounce! |
---|
| 57 | % it is described in: |
---|
| 58 | % |
---|
| 59 | % @article{Torr02d, |
---|
| 60 | % author = "Torr, P. H. S.", |
---|
| 61 | % title ="Bayesian Model Estimation and Selection for Epipolar Geometry and |
---|
| 62 | % Generic Manifold Fitting", |
---|
| 63 | % journal = "IJCV", |
---|
| 64 | % Volume = {?}, |
---|
| 65 | % number = ?, |
---|
| 66 | % pages = {?}, |
---|
| 67 | % url = "http://research.microsoft.com/~philtorr/", |
---|
| 68 | % year = 2002} |
---|
| 69 | % |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | function varargout = torr_tool(varargin) |
---|
| 74 | % TORR_TOOL Application M-file for torr_tool.fig |
---|
| 75 | % FIG = TORR_TOOL launch torr_tool GUI. |
---|
| 76 | % TORR_TOOL('callback_name', ...) invoke the named callback. |
---|
| 77 | |
---|
| 78 | % Last Modified by GUIDE v2.0 21-May-2002 17:58:20 |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | if nargin == 0 % LAUNCH GUI |
---|
| 84 | |
---|
| 85 | fig = openfig(mfilename,'reuse'); |
---|
| 86 | |
---|
| 87 | % Use system color scheme for figure: |
---|
| 88 | set(fig,'Color',get(0,'defaultUicontrolBackgroundColor')); |
---|
| 89 | |
---|
| 90 | % Generate a structure of handles to pass to callbacks, and store it. |
---|
| 91 | handles = guihandles(fig); |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | %phils atuff added, initialization |
---|
| 95 | %corner parameters |
---|
| 96 | handles.n_corners = 2000; %max no of corners permitted/requested |
---|
| 97 | |
---|
| 98 | handles.n_corners1 = 0; %the actual number detected |
---|
| 99 | handles.n_corners2 = 0; |
---|
| 100 | |
---|
| 101 | handles.corner_sigma = 1.0; |
---|
| 102 | handles.corner_width = 3; |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | %matchin parameters |
---|
| 106 | handles.max_disparity = 50; |
---|
| 107 | handles.match_half_size = 3; |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | %F parameters: |
---|
| 111 | handles.no_samp = 500; % no of samples in the mapsac algorithm |
---|
| 112 | handles.f_threshold = 6.0; % f_threshold in the mapsac algorithm |
---|
| 113 | |
---|
| 114 | %calibration matrix |
---|
| 115 | handles.focal_length = 3; %first guess |
---|
| 116 | handles.aspect_ratio = 1; |
---|
| 117 | handles.ppx = 0; |
---|
| 118 | handles.ppy = 0; |
---|
| 119 | %work out calibration matrix |
---|
| 120 | C = [handles.aspect_ratio 0 handles.ppx; 0 1 handles.ppy; 0 0 1/handles.focal_length]; |
---|
| 121 | handles.C = C; |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | %informational variables |
---|
| 126 | handles.n_matches = 0; %how many matches have we detected. |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | %general parameters |
---|
| 130 | %debugt mode |
---|
| 131 | handles.debug = 1; |
---|
| 132 | handles.m3 = 256; %third homogeous pixel coordinate, chosen as 256 to help conditioning, see my thesis |
---|
| 133 | handles.pathname = ['C:\matlabR12\bin\']; |
---|
| 134 | |
---|
| 135 | if ~handles.debug |
---|
| 136 | helpdlg('Phil asks: "how ya diddling", first load some images') |
---|
| 137 | end |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | set(handles.save_image1_button, 'Enable', 'off'); |
---|
| 141 | set(handles.save_image2_button, 'Enable', 'off'); |
---|
| 142 | set(handles.Save_Images_menu, 'Enable', 'off'); |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | %for corners |
---|
| 146 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 147 | set(handles.save_corner_button, 'Enable', 'off'); |
---|
| 148 | set(handles.load_corner_button, 'Enable', 'on'); |
---|
| 149 | set(handles.corn_param_button, 'Enable', 'off'); |
---|
| 150 | |
---|
| 151 | %for correlation matches |
---|
| 152 | set(handles.match_button, 'Enable', 'off'); |
---|
| 153 | set(handles.match_param_button, 'Enable', 'on'); |
---|
| 154 | set(handles.manual_match_button, 'Enable', 'on'); |
---|
| 155 | set(handles.save_match_button, 'Enable', 'off'); |
---|
| 156 | set(handles.load_match_button, 'Enable', 'off'); |
---|
| 157 | |
---|
| 158 | %for F and correlation matches |
---|
| 159 | set(handles.mapsac_button, 'Enable', 'off'); |
---|
| 160 | set(handles.mapsac_parameters_button, 'Enable', 'on'); |
---|
| 161 | set(handles.save_F_button, 'Enable', 'off'); |
---|
| 162 | set(handles.display_epipolar_button, 'Enable', 'off'); |
---|
| 163 | set(handles.display_epipolar_button2, 'Enable', 'off'); |
---|
| 164 | set(handles.ImproveF_button, 'Enable', 'off'); |
---|
| 165 | |
---|
| 166 | %for SFM |
---|
| 167 | set(handles.sfm_button, 'Enable', 'off'); |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | guidata(fig, handles); |
---|
| 172 | |
---|
| 173 | if nargout > 0 |
---|
| 174 | varargout{1} = fig; |
---|
| 175 | end |
---|
| 176 | |
---|
| 177 | elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK |
---|
| 178 | |
---|
| 179 | try |
---|
| 180 | [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard |
---|
| 181 | catch |
---|
| 182 | disp(lasterr); |
---|
| 183 | end |
---|
| 184 | |
---|
| 185 | end |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | %| ABOUT CALLBACKS: |
---|
| 189 | %| GUIDE automatically appends subfunction prototypes to this file, and |
---|
| 190 | %| sets objects' callback properties to call them through the FEVAL |
---|
| 191 | %| switchyard above. This comment describes that mechanism. |
---|
| 192 | %| |
---|
| 193 | %| Each callback subfunction declaration has the following form: |
---|
| 194 | %| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN) |
---|
| 195 | %| |
---|
| 196 | %| The subfunction name is composed using the object's Tag and the |
---|
| 197 | %| callback type separated by '_', e.g. 'slider2_Callback', |
---|
| 198 | %| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'. |
---|
| 199 | %| |
---|
| 200 | %| H is the callback object's handle (obtained using GCBO). |
---|
| 201 | %| |
---|
| 202 | %| EVENTDATA is empty, but reserved for future use. |
---|
| 203 | %| |
---|
| 204 | %| HANDLES is a structure containing handles of components in GUI using |
---|
| 205 | %| tags as fieldnames, e.g. handles.figure1, handles.slider2. This |
---|
| 206 | %| structure is created at GUI startup using GUIHANDLES and stored in |
---|
| 207 | %| the figure's application data using GUIDATA. A copy of the structure |
---|
| 208 | %| is passed to each callback. You can store additional information in |
---|
| 209 | %| this structure at GUI startup, and you can change the structure |
---|
| 210 | %| during callbacks. Call guidata(h, handles) after changing your |
---|
| 211 | %| copy to replace the stored original so that subsequent callbacks see |
---|
| 212 | %| the updates. Type "help guihandles" and "help guidata" for more |
---|
| 213 | %| information. |
---|
| 214 | %| |
---|
| 215 | %| VARARGIN contains any extra arguments you have passed to the |
---|
| 216 | %| callback. Specify the extra arguments by editing the callback |
---|
| 217 | %| property in the inspector. By default, GUIDE sets the property to: |
---|
| 218 | %| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo)) |
---|
| 219 | %| Add any extra arguments after the last argument, before the final |
---|
| 220 | %| closing parenthesis. |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | % -------------------------------------------------------------------- |
---|
| 224 | |
---|
| 225 | %%get rid f current stuff and do it again! |
---|
| 226 | function varargout = start_again_button_Callback(h, eventdata, handles, varargin) |
---|
| 227 | % Stub for Callback of the uicontrol handles.start_again_button. |
---|
| 228 | clear_button_Callback(h, eventdata, handles, varargin) |
---|
| 229 | initialize(handles) |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | % -------------------------------------------------------------------- |
---|
| 234 | function varargout = frame1_Callback(h, eventdata, handles, varargin) |
---|
| 235 | % Stub for Callback of the uicontrol handles.frame1. |
---|
| 236 | disp('frame1 Callback not implemented yet. O great one') |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | %---------------------------------------------------------------------\\\ |
---|
| 240 | |
---|
| 241 | function menu_OpenImage_Callback(h,eventdata,handles,varargin) |
---|
| 242 | disp('loading some images your highness') |
---|
| 243 | |
---|
| 244 | load_image_button_Callback(h, eventdata, handles, varargin) |
---|
| 245 | |
---|
| 246 | %---------------------------------------------------------------------\\\ |
---|
| 247 | |
---|
| 248 | function menu_SaveImages_Callback(h,eventdata,handles,varargin) |
---|
| 249 | |
---|
| 250 | save_image1_button_Callback(h, eventdata, handles, varargin) |
---|
| 251 | save_image_button2_Callback(h, eventdata, handles, varargin) |
---|
| 252 | |
---|
| 253 | %---------------------------------------------------------------------\\\ |
---|
| 254 | |
---|
| 255 | function menu_display_corners_Callback(h,eventdata,handles,varargin) |
---|
| 256 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 257 | display_corners_in_figure(handles); |
---|
| 258 | |
---|
| 259 | %---------------------------------------------------------------------\\\ |
---|
| 260 | |
---|
| 261 | function menu_display_c_matches_Callback(h,eventdata,handles,varargin) |
---|
| 262 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 263 | display_matches(h, eventdata, handles, varargin); |
---|
| 264 | |
---|
| 265 | %---------------------------------------------------------------------\\\ |
---|
| 266 | function menu_display_i_matches_Callback(h,eventdata,handles,varargin) |
---|
| 267 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 268 | display_inliers(h, eventdata, handles, varargin); |
---|
| 269 | |
---|
| 270 | %---------------------------------------------------------------------\\\ |
---|
| 271 | function menu_display_io_matches_Callback(h,eventdata,handles,varargin) |
---|
| 272 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 273 | display_matches(h, eventdata, handles, varargin); |
---|
| 274 | display_inliers(h, eventdata, handles, varargin); |
---|
| 275 | %---------------------------------------------------------------------\\\ |
---|
| 276 | |
---|
| 277 | % -------------------------------------------------------------------- |
---|
| 278 | function display_corners_in_figure(handles) |
---|
| 279 | |
---|
| 280 | % extracting the handle of the axes in which to display the image |
---|
| 281 | ax_handle2 = handles.axes2; |
---|
| 282 | ax_handle3 = handles.axes3; |
---|
| 283 | ccr1 = handles.ccr1; |
---|
| 284 | ccr2 = handles.ccr2; |
---|
| 285 | |
---|
| 286 | axes(ax_handle2); |
---|
| 287 | hold on |
---|
| 288 | axes(ax_handle3); |
---|
| 289 | hold on |
---|
| 290 | % plot(c_col, c_row, '+'); |
---|
| 291 | plot(ccr1(:,1), ccr1(:,2), 'g+','Parent', ax_handle2); |
---|
| 292 | plot(ccr2(:,1), ccr2(:,2), 'r+','Parent', ax_handle3); |
---|
| 293 | |
---|
| 294 | |
---|
| 295 | axes(ax_handle2); |
---|
| 296 | hold off |
---|
| 297 | axes(ax_handle3); |
---|
| 298 | hold off |
---|
| 299 | |
---|
| 300 | |
---|
| 301 | |
---|
| 302 | % -------------------------------------------------------------------- |
---|
| 303 | function varargout = detect_corner_button_Callback(h, eventdata, handles, varargin) |
---|
| 304 | % Stub for Callback of the uicontrol handles.pushbutton3. |
---|
| 305 | disp('Calculating corners.') |
---|
| 306 | |
---|
| 307 | [ccr1] = torr_charris(handles.d1,handles.n_corners,handles.corner_width,handles.corner_sigma); |
---|
| 308 | [ccr2] = torr_charris(handles.d2,handles.n_corners,handles.corner_width,handles.corner_sigma); |
---|
| 309 | |
---|
| 310 | |
---|
| 311 | %normalize so that the centre of the image is the origin... |
---|
| 312 | ccr1(:,1) = ccr1(:,1) - handles.image_centrex; |
---|
| 313 | ccr1(:,2) = ccr1(:,2) - handles.image_centrey; |
---|
| 314 | ccr2(:,1) = ccr2(:,1) - handles.image_centrex; |
---|
| 315 | ccr2(:,2) = ccr2(:,2) - handles.image_centrey; |
---|
| 316 | |
---|
| 317 | handles.ccr1 = ccr1; |
---|
| 318 | handles.ccr2 = ccr2; |
---|
| 319 | handles.n_corners1 = length(ccr1); |
---|
| 320 | handles.n_corners2 = length(ccr2); |
---|
| 321 | |
---|
| 322 | display_corners_in_figure(handles) |
---|
| 323 | |
---|
| 324 | set(handles.save_corner_button, 'Enable', 'on'); |
---|
| 325 | set(handles.match_button, 'Enable', 'on'); |
---|
| 326 | set(handles.match_param_button, 'Enable', 'on'); |
---|
| 327 | % set(handles.manual_match_button, 'Enable', 'on'); |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | guidata(handles.figure1, handles); |
---|
| 332 | % -------------------------------------------------------------------- |
---|
| 333 | |
---|
| 334 | |
---|
| 335 | %here is phil's code to get a file, it uses the warning dialog |
---|
| 336 | %it has not been properly tested |
---|
| 337 | function [filename, pathname] = uigetfile_name(filer,message) |
---|
| 338 | |
---|
| 339 | [filename, pathname] = uigetfile(filer,message) |
---|
| 340 | if isequal(filename,0)|isequal(pathname,0) |
---|
| 341 | %recurse |
---|
| 342 | [filename, pathname] = uigetfile_name(filer,message); |
---|
| 343 | else |
---|
| 344 | disp(['File ', pathname, filename, ' found']) |
---|
| 345 | end |
---|
| 346 | |
---|
| 347 | |
---|
| 348 | |
---|
| 349 | % -------------------------------------------------------------------- |
---|
| 350 | function [filename, pathname] = uiputfile_name(filer,message) |
---|
| 351 | |
---|
| 352 | [filename, pathname] = uiputfile(filer,message) |
---|
| 353 | if isequal(filename,0)|isequal(pathname,0) |
---|
| 354 | [filename, pathname] = uiputfile_name(filer,message); |
---|
| 355 | else |
---|
| 356 | disp(['File ', pathname, filename, ' has been saved']) |
---|
| 357 | end |
---|
| 358 | |
---|
| 359 | |
---|
| 360 | |
---|
| 361 | |
---|
| 362 | % -------------------------------------------------------------------- |
---|
| 363 | function varargout = load_demo_image_button_Callback(h, eventdata, handles, varargin) |
---|
| 364 | % Stub for Callback of the uicontrol handles.pushbutton5. |
---|
| 365 | % [filename, pathname] = uigetfile_name('*.bmp;*.jpg;*.gif','Pick an input image') |
---|
| 366 | % [i1,map1] = imread([pathname filename]); |
---|
| 367 | % |
---|
| 368 | % [filename, pathname] = uigetfile_name('*.bmp;*.jpg;*.gif','Pick a second input image') |
---|
| 369 | % [i2,map2] = imread([pathname filename]); |
---|
| 370 | |
---|
| 371 | pathname1 = ['.\']; |
---|
| 372 | pathname2 = ['.\']; |
---|
| 373 | filename1=['j1.bmp']; |
---|
| 374 | filename2=['j2.bmp']; |
---|
| 375 | |
---|
| 376 | |
---|
| 377 | load_2images(h, eventdata, handles, varargin, filename1, pathname1,filename2, pathname2); |
---|
| 378 | |
---|
| 379 | %---------------------------------------------------------------------\\\ |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | function varargout = load_2images(h, eventdata, handles, varargin, ... |
---|
| 383 | filename1, pathname1,filename2, pathname2) |
---|
| 384 | |
---|
| 385 | |
---|
| 386 | if pathname1 == pathname2 |
---|
| 387 | handles.pathname = pathname1; |
---|
| 388 | else |
---|
| 389 | errordlg(['The two images should be in the same directory:' pathname1 pathname2],'not fatal'); |
---|
| 390 | handles.pathname = pathname1; |
---|
| 391 | end |
---|
| 392 | |
---|
| 393 | |
---|
| 394 | |
---|
| 395 | |
---|
| 396 | [i1,map1] = imread([pathname1 filename1]); |
---|
| 397 | [i2,map2] = imread([pathname2 filename2]); |
---|
| 398 | |
---|
| 399 | |
---|
| 400 | iii = size(size(i1)); |
---|
| 401 | if iii(2) == 3 |
---|
| 402 | g1 = rgb2gray(i1); |
---|
| 403 | disp('converting to rgb'); |
---|
| 404 | else |
---|
| 405 | g1 = i1; |
---|
| 406 | end |
---|
| 407 | |
---|
| 408 | |
---|
| 409 | iii = size(size(i2)); |
---|
| 410 | if iii(2) == 3 |
---|
| 411 | g2 = rgb2gray(i2); |
---|
| 412 | else |
---|
| 413 | g2 = i2; |
---|
| 414 | end |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | %if we successfully load: |
---|
| 418 | set(handles.detect_corner_button, 'Enable', 'on'); |
---|
| 419 | set(handles.load_corner_button, 'Enable', 'on'); |
---|
| 420 | set(handles.corn_param_button, 'Enable', 'on'); |
---|
| 421 | |
---|
| 422 | set(handles.save_image1_button, 'Enable', 'on'); |
---|
| 423 | set(handles.save_image2_button, 'Enable', 'on'); |
---|
| 424 | |
---|
| 425 | set(handles.Save_Images_menu, 'Enable', 'on'); |
---|
| 426 | |
---|
| 427 | set(handles.manual_match_button, 'Enable', 'on'); |
---|
| 428 | set(handles.load_match_button, 'Enable', 'on'); |
---|
| 429 | |
---|
| 430 | |
---|
| 431 | |
---|
| 432 | |
---|
| 433 | d1 = double(g1); |
---|
| 434 | d2 = double(g2); |
---|
| 435 | |
---|
| 436 | % extracting the handle of the axes in which to display the image |
---|
| 437 | ax_handle2 = handles.axes2; |
---|
| 438 | axes(ax_handle2); |
---|
| 439 | |
---|
| 440 | set(get(ax_handle2, 'Title'), 'Visible', 'off'); |
---|
| 441 | set(get(ax_handle2, 'Title'),'String', 'fff'); |
---|
| 442 | |
---|
| 443 | [m,n] = size(d1); |
---|
| 444 | [m1,n1] = size(d2); |
---|
| 445 | if (m ~= m1) | (n ~= n1) |
---|
| 446 | error('images must be the same size') |
---|
| 447 | end |
---|
| 448 | |
---|
| 449 | axis equal; |
---|
| 450 | colormap(map1); |
---|
| 451 | image(i1, 'Parent', ax_handle2,'XData',-n/2,'YData',-m/2); |
---|
| 452 | % imshow(i1, 'Parent', ax_handle2); |
---|
| 453 | |
---|
| 454 | ax_handle3 = handles.axes3; |
---|
| 455 | axes(ax_handle3); |
---|
| 456 | colormap(map1); |
---|
| 457 | image(i2, 'Parent', ax_handle3,'XData',-n/2,'YData',-m/2); |
---|
| 458 | |
---|
| 459 | handles.image_centrex = n/2; |
---|
| 460 | handles.image_centrey = m/2; |
---|
| 461 | |
---|
| 462 | |
---|
| 463 | handles.i1 = i1; |
---|
| 464 | handles.i2 = i2; |
---|
| 465 | handles.d1 = d1; |
---|
| 466 | handles.d2 = d2; |
---|
| 467 | handles.pathname = pathname1; |
---|
| 468 | |
---|
| 469 | % saving the GUI data |
---|
| 470 | guidata(handles.figure1, handles); |
---|
| 471 | %---------------------------------------------------------------------\\\ |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | % -------------------------------------------------------------------- |
---|
| 475 | function varargout = load_image_button_Callback(h, eventdata, handles, varargin) |
---|
| 476 | % Stub for Callback of the uicontrol handles.pushbutton5. |
---|
| 477 | [filename1, pathname1] = uigetfile_name('*.bmp;*.jpg;*.gif','Pick an input image') |
---|
| 478 | |
---|
| 479 | [filename2, pathname2] = uigetfile_name('*.bmp;*.jpg;*.gif','Pick a second input image') |
---|
| 480 | |
---|
| 481 | load_2images(h, eventdata, handles, varargin, filename1, pathname1,filename2, pathname2); |
---|
| 482 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 483 | |
---|
| 484 | |
---|
| 485 | |
---|
| 486 | % -------------------------------------------------------------------- |
---|
| 487 | function varargout = clear_button_Callback(h, eventdata, handles, varargin) |
---|
| 488 | % Stub for Callback of the uicontrol handles.pushbutton6. |
---|
| 489 | |
---|
| 490 | |
---|
| 491 | % extracting the handle of the axes in which to display the image |
---|
| 492 | ax_handle2 = handles.axes2; |
---|
| 493 | axes(ax_handle2); |
---|
| 494 | |
---|
| 495 | set(get(ax_handle2, 'Title'), 'Visible', 'off'); |
---|
| 496 | set(get(ax_handle2, 'Title'),'String', 'fff'); |
---|
| 497 | |
---|
| 498 | hold off |
---|
| 499 | image(handles.i1, 'Parent', ax_handle2,'XData',-handles.image_centrex,'YData',-handles.image_centrey); |
---|
| 500 | % imshow(i1, 'Parent', ax_handle2); |
---|
| 501 | |
---|
| 502 | |
---|
| 503 | |
---|
| 504 | ax_handle3 = handles.axes3; |
---|
| 505 | axes(ax_handle3); |
---|
| 506 | hold off |
---|
| 507 | image(handles.i2, 'Parent', ax_handle3,'XData',-handles.image_centrex,'YData',-handles.image_centrey); |
---|
| 508 | |
---|
| 509 | |
---|
| 510 | |
---|
| 511 | |
---|
| 512 | % -------------------------------------------------------------------- |
---|
| 513 | function varargout = close_button_Callback(h, eventdata, handles, varargin) |
---|
| 514 | % Stub for Callback of the uicontrol handles.close_button. |
---|
| 515 | pos_size = get(handles.figure1,'Position'); |
---|
| 516 | user_response = modaldlg([pos_size(1)+pos_size(3)/5 pos_size(2)+pos_size(4)/5]); |
---|
| 517 | switch user_response |
---|
| 518 | case {'no','cancel'} |
---|
| 519 | % take no action |
---|
| 520 | case 'yes' |
---|
| 521 | % Prepare to close GUI application window |
---|
| 522 | % . |
---|
| 523 | % . |
---|
| 524 | % . |
---|
| 525 | delete(handles.figure1) |
---|
| 526 | end |
---|
| 527 | |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | % -------------------------------------------------------------------- |
---|
| 531 | function varargout = help_button_Callback(h, eventdata, handles, varargin) |
---|
| 532 | % Stub for Callback of the uicontrol handles.help_button. |
---|
| 533 | HelpPath = which('stereo.htm'); |
---|
| 534 | web(HelpPath); |
---|
| 535 | |
---|
| 536 | |
---|
| 537 | % -------------------------------------------------------------------- |
---|
| 538 | function varargout = corn_param_button_Callback(h, eventdata, handles, varargin) |
---|
| 539 | % Stub for Callback of the uicontrol handles.corn_param_button. |
---|
| 540 | |
---|
| 541 | pos_size = get(handles.figure1,'Position'); |
---|
| 542 | dlg_pos = [pos_size(1)+pos_size(3)/5 pos_size(2)+pos_size(4)/5]; |
---|
| 543 | corn_param = torr_c_menu(handles, dlg_pos); |
---|
| 544 | |
---|
| 545 | handles.n_corners = corn_param(1); |
---|
| 546 | handles.corner_sigma = corn_param(2); |
---|
| 547 | handles.corner_width = corn_param(3); |
---|
| 548 | corn_param |
---|
| 549 | % saving the GUI data |
---|
| 550 | guidata(handles.figure1, handles); |
---|
| 551 | %---------------------------------------------------------------------\\\ |
---|
| 552 | |
---|
| 553 | function save_corners_to_file(n_corners1, n_corners2, ccr1, ccr2, FID) |
---|
| 554 | |
---|
| 555 | |
---|
| 556 | fprintf(FID,'%1.0f \n',n_corners1); |
---|
| 557 | fprintf(FID,'%1.0f \n',n_corners2); |
---|
| 558 | |
---|
| 559 | fprintf(FID,'%1.1f %1.1f \n',ccr1'); |
---|
| 560 | fprintf(FID,'%1.1f %1.1f \n',ccr2'); |
---|
| 561 | |
---|
| 562 | |
---|
| 563 | % -------------------------------------------------------------------- |
---|
| 564 | function varargout = save_corner_button_Callback(h, eventdata, handles, varargin) |
---|
| 565 | % Stub for Callback of the uicontrol handles.save_corner_button. |
---|
| 566 | [fname,pname] = uiputfile_name('*.cor','Put Corner File'); |
---|
| 567 | ccr1 = handles.ccr1; |
---|
| 568 | ccr2 = handles.ccr2; |
---|
| 569 | |
---|
| 570 | %save([pname fname], 'n_corners', 'ccr1', 'ccr2', '-ASCII') |
---|
| 571 | FID = fopen([pname fname],'w'); |
---|
| 572 | |
---|
| 573 | n_corners1 = handles.n_corners1; |
---|
| 574 | n_corners2 = handles.n_corners2; |
---|
| 575 | |
---|
| 576 | save_corners_to_file(n_corners1, n_corners2, ccr1, ccr2, FID) |
---|
| 577 | |
---|
| 578 | fclose(FID); |
---|
| 579 | |
---|
| 580 | % -------------------------------------------------------------------- |
---|
| 581 | |
---|
| 582 | function [n_corners1, n_corners2, ccr1, ccr2] = load_corners_from_file(FID) |
---|
| 583 | |
---|
| 584 | n_corners1 = fscanf(FID,'%f',1); |
---|
| 585 | n_corners2 = fscanf(FID,'%f',1); |
---|
| 586 | ccr1 = fscanf(FID,'%f %f',[2 n_corners1]); |
---|
| 587 | ccr2 = fscanf(FID,'%f %f',[2 n_corners2]); |
---|
| 588 | |
---|
| 589 | % -------------------------------------------------------------------- |
---|
| 590 | |
---|
| 591 | |
---|
| 592 | function varargout = load_corner_button_Callback(h, eventdata, handles, varargin) |
---|
| 593 | % Stub for Callback of the uicontrol handles.load_corner_button. |
---|
| 594 | [fname,pname] = uigetfile_name('*.cor','Load Corner File'); |
---|
| 595 | |
---|
| 596 | if isempty(fname) |
---|
| 597 | return |
---|
| 598 | end |
---|
| 599 | |
---|
| 600 | FID = fopen([pname fname]); |
---|
| 601 | |
---|
| 602 | [n_corners1, n_corners2, ccr1, ccr2] = load_corners_from_file(FID); |
---|
| 603 | handles.n_corners1 = n_corners1; |
---|
| 604 | handles.n_corners2 = n_corners2; |
---|
| 605 | handles.ccr1 = ccr1'; |
---|
| 606 | handles.ccr2 = ccr2'; |
---|
| 607 | |
---|
| 608 | |
---|
| 609 | |
---|
| 610 | fclose(FID); |
---|
| 611 | set(handles.save_corner_button, 'Enable', 'on'); |
---|
| 612 | set(handles.match_button, 'Enable', 'on'); |
---|
| 613 | set(handles.match_param_button, 'Enable', 'on'); |
---|
| 614 | |
---|
| 615 | %once we have done the matches we can no longer redo corners otherwise things might be inconsistent |
---|
| 616 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 617 | % saving the GUI data |
---|
| 618 | guidata(handles.figure1, handles); |
---|
| 619 | |
---|
| 620 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 621 | display_corners_in_figure(handles) |
---|
| 622 | %---------------------------------------------------------------------\\\ |
---|
| 623 | |
---|
| 624 | |
---|
| 625 | |
---|
| 626 | % -------------------------------------------------------------------- |
---|
| 627 | function varargout = match_button_Callback(h, eventdata, handles, varargin) |
---|
| 628 | % Stub for Callback of the uicontrol handles.match_button. |
---|
| 629 | |
---|
| 630 | |
---|
| 631 | %shift the x,y coordinates so we can access the image directly |
---|
| 632 | ccr1(:,1) = handles.ccr1(:,1) + handles.image_centrex; |
---|
| 633 | ccr1(:,2) = handles.ccr1(:,2) + handles.image_centrey; |
---|
| 634 | ccr2(:,1) = handles.ccr2(:,1) + handles.image_centrex; |
---|
| 635 | ccr2(:,2) = handles.ccr2(:,2) + handles.image_centrey; |
---|
| 636 | |
---|
| 637 | matches12 = torr_corn_matcher(handles.d1, handles.d2, ccr1, ccr2, handles.max_disparity,handles.match_half_size); |
---|
| 638 | |
---|
| 639 | disp('Number of matches:') |
---|
| 640 | length(matches12) |
---|
| 641 | |
---|
| 642 | matches12(:,1) = matches12(:,1) - handles.image_centrex; |
---|
| 643 | matches12(:,2) = matches12(:,2) - handles.image_centrey; |
---|
| 644 | matches12(:,3) = matches12(:,3) - handles.image_centrex; |
---|
| 645 | matches12(:,4) = matches12(:,4) - handles.image_centrey; |
---|
| 646 | |
---|
| 647 | |
---|
| 648 | handles.matches12 = matches12; |
---|
| 649 | handles.n_matches = length(matches12); |
---|
| 650 | |
---|
| 651 | |
---|
| 652 | set(handles.save_match_button, 'Enable', 'on'); |
---|
| 653 | |
---|
| 654 | set(handles.mapsac_button, 'Enable', 'on'); |
---|
| 655 | set(handles.mapsac_parameters_button, 'Enable', 'on'); |
---|
| 656 | |
---|
| 657 | %once we have done the matches we can no longer redo corners otherwise things might be inconsistent |
---|
| 658 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 659 | |
---|
| 660 | |
---|
| 661 | guidata(handles.figure1, handles); |
---|
| 662 | display_matches(h, eventdata, handles, varargin); |
---|
| 663 | % -------------------------------------------------------------------- |
---|
| 664 | function varargout = display_matches(h, eventdata, handles, varargin) |
---|
| 665 | % extracting the handle of the axes in which to display the image |
---|
| 666 | ax_handle2 = handles.axes2; |
---|
| 667 | ax_handle3 = handles.axes3; |
---|
| 668 | |
---|
| 669 | ccr1 = handles.ccr1; |
---|
| 670 | ccr2 = handles.ccr2; |
---|
| 671 | matches= handles.matches12; |
---|
| 672 | axes(ax_handle2); |
---|
| 673 | hold on |
---|
| 674 | axes(ax_handle3); |
---|
| 675 | hold on |
---|
| 676 | |
---|
| 677 | |
---|
| 678 | |
---|
| 679 | x1 = matches(:,1); |
---|
| 680 | y1 = matches(:,2); |
---|
| 681 | x2 = matches(:,3); |
---|
| 682 | y2 = matches(:,4); |
---|
| 683 | |
---|
| 684 | u1 = x2 - x1; |
---|
| 685 | v1 = y2 - y1; |
---|
| 686 | |
---|
| 687 | |
---|
| 688 | |
---|
| 689 | plot (matches(:,1), matches(:,2),'r+'); |
---|
| 690 | hold on |
---|
| 691 | plot (matches(:,3), matches(:,4),'r+'); |
---|
| 692 | |
---|
| 693 | display_numbers = 0; |
---|
| 694 | if display_numbers |
---|
| 695 | mat_index1 = 1:length(matches); |
---|
| 696 | mat_index1 = mat_index1'; |
---|
| 697 | mat_index = num2str(mat_index1); |
---|
| 698 | text(matches(:,1), matches(:,2),mat_index) |
---|
| 699 | end |
---|
| 700 | |
---|
| 701 | quiver(x1, y1, u1, v1, 0) |
---|
| 702 | hold off |
---|
| 703 | |
---|
| 704 | % |
---|
| 705 | % plot(ccr1(:,1), ccr1(:,2), 'r.') |
---|
| 706 | % plot(ccr2(:,1), ccr2(:,2), 'c.') |
---|
| 707 | % |
---|
| 708 | % for i = 1:length(mat12) |
---|
| 709 | % if mat12(i) ~= 0 |
---|
| 710 | % a = [ccr1(i,1),ccr2(mat12(i),1)]; %x1 x2 |
---|
| 711 | % b = [ccr1(i,2),ccr2(mat12(i),2)]; %y1 y2 |
---|
| 712 | % %x1 y1 |
---|
| 713 | % %x2 y2 |
---|
| 714 | % line(a,b); |
---|
| 715 | % end |
---|
| 716 | % end |
---|
| 717 | |
---|
| 718 | axes(ax_handle2); |
---|
| 719 | hold off |
---|
| 720 | axes(ax_handle3); |
---|
| 721 | hold off |
---|
| 722 | |
---|
| 723 | % -------------------------------------------------------------------- |
---|
| 724 | function varargout = match_param_button_Callback(h, eventdata, handles, varargin) |
---|
| 725 | |
---|
| 726 | |
---|
| 727 | pos_size = get(handles.figure1,'Position'); |
---|
| 728 | dlg_pos = [pos_size(1)+pos_size(3)/5 pos_size(2)+pos_size(4)/5]; |
---|
| 729 | match_param = torr_m_menu(handles, dlg_pos); |
---|
| 730 | |
---|
| 731 | handles.max_disparity = match_param(1); |
---|
| 732 | handles.match_half_size = match_param(2); |
---|
| 733 | % saving the GUI data |
---|
| 734 | guidata(handles.figure1, handles); |
---|
| 735 | %--------------------------------------------------------------------- |
---|
| 736 | % -------------------------------------------------------------------- |
---|
| 737 | function varargout = save_image1_button_Callback(h, eventdata, handles, varargin) |
---|
| 738 | % Stub for Callback of the uicontrol handles.save_image1_button. |
---|
| 739 | ax_handle2 = handles.axes2; |
---|
| 740 | %ax_handle3 = handles.axes3; |
---|
| 741 | % hf1 = figure; |
---|
| 742 | % %plot(sin(1:10)); |
---|
| 743 | %hf2 = figure; |
---|
| 744 | %ha = findobj('Parent',hf1); |
---|
| 745 | % ax_handle2 = handles.axes2; |
---|
| 746 | % new_axes = axes(ax_handle2); |
---|
| 747 | % set(new_axes, 'Parent', hf1); |
---|
| 748 | % |
---|
| 749 | % [fname,pname] = uiputfile('*.fig'); |
---|
| 750 | % saveas(ax_handle2,[pname fname ]); |
---|
| 751 | %hgsave(ax_handle2,[pname fname ]); |
---|
| 752 | |
---|
| 753 | new_fig = figure; |
---|
| 754 | new_axes = copyobj(ax_handle2,new_fig) |
---|
| 755 | %set(new_axes,'Position',[.5 .5 .8 .8],'DataAspectRatioMode','auto','PlotBoxAspectRatioMode','auto'); |
---|
| 756 | |
---|
| 757 | %get(new_axes) |
---|
| 758 | axis_position = get(new_axes,'Position'); |
---|
| 759 | set(new_axes,'Position',[10 7 axis_position(3) axis_position(4) ]); |
---|
| 760 | %keyboard |
---|
| 761 | |
---|
| 762 | % fff = handles.figure1; |
---|
| 763 | % saveas(fff,'bigfig.bmp'); |
---|
| 764 | |
---|
| 765 | % -------------------------------------------------------------------- |
---|
| 766 | function varargout = save_image2_button_Callback(h, eventdata, handles, varargin) |
---|
| 767 | % Stub for Callback of the uicontrol handles.save_image2_button. |
---|
| 768 | ax_handle3 = handles.axes3; |
---|
| 769 | |
---|
| 770 | % [fname,pname] = uiputfile('*.fig'); |
---|
| 771 | % saveas(ax_handle3,[pname fname ]); |
---|
| 772 | %hgsave(ax_handle3,[pname fname ]); |
---|
| 773 | |
---|
| 774 | new_fig = figure; |
---|
| 775 | new_axes = copyobj(ax_handle3,new_fig) |
---|
| 776 | %set(new_axes,'Position',[.5 .5 .8 .8],'DataAspectRatioMode','auto','PlotBoxAspectRatioMode','auto'); |
---|
| 777 | |
---|
| 778 | %get(new_axes) |
---|
| 779 | axis_position = get(new_axes,'Position'); |
---|
| 780 | set(new_axes,'Position',[10 7 axis_position(3) axis_position(4) ]); |
---|
| 781 | %keyboard |
---|
| 782 | |
---|
| 783 | |
---|
| 784 | % -------------------------------------------------------------------- |
---|
| 785 | function varargout = manual_match_button_Callback(h, eventdata, handles, varargin) |
---|
| 786 | % Stub for Callback of the uicontrol handles.manual_match_button. |
---|
| 787 | |
---|
| 788 | |
---|
| 789 | set(handles.save_match_button, 'Enable', 'on'); |
---|
| 790 | set(handles.load_match_button, 'Enable', 'on'); |
---|
| 791 | |
---|
| 792 | matches12 = torr_add_manual_matches(handles.axes2,handles.axes3); |
---|
| 793 | |
---|
| 794 | handles.matches12 = matches12; |
---|
| 795 | handles.n_matches = length(matches12); |
---|
| 796 | |
---|
| 797 | %also store corners |
---|
| 798 | ccr1(:,1) = matches12(:,1); |
---|
| 799 | ccr1(:,2) = matches12(:,2); |
---|
| 800 | ccr2(:,1) = matches12(:,3); |
---|
| 801 | ccr2(:,2) = matches12(:,4); |
---|
| 802 | handles.ccr1 = ccr1; |
---|
| 803 | handles.ccr2 = ccr2; |
---|
| 804 | |
---|
| 805 | %once we have done the matches we can no longer redo corners otherwise things might be inconsistent |
---|
| 806 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 807 | |
---|
| 808 | |
---|
| 809 | guidata(handles.figure1, handles); |
---|
| 810 | display_matches(h, eventdata, handles, varargin); |
---|
| 811 | |
---|
| 812 | if handles.n_matches > 7; |
---|
| 813 | set(handles.mapsac_button, 'Enable', 'on'); |
---|
| 814 | set(handles.mapsac_parameters_button, 'Enable', 'on'); |
---|
| 815 | set(handles.ImproveF_button, 'Enable', 'on'); |
---|
| 816 | end |
---|
| 817 | |
---|
| 818 | |
---|
| 819 | |
---|
| 820 | % -------------------------------------------------------------------- |
---|
| 821 | function varargout = save_match_button_Callback(h, eventdata, handles, varargin) |
---|
| 822 | % Stub for Callback of the uicontrol handles.save_corner_button. |
---|
| 823 | [fname,pname] = uiputfile_name('*.matches','Put Match File'); |
---|
| 824 | |
---|
| 825 | n_matches = handles.n_matches; |
---|
| 826 | matches12 = handles.matches12; |
---|
| 827 | |
---|
| 828 | %save([pname fname], 'n_corners', 'ccr1', 'ccr2', '-ASCII') |
---|
| 829 | FID = fopen([pname fname],'w'); |
---|
| 830 | fprintf(FID,'%1.0f \n',n_matches); |
---|
| 831 | fprintf(FID,'%1.1f %1.1f %1.1f %1.1f \n',matches12'); |
---|
| 832 | |
---|
| 833 | %now store original corners for good measure: |
---|
| 834 | n_corners = handles.n_corners; |
---|
| 835 | ccr1 = handles.ccr1; |
---|
| 836 | ccr2 = handles.ccr2; |
---|
| 837 | n_corners1 = handles.n_corners1; |
---|
| 838 | n_corners2 = handles.n_corners2; |
---|
| 839 | save_corners_to_file(n_corners1, n_corners2, ccr1, ccr2, FID); |
---|
| 840 | fclose(FID); |
---|
| 841 | |
---|
| 842 | |
---|
| 843 | % -------------------------------------------------------------------- |
---|
| 844 | function varargout = load_match_button_Callback(h, eventdata, handles, varargin) |
---|
| 845 | % Stub for Callback of the uicontrol handles.load_match_button. |
---|
| 846 | % Stub for Callback of the uicontrol handles.load_corner_button. |
---|
| 847 | [fname,pname] = uigetfile_name('*.matches','Load Match File'); |
---|
| 848 | |
---|
| 849 | if isempty(fname) |
---|
| 850 | return |
---|
| 851 | end |
---|
| 852 | |
---|
| 853 | FID = fopen([pname fname]); |
---|
| 854 | n_matches = fscanf(FID,'%f',1) |
---|
| 855 | handles.n_matches = n_matches; |
---|
| 856 | matches12 = fscanf(FID,'%f %f %f %f',[4 n_matches]); |
---|
| 857 | |
---|
| 858 | [n_corners1, n_corners2, ccr1, ccr2] = load_corners_from_file(FID); |
---|
| 859 | handles.n_corners1 = n_corners1; |
---|
| 860 | handles.n_corners2 = n_corners2; |
---|
| 861 | handles.ccr1 = ccr1'; |
---|
| 862 | handles.ccr2 = ccr2'; |
---|
| 863 | |
---|
| 864 | fclose(FID); |
---|
| 865 | |
---|
| 866 | handles.matches12 = matches12'; |
---|
| 867 | |
---|
| 868 | set(handles.save_corner_button, 'Enable', 'on'); |
---|
| 869 | set(handles.save_match_button, 'Enable', 'on'); |
---|
| 870 | set(handles.match_button, 'Enable', 'on'); |
---|
| 871 | set(handles.match_param_button, 'Enable', 'on'); |
---|
| 872 | |
---|
| 873 | % Stub for Callback of the uicontrol handles.pushbutton28. |
---|
| 874 | set(handles.mapsac_button, 'Enable', 'on'); |
---|
| 875 | set(handles.mapsac_parameters_button, 'Enable', 'on'); |
---|
| 876 | |
---|
| 877 | |
---|
| 878 | |
---|
| 879 | % saving the GUI data |
---|
| 880 | guidata(handles.figure1, handles); |
---|
| 881 | clear_button_Callback(h, eventdata, handles, varargin) |
---|
| 882 | display_matches(h, eventdata, handles, varargin) |
---|
| 883 | |
---|
| 884 | |
---|
| 885 | |
---|
| 886 | % -------------------------------------------------------------------- |
---|
| 887 | function varargout = display_inliers(h, eventdata, handles, varargin) |
---|
| 888 | % extracting the handle of the axes in which to display the image |
---|
| 889 | ax_handle2 = handles.axes2; |
---|
| 890 | ax_handle3 = handles.axes3; |
---|
| 891 | |
---|
| 892 | ccr1 = handles.ccr1; |
---|
| 893 | ccr2 = handles.ccr2; |
---|
| 894 | axes(ax_handle2); |
---|
| 895 | hold on |
---|
| 896 | axes(ax_handle3); |
---|
| 897 | hold on |
---|
| 898 | |
---|
| 899 | |
---|
| 900 | matches12 = handles.inlier_matches; |
---|
| 901 | plot(matches12(:,3),matches12(:,4),'c.'); |
---|
| 902 | |
---|
| 903 | for i = 1:length(matches12) |
---|
| 904 | a = [matches12(i,1),matches12(i,3)]; %x1 x2 |
---|
| 905 | b = [matches12(i,2),matches12(i,4)]; %y1 y2 |
---|
| 906 | line(a,b,'Color','g'); |
---|
| 907 | end |
---|
| 908 | |
---|
| 909 | axes(ax_handle2); |
---|
| 910 | hold on |
---|
| 911 | |
---|
| 912 | plot(matches12(:,3),matches12(:,4),'c.'); |
---|
| 913 | |
---|
| 914 | %can i fix this to make this faster?? |
---|
| 915 | for i = 1:length(matches12) |
---|
| 916 | a = [matches12(i,1),matches12(i,3)]; %x1 x2 |
---|
| 917 | b = [matches12(i,2),matches12(i,4)]; %y1 y2 |
---|
| 918 | line(a,b,'Color','g'); |
---|
| 919 | end |
---|
| 920 | |
---|
| 921 | axes(ax_handle2); |
---|
| 922 | hold off |
---|
| 923 | axes(ax_handle3); |
---|
| 924 | hold off |
---|
| 925 | |
---|
| 926 | %MAPSAC is the Bayesian version of MLESAC, and it is easier to pronounce! |
---|
| 927 | % -------------------------------------------------------------------- |
---|
| 928 | function varargout = mapsac_button_Callback(h, eventdata, handles, varargin) |
---|
| 929 | % Stub for Callback of the uicontrol handles.mapsac_button. |
---|
| 930 | |
---|
| 931 | |
---|
| 932 | %run mapsac to get f |
---|
| 933 | f_optim_parameters = [handles.no_samp, handles.f_threshold]; |
---|
| 934 | [f,f_sq_errors, n_inliers,inlier_index] = torr_estimateF(handles.matches12, handles.m3, f_optim_parameters, 'mapsac'); |
---|
| 935 | disp('goodness of fit before non linear:') |
---|
| 936 | norm(f_sq_errors) |
---|
| 937 | |
---|
| 938 | |
---|
| 939 | handles.f = f; |
---|
| 940 | handles.inlier_matches = handles.matches12(inlier_index,:); |
---|
| 941 | handles.n_inliers = n_inliers; |
---|
| 942 | |
---|
| 943 | %first estimate F |
---|
| 944 | [f_nl,f_sq_errors] = torr_estimateF(handles.inlier_matches, handles.m3, [], 'non_linear',1,f); |
---|
| 945 | handles.f = f_nl; |
---|
| 946 | disp('goodness of fit after non linear:') |
---|
| 947 | norm(f_sq_errors) |
---|
| 948 | |
---|
| 949 | %finally display inliers |
---|
| 950 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 951 | display_inliers(h, eventdata, handles, varargin); |
---|
| 952 | |
---|
| 953 | %we can now save the result |
---|
| 954 | set(handles.save_F_button, 'Enable', 'on'); |
---|
| 955 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 956 | set(handles.match_button, 'Enable', 'off'); |
---|
| 957 | set(handles.display_epipolar_button, 'Enable', 'on'); |
---|
| 958 | set(handles.display_epipolar_button2, 'Enable', 'on'); |
---|
| 959 | %set(handles.mapsac_plane_button, 'Enable', 'on'); |
---|
| 960 | |
---|
| 961 | set(handles.ImproveF_button, 'Enable', 'on'); |
---|
| 962 | set(handles.sfm_button, 'Enable', 'on'); |
---|
| 963 | |
---|
| 964 | |
---|
| 965 | % saving the GUI data |
---|
| 966 | guidata(handles.figure1, handles); |
---|
| 967 | |
---|
| 968 | % -------------------------------------------------------------------- |
---|
| 969 | function varargout = mapsac_parameters_button_Callback(h, eventdata, handles, varargin) |
---|
| 970 | |
---|
| 971 | pos_size = get(handles.figure1,'Position'); |
---|
| 972 | dlg_pos = [pos_size(1)+pos_size(3)/5 pos_size(2)+pos_size(4)/5]; |
---|
| 973 | f_param = torr_f_menu(handles, dlg_pos); |
---|
| 974 | |
---|
| 975 | handles.no_samp = f_param(1); |
---|
| 976 | handles.f_threshold = f_param(2); |
---|
| 977 | % saving the GUI data |
---|
| 978 | guidata(handles.figure1, handles); |
---|
| 979 | %-------------------------------------------------------------- |
---|
| 980 | |
---|
| 981 | |
---|
| 982 | %here we save all the stuff in corner file, match file and add some extras.... |
---|
| 983 | % -------------------------------------------------------------------- |
---|
| 984 | function varargout = save_F_button_Callback(h, eventdata, handles, varargin) |
---|
| 985 | [fname,pname] = uiputfile_name('*.Fmatches','Put F & inlying matches'); |
---|
| 986 | |
---|
| 987 | |
---|
| 988 | f = handles.f; |
---|
| 989 | inlier_matches = handles.inlier_matches; |
---|
| 990 | n_inliers = handles.n_inliers; |
---|
| 991 | |
---|
| 992 | n_matches = handles.n_matches; |
---|
| 993 | matches12 = handles.matches12; |
---|
| 994 | f = handles.f; |
---|
| 995 | f |
---|
| 996 | |
---|
| 997 | FID = fopen([pname fname],'w'); |
---|
| 998 | |
---|
| 999 | %save F stuff |
---|
| 1000 | fprintf(FID,'%1.0f \n',n_inliers); |
---|
| 1001 | fprintf(FID,'%12.8f \n', f); |
---|
| 1002 | fprintf(FID,'%1.1f %1.1f %1.1f %1.1f \n',inlier_matches'); |
---|
| 1003 | |
---|
| 1004 | |
---|
| 1005 | %save correlation matches |
---|
| 1006 | fprintf(FID,'%1.0f \n',n_matches); |
---|
| 1007 | fprintf(FID,'%1.1f %1.1f %1.1f %1.1f \n',matches12'); |
---|
| 1008 | |
---|
| 1009 | %now store original corners for good measure: |
---|
| 1010 | n_corners = handles.n_corners; |
---|
| 1011 | ccr1 = handles.ccr1; |
---|
| 1012 | ccr2 = handles.ccr2; |
---|
| 1013 | n_corners1 = handles.n_corners1; |
---|
| 1014 | n_corners2 = handles.n_corners2; |
---|
| 1015 | save_corners_to_file(n_corners1, n_corners2, ccr1, ccr2, FID); |
---|
| 1016 | fclose(FID); |
---|
| 1017 | |
---|
| 1018 | |
---|
| 1019 | % -------------------------------------------------------------------- |
---|
| 1020 | function varargout = load_F_button_Callback(h, eventdata, handles, varargin) |
---|
| 1021 | % Stub for Callback of the uicontrol handles.pushbutton28. |
---|
| 1022 | |
---|
| 1023 | |
---|
| 1024 | [fname,pname] = uigetfile_name('*.fmatches','Load Match File'); |
---|
| 1025 | if isempty(fname) |
---|
| 1026 | return |
---|
| 1027 | end |
---|
| 1028 | |
---|
| 1029 | |
---|
| 1030 | %set(handles.mapsac_plane_button, 'Enable', 'on'); |
---|
| 1031 | set(handles.mapsac_button, 'Enable', 'on'); |
---|
| 1032 | set(handles.mapsac_parameters_button, 'Enable', 'on'); |
---|
| 1033 | set(handles.save_F_button, 'Enable', 'on'); |
---|
| 1034 | |
---|
| 1035 | set(handles.ImproveF_button, 'Enable', 'on'); |
---|
| 1036 | |
---|
| 1037 | set(handles.sfm_button, 'Enable', 'on'); |
---|
| 1038 | |
---|
| 1039 | |
---|
| 1040 | FID = fopen([pname fname]); |
---|
| 1041 | |
---|
| 1042 | |
---|
| 1043 | %save F stuff |
---|
| 1044 | n_inliers = fscanf(FID,'%f',1); |
---|
| 1045 | f = fscanf(FID,'%f',[1 9]); |
---|
| 1046 | inlier_matches = fscanf(FID,'%f %f %f %f',[4 n_inliers]); |
---|
| 1047 | |
---|
| 1048 | disp('fundamental matrix') |
---|
| 1049 | handles.f = f |
---|
| 1050 | handles.inlier_matches = inlier_matches'; |
---|
| 1051 | handles.n_inliers = n_inliers; |
---|
| 1052 | |
---|
| 1053 | |
---|
| 1054 | |
---|
| 1055 | n_matches = fscanf(FID,'%f',1); |
---|
| 1056 | handles.n_matches = n_matches; |
---|
| 1057 | matches12 = fscanf(FID,'%f %f %f %f',[4 n_matches]); |
---|
| 1058 | |
---|
| 1059 | [n_corners1, n_corners2, ccr1, ccr2] = load_corners_from_file(FID); |
---|
| 1060 | handles.n_corners1 = n_corners1; |
---|
| 1061 | handles.n_corners2 = n_corners2; |
---|
| 1062 | handles.ccr1 = ccr1'; |
---|
| 1063 | handles.ccr2 = ccr2'; |
---|
| 1064 | |
---|
| 1065 | |
---|
| 1066 | |
---|
| 1067 | fclose(FID); |
---|
| 1068 | |
---|
| 1069 | |
---|
| 1070 | handles.matches12 = matches12'; |
---|
| 1071 | |
---|
| 1072 | set(handles.save_corner_button, 'Enable', 'on'); |
---|
| 1073 | set(handles.save_match_button, 'Enable', 'on'); |
---|
| 1074 | set(handles.match_button, 'Enable', 'on'); |
---|
| 1075 | set(handles.match_param_button, 'Enable', 'on'); |
---|
| 1076 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 1077 | set(handles.match_button, 'Enable', 'off'); |
---|
| 1078 | set(handles.display_epipolar_button, 'Enable', 'on'); |
---|
| 1079 | set(handles.display_epipolar_button2, 'Enable', 'on'); |
---|
| 1080 | |
---|
| 1081 | |
---|
| 1082 | % Stub for Callback of the uicontrol handles.pushbutton28. |
---|
| 1083 | set(handles.mapsac_button, 'Enable', 'on'); |
---|
| 1084 | set(handles.mapsac_parameters_button, 'Enable', 'on'); |
---|
| 1085 | %we can now save the result |
---|
| 1086 | set(handles.save_F_button, 'Enable', 'on'); |
---|
| 1087 | |
---|
| 1088 | |
---|
| 1089 | |
---|
| 1090 | % saving the GUI data |
---|
| 1091 | guidata(handles.figure1, handles); |
---|
| 1092 | clear_button_Callback(h, eventdata, handles, varargin) |
---|
| 1093 | %display_matches(h, eventdata, handles, varargin) |
---|
| 1094 | |
---|
| 1095 | %finally display inliers |
---|
| 1096 | display_inliers(h, eventdata, handles, varargin); |
---|
| 1097 | %%%---------------------------------------------------------------------------------- |
---|
| 1098 | %%%%this is not 100% checked.... |
---|
| 1099 | function varargout = display_epipolar_button_Callback(h, eventdata, handles, varargin) |
---|
| 1100 | |
---|
| 1101 | torr_display_epipolar(handles.f,handles.axes2,handles.axes3,handles.m3); |
---|
| 1102 | |
---|
| 1103 | |
---|
| 1104 | %%%---------------------------------------------------------------------------------- |
---|
| 1105 | |
---|
| 1106 | function varargout = display_epipolar_button2_Callback(h, eventdata, handles, varargin) |
---|
| 1107 | f = handles.f; |
---|
| 1108 | |
---|
| 1109 | %need to use the transpose of F for image 2--1 |
---|
| 1110 | f = [f(1) f(4) f(7) f(2) f(5) f(8) f(3) f(6) f(9)]; |
---|
| 1111 | torr_display_epipolar(f,handles.axes3,handles.axes2,handles.m3); |
---|
| 1112 | |
---|
| 1113 | |
---|
| 1114 | %%%---------------------------------------------------------------------------------- |
---|
| 1115 | |
---|
| 1116 | |
---|
| 1117 | |
---|
| 1118 | % -------------------------------------------------------------------- |
---|
| 1119 | function varargout = mapsac_plane_button_Callback(h, eventdata, handles, varargin) |
---|
| 1120 | % Stub for Callback of the uicontrol handles.mapsac_plane_button. |
---|
| 1121 | % Stub for Callback of the uicontrol handles.mapsac_button. |
---|
| 1122 | |
---|
| 1123 | |
---|
| 1124 | %run mapsac to get f |
---|
| 1125 | [f,f_sq_errors, n_inliers,inlier_index] = torr_mapsac_H(handles.matches12(:,1),handles.matches12(:,2),handles.matches12(:,3),handles.matches12(:,4), ... |
---|
| 1126 | handles.n_matches, handles.m3, handles.no_samp, handles.f_threshold) |
---|
| 1127 | |
---|
| 1128 | handles.f = f; |
---|
| 1129 | handles.inlier_matches = handles.matches12(inlier_index,:); |
---|
| 1130 | handles.n_inliers = n_inliers; |
---|
| 1131 | |
---|
| 1132 | %finally display inliers |
---|
| 1133 | clear_button_Callback(h, eventdata, handles, varargin); |
---|
| 1134 | display_inliers(h, eventdata, handles, varargin); |
---|
| 1135 | |
---|
| 1136 | %we can now save the result |
---|
| 1137 | set(handles.save_F_button, 'Enable', 'on'); |
---|
| 1138 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 1139 | set(handles.match_button, 'Enable', 'off'); |
---|
| 1140 | set(handles.display_epipolar_button, 'Enable', 'on'); |
---|
| 1141 | set(handles.display_epipolar_button2, 'Enable', 'on'); |
---|
| 1142 | |
---|
| 1143 | |
---|
| 1144 | % saving the GUI data |
---|
| 1145 | guidata(handles.figure1, handles); |
---|
| 1146 | |
---|
| 1147 | |
---|
| 1148 | |
---|
| 1149 | |
---|
| 1150 | % -------------------------------------------------------------------- |
---|
| 1151 | function varargout = ImproveF_button_Callback(h, eventdata, handles, varargin) |
---|
| 1152 | % Stub for Callback of the uicontrol handles.ImproveF_button. |
---|
| 1153 | |
---|
| 1154 | %this function simply operates on the set of matches with no robustness |
---|
| 1155 | %to be used with manual input etc... |
---|
| 1156 | handles.m3 = 256; |
---|
| 1157 | |
---|
| 1158 | %first estimate F |
---|
| 1159 | f = torr_estimateF(handles.matches12, handles.m3, [], 'lin+non_lin'); |
---|
| 1160 | handles.f = f; |
---|
| 1161 | |
---|
| 1162 | |
---|
| 1163 | %we can now save the result |
---|
| 1164 | set(handles.save_F_button, 'Enable', 'on'); |
---|
| 1165 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 1166 | set(handles.match_button, 'Enable', 'off'); |
---|
| 1167 | set(handles.display_epipolar_button, 'Enable', 'on'); |
---|
| 1168 | set(handles.display_epipolar_button2, 'Enable', 'on'); |
---|
| 1169 | %set(handles.mapsac_plane_button, 'Enable', 'on'); |
---|
| 1170 | |
---|
| 1171 | set(handles.ImproveF_button, 'Enable', 'on'); |
---|
| 1172 | set(handles.sfm_button, 'Enable', 'on'); |
---|
| 1173 | |
---|
| 1174 | % saving the GUI data |
---|
| 1175 | guidata(handles.figure1, handles); |
---|
| 1176 | |
---|
| 1177 | |
---|
| 1178 | % -------------------------------------------------------------------- |
---|
| 1179 | |
---|
| 1180 | |
---|
| 1181 | % -------------------------------------------------------------------- |
---|
| 1182 | function varargout = sfm_button_Callback(h, eventdata, handles, varargin) |
---|
| 1183 | %this function estalishes the frame, self calibrates and estimates X |
---|
| 1184 | |
---|
| 1185 | |
---|
| 1186 | f = handles.f; |
---|
| 1187 | nF = [[f(1) f(2) f(3)]; [f(4) f(5) f(6)];[f(7) f(8) f(9)]]; |
---|
| 1188 | |
---|
| 1189 | nx1 = handles.inlier_matches(:,1); |
---|
| 1190 | ny1 = handles.inlier_matches(:,2); |
---|
| 1191 | nx2 = handles.inlier_matches(:,3); |
---|
| 1192 | ny2 = handles.inlier_matches(:,4); |
---|
| 1193 | no_matches = length(nx1); |
---|
| 1194 | m3 = handles.m3; |
---|
| 1195 | |
---|
| 1196 | %next self calibrate for focal length |
---|
| 1197 | [focal_length, nE,C] = torr_self_calib_f(nF,handles.C); |
---|
| 1198 | |
---|
| 1199 | % |
---|
| 1200 | disp('initial estimate of focal length') |
---|
| 1201 | focal_length |
---|
| 1202 | |
---|
| 1203 | %now we have an Essential matrix we can establish the camera frame... |
---|
| 1204 | [P1,P2,R,t,srot_axis,rot_angle,g] = torr_linear_EtoPX(nE,handles.inlier_matches,C,handles.m3); |
---|
| 1205 | |
---|
| 1206 | % %next convert the 6 parameters of g to a fundamental matrix |
---|
| 1207 | % f2 = torr_g2F(g,C); |
---|
| 1208 | |
---|
| 1209 | [g,f] = torr_nonlinG(g ,nx1,ny1,nx2,ny2, length(nx1), handles.m3, C) |
---|
| 1210 | |
---|
| 1211 | rot_axis = torr_sphere2unit([g(2) g(3)]); |
---|
| 1212 | t = torr_sphere2unit([g(5) g(6)]); |
---|
| 1213 | rot_angle = g(4); |
---|
| 1214 | |
---|
| 1215 | disp('non_linear estimate of focal length') |
---|
| 1216 | focal_length |
---|
| 1217 | disp('rotation') |
---|
| 1218 | R |
---|
| 1219 | rot_axis |
---|
| 1220 | rot_angle |
---|
| 1221 | disp('translation') |
---|
| 1222 | t |
---|
| 1223 | |
---|
| 1224 | %next correct the points so that they lie on the fundamental matrix |
---|
| 1225 | [corrected_matches error2] = torr_correctx4F(f, nx1,ny1,nx2,ny2, no_matches, m3); |
---|
| 1226 | |
---|
| 1227 | %corrected matches should have zero error: |
---|
| 1228 | e2 = torr_errf2(f, corrected_matches(:,1), corrected_matches(:,2), corrected_matches(:,3),corrected_matches(:,4), length(nx1), m3); |
---|
| 1229 | disp('corrected match error is') |
---|
| 1230 | norm(e2) |
---|
| 1231 | |
---|
| 1232 | %next we need to obtain P1 & P2 |
---|
| 1233 | [P1, P2] = torr_g2FP(g,C); |
---|
| 1234 | |
---|
| 1235 | %now use P matrices and corrected matches to get structure: |
---|
| 1236 | X = torr_triangulate(corrected_matches, m3, P1, P2); |
---|
| 1237 | |
---|
| 1238 | %note structure is upside down! |
---|
| 1239 | |
---|
| 1240 | %test reprojection error |
---|
| 1241 | % rx1 = (P1 * X)'; |
---|
| 1242 | % |
---|
| 1243 | % rx1(:,1) = m3 * rx1(:,1) ./ rx1(:,3); |
---|
| 1244 | % rx1(:,2) = m3 * rx1(:,2) ./ rx1(:,3); |
---|
| 1245 | % |
---|
| 1246 | % rx2 = P2 * X; |
---|
| 1247 | |
---|
| 1248 | inlier_index = torr_robust_chieral(X,P1,P2); |
---|
| 1249 | |
---|
| 1250 | disp('number of outliers from chierality:') |
---|
| 1251 | no_matches - length(inlier_index) |
---|
| 1252 | |
---|
| 1253 | X = X(:,inlier_index); |
---|
| 1254 | %flash up a new window and display the structure plus cameras: |
---|
| 1255 | %invert = 1; |
---|
| 1256 | |
---|
| 1257 | % note becuase of row/column coordinate system of the image the X's are upside down so invert them prior |
---|
| 1258 | % to display. |
---|
| 1259 | X(2,:) = -X(2,:); |
---|
| 1260 | torr_display_structure(X, P1, P2); |
---|
| 1261 | X(2,:) = -X(2,:); |
---|
| 1262 | |
---|
| 1263 | |
---|
| 1264 | handles.P1 = P1; |
---|
| 1265 | handles.P2 = P2; |
---|
| 1266 | handles.X = X; |
---|
| 1267 | handles.inlier_matches = handles.inlier_matches(inlier_index,:); |
---|
| 1268 | handles.focal_length = focal_length; |
---|
| 1269 | handles.E = nE; |
---|
| 1270 | handles.C = C; |
---|
| 1271 | handles.f = f; |
---|
| 1272 | handles.n_matches = no_matches; |
---|
| 1273 | |
---|
| 1274 | % saving the GUI data |
---|
| 1275 | guidata(handles.figure1, handles); |
---|
| 1276 | |
---|
| 1277 | |
---|
| 1278 | |
---|
| 1279 | % -------------------------------------------------------------------- |
---|
| 1280 | function varargout = sfm_parambutton_Callback(h, eventdata, handles, varargin) |
---|
| 1281 | |
---|
| 1282 | pos_size = get(handles.figure1,'Position'); |
---|
| 1283 | dlg_pos = [pos_size(1)+pos_size(3)/5 pos_size(2)+pos_size(4)/5]; |
---|
| 1284 | |
---|
| 1285 | cal_param = torr_cal_menu(handles, dlg_pos); |
---|
| 1286 | |
---|
| 1287 | handles.focal_length = cal_param(1); |
---|
| 1288 | handles.aspect_ratio = cal_param(2); |
---|
| 1289 | handles.ppx = cal_param(3); |
---|
| 1290 | handles.ppy = cal_param(4); |
---|
| 1291 | |
---|
| 1292 | %work out calibration matrix |
---|
| 1293 | C = [ handles.aspect_ratio 0 handles.ppx; 0 1 handles.ppy; 0 0 1/handles.focal_length]; |
---|
| 1294 | C |
---|
| 1295 | handles.C = C; |
---|
| 1296 | % saving the GUI data |
---|
| 1297 | guidata(handles.figure1, handles); |
---|
| 1298 | |
---|
| 1299 | |
---|
| 1300 | |
---|
| 1301 | % -------------------------------------------------------------------- |
---|
| 1302 | function varargout = initialize(handles) |
---|
| 1303 | |
---|
| 1304 | disp('this function isnt ready yet'); |
---|
| 1305 | %phils atuff added, initialization |
---|
| 1306 | %corner parameters |
---|
| 1307 | handles.n_corners = 500; %max no of corners permitted/requested |
---|
| 1308 | |
---|
| 1309 | handles.n_corners1 = 0; %the actual number detected |
---|
| 1310 | handles.n_corners2 = 0; |
---|
| 1311 | |
---|
| 1312 | handles.corner_sigma = 1.0; |
---|
| 1313 | handles.corner_width = 3; |
---|
| 1314 | |
---|
| 1315 | |
---|
| 1316 | %matchin parameters |
---|
| 1317 | handles.max_disparity = 100; |
---|
| 1318 | handles.match_half_size = 3; |
---|
| 1319 | |
---|
| 1320 | |
---|
| 1321 | %F parameters: |
---|
| 1322 | handles.no_samp = 500; % no of samples in the mapsac algorithm |
---|
| 1323 | handles.f_threshold = 6.0; % f_threshold in the mapsac algorithm |
---|
| 1324 | |
---|
| 1325 | %informational variables |
---|
| 1326 | handles.n_matches = 0; %how many matches have we dectected. |
---|
| 1327 | |
---|
| 1328 | |
---|
| 1329 | %general parameters |
---|
| 1330 | %debugt mode |
---|
| 1331 | handles.debug = 1; |
---|
| 1332 | handles.m3 = 256; %third homogeous pixel coordinate, chosen as 256 to help conditioning, see my thesis |
---|
| 1333 | handles.pathname = ['C:\matlabR12\bin\']; |
---|
| 1334 | |
---|
| 1335 | |
---|
| 1336 | %calibration matrix |
---|
| 1337 | handles.focal_length = 3; %first guess, which is in units of m3 i.e |
---|
| 1338 | %focal length in pixels is 3 * m3 |
---|
| 1339 | handles.aspect_ratio = 1; |
---|
| 1340 | handles.ppx = 0; |
---|
| 1341 | handles.ppy = 0; |
---|
| 1342 | %work out calibration matrix |
---|
| 1343 | C = [a 0 handles.ppx; 0 1 handles.ppy; 0 0 1/handles.focal_length]; |
---|
| 1344 | handles.C = C; |
---|
| 1345 | |
---|
| 1346 | if ~handles.debug |
---|
| 1347 | helpdlg('Phil asks: "how ya diddling", first load some images') |
---|
| 1348 | end |
---|
| 1349 | |
---|
| 1350 | |
---|
| 1351 | set(handles.save_image1_button, 'Enable', 'off'); |
---|
| 1352 | set(handles.save_image2_button, 'Enable', 'off'); |
---|
| 1353 | set(handles.Save_Images_menu, 'Enable', 'off'); |
---|
| 1354 | |
---|
| 1355 | |
---|
| 1356 | %for corners |
---|
| 1357 | set(handles.detect_corner_button, 'Enable', 'off'); |
---|
| 1358 | set(handles.save_corner_button, 'Enable', 'off'); |
---|
| 1359 | set(handles.load_corner_button, 'Enable', 'off'); |
---|
| 1360 | set(handles.corn_param_button, 'Enable', 'off'); |
---|
| 1361 | |
---|
| 1362 | %for correlation matches |
---|
| 1363 | set(handles.match_button, 'Enable', 'off'); |
---|
| 1364 | set(handles.match_param_button, 'Enable', 'off'); |
---|
| 1365 | set(handles.manual_match_button, 'Enable', 'off'); |
---|
| 1366 | set(handles.save_match_button, 'Enable', 'off'); |
---|
| 1367 | set(handles.load_match_button, 'Enable', 'off'); |
---|
| 1368 | |
---|
| 1369 | %for F and correlation matches |
---|
| 1370 | set(handles.mapsac_button, 'Enable', 'off'); |
---|
| 1371 | set(handles.mapsac_parameters_button, 'Enable', 'off'); |
---|
| 1372 | set(handles.save_F_button, 'Enable', 'off'); |
---|
| 1373 | set(handles.display_epipolar_button, 'Enable', 'off'); |
---|
| 1374 | set(handles.display_epipolar_button2, 'Enable', 'off'); |
---|
| 1375 | |
---|
| 1376 | %self calibrate |
---|
| 1377 | set(handles.calibrate_button, 'Enable', 'on'); |
---|
| 1378 | |
---|
| 1379 | |
---|
| 1380 | |
---|
| 1381 | |
---|
| 1382 | guidata(handles.figure1, handles); |
---|
| 1383 | |
---|
| 1384 | |
---|
| 1385 | |
---|
| 1386 | |
---|
| 1387 | |
---|
| 1388 | % -------------------------------------------------------------------- |
---|
| 1389 | function varargout = epi_button_Callback(h, eventdata, handles, varargin) |
---|
| 1390 | |
---|
| 1391 | torr_disp_epip_geom(handles.f,handles.matches12,handles.axes2,handles.axes3,handles.m3); |
---|
| 1392 | |
---|
| 1393 | |
---|
| 1394 | f = handles.f; |
---|
| 1395 | f = [f(1) f(4) f(7) f(2) f(5) f(8) f(3) f(6) f(9)]; |
---|
| 1396 | |
---|
| 1397 | torr_disp_epip_geom(handles.f,handles.matches12,handles.axes3,handles.axes2,handles.m3); |
---|
| 1398 | |
---|
| 1399 | |
---|
| 1400 | |
---|
| 1401 | % -------------------------------------------------------------------- |
---|
| 1402 | |
---|
| 1403 | |
---|
| 1404 | |
---|
| 1405 | |
---|
| 1406 | |
---|
| 1407 | |
---|
| 1408 | |
---|