?? torr_tool.m
字號:
% By Philip Torr 2002% copyright Microsoft Corp.% % %designed for the good of the world by Philip Torr based on ideas contained in % copyright Philip Torr and Microsoft Corp 2002% % @inproceedings{Torr93b,% author = "Torr, P. H. S. and Murray, D. W.",% title = "Outlier Detection and Motion Segmentation",% booktitle = "Sensor Fusion VI",% editor = "Schenker, P. S.",% publisher = "SPIE volume 2059",% note = "Boston",% pages = {432-443},% year = 1993 }% % % @phdthesis{Torr:thesis,% author="Torr, P. H. S.",% title="Outlier Detection and Motion Segmentation",% school=" Dept. of Engineering Science, University of Oxford",% year=1995}% % @inproceedings{Beardsley96a,% author="Beardsley, P. and Torr, P. H. S. and Zisserman, A.",% title="{3D} Model Aquisition from Extended Image Sequences",% booktitle=eccv4.2,% editor = "Buxton, B. and Cipolla R.",% publisher = "Springer--Verlag",% pages={683--695},% year=1996}% % % @article{Torr97c,% author="Torr, P. H. S. and Murray, D. W. ",% title="The Development and Comparison of Robust Methods for Estimating the Fundamental Matrix",% journal="IJCV",% volume = 24,% number = 3,% pages = {271--300},% year=1997% }% % % % % @article{Torr99c,% author = "Torr, P. H. S. and Zisserman, A",% title ="MLESAC: A New Robust Estimator with Application to Estimating Image Geometry ",% journal = "CVIU",% Volume = {78},% number = 1,% pages = {138-156},% year = 2000}% % %MAPSAC is the Bayesian version of MLESAC, and it is easier to pronounce!% it is described in:% % @article{Torr02d,% author = "Torr, P. H. S.",% title ="Bayesian Model Estimation and Selection for Epipolar Geometry and% Generic Manifold Fitting",% journal = "IJCV",% Volume = {?},% number = ?,% pages = {?},% url = "http://research.microsoft.com/~philtorr/",% year = 2002}% function varargout = torr_tool(varargin)% TORR_TOOL Application M-file for torr_tool.fig% FIG = TORR_TOOL launch torr_tool GUI.% TORR_TOOL('callback_name', ...) invoke the named callback.% Last Modified by GUIDE v2.0 21-May-2002 17:58:20if nargin == 0 % LAUNCH GUI fig = openfig(mfilename,'reuse'); % Use system color scheme for figure: set(fig,'Color',get(0,'defaultUicontrolBackgroundColor')); % Generate a structure of handles to pass to callbacks, and store it. handles = guihandles(fig); %phils atuff added, initialization %corner parameters handles.n_corners = 2000; %max no of corners permitted/requested handles.n_corners1 = 0; %the actual number detected handles.n_corners2 = 0; handles.corner_sigma = 1.0; handles.corner_width = 3; %matchin parameters handles.max_disparity = 50; handles.match_half_size = 3; %F parameters: handles.no_samp = 500; % no of samples in the mapsac algorithm handles.f_threshold = 6.0; % f_threshold in the mapsac algorithm %calibration matrix handles.focal_length = 3; %first guess handles.aspect_ratio = 1; handles.ppx = 0; handles.ppy = 0; %work out calibration matrix C = [handles.aspect_ratio 0 handles.ppx; 0 1 handles.ppy; 0 0 1/handles.focal_length]; handles.C = C; %informational variables handles.n_matches = 0; %how many matches have we detected. %general parameters %debugt mode handles.debug = 1; handles.m3 = 256; %third homogeous pixel coordinate, chosen as 256 to help conditioning, see my thesis handles.pathname = ['C:\matlabR12\bin\']; if ~handles.debug helpdlg('Phil asks: "how ya diddling", first load some images') end set(handles.save_image1_button, 'Enable', 'off'); set(handles.save_image2_button, 'Enable', 'off'); set(handles.Save_Images_menu, 'Enable', 'off'); %for corners set(handles.detect_corner_button, 'Enable', 'off'); set(handles.save_corner_button, 'Enable', 'off'); set(handles.load_corner_button, 'Enable', 'on'); set(handles.corn_param_button, 'Enable', 'off'); %for correlation matches set(handles.match_button, 'Enable', 'off'); set(handles.match_param_button, 'Enable', 'on'); set(handles.manual_match_button, 'Enable', 'on'); set(handles.save_match_button, 'Enable', 'off'); set(handles.load_match_button, 'Enable', 'off'); %for F and correlation matches set(handles.mapsac_button, 'Enable', 'off'); set(handles.mapsac_parameters_button, 'Enable', 'on'); set(handles.save_F_button, 'Enable', 'off'); set(handles.display_epipolar_button, 'Enable', 'off'); set(handles.display_epipolar_button2, 'Enable', 'off'); set(handles.ImproveF_button, 'Enable', 'off'); %for SFM set(handles.sfm_button, 'Enable', 'off'); guidata(fig, handles); if nargout > 0 varargout{1} = fig; end elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK try [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard catch disp(lasterr); end end%| ABOUT CALLBACKS:%| GUIDE automatically appends subfunction prototypes to this file, and %| sets objects' callback properties to call them through the FEVAL %| switchyard above. This comment describes that mechanism.%|%| Each callback subfunction declaration has the following form:%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)%|%| The subfunction name is composed using the object's Tag and the %| callback type separated by '_', e.g. 'slider2_Callback',%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.%|%| H is the callback object's handle (obtained using GCBO).%|%| EVENTDATA is empty, but reserved for future use.%|%| HANDLES is a structure containing handles of components in GUI using%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This%| structure is created at GUI startup using GUIHANDLES and stored in%| the figure's application data using GUIDATA. A copy of the structure%| is passed to each callback. You can store additional information in%| this structure at GUI startup, and you can change the structure%| during callbacks. Call guidata(h, handles) after changing your%| copy to replace the stored original so that subsequent callbacks see%| the updates. Type "help guihandles" and "help guidata" for more%| information.%|%| VARARGIN contains any extra arguments you have passed to the%| callback. Specify the extra arguments by editing the callback%| property in the inspector. By default, GUIDE sets the property to:%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))%| Add any extra arguments after the last argument, before the final%| closing parenthesis.% --------------------------------------------------------------------%%get rid f current stuff and do it again!function varargout = start_again_button_Callback(h, eventdata, handles, varargin)% Stub for Callback of the uicontrol handles.start_again_button.clear_button_Callback(h, eventdata, handles, varargin)initialize(handles)% --------------------------------------------------------------------function varargout = frame1_Callback(h, eventdata, handles, varargin)% Stub for Callback of the uicontrol handles.frame1.disp('frame1 Callback not implemented yet. O great one')%---------------------------------------------------------------------\\\function menu_OpenImage_Callback(h,eventdata,handles,varargin)disp('loading some images your highness')load_image_button_Callback(h, eventdata, handles, varargin)%---------------------------------------------------------------------\\\function menu_SaveImages_Callback(h,eventdata,handles,varargin)save_image1_button_Callback(h, eventdata, handles, varargin)save_image_button2_Callback(h, eventdata, handles, varargin)%---------------------------------------------------------------------\\\function menu_display_corners_Callback(h,eventdata,handles,varargin)clear_button_Callback(h, eventdata, handles, varargin);display_corners_in_figure(handles);%---------------------------------------------------------------------\\\function menu_display_c_matches_Callback(h,eventdata,handles,varargin)clear_button_Callback(h, eventdata, handles, varargin);display_matches(h, eventdata, handles, varargin);%---------------------------------------------------------------------\\\function menu_display_i_matches_Callback(h,eventdata,handles,varargin)clear_button_Callback(h, eventdata, handles, varargin);display_inliers(h, eventdata, handles, varargin);%---------------------------------------------------------------------\\\function menu_display_io_matches_Callback(h,eventdata,handles,varargin)clear_button_Callback(h, eventdata, handles, varargin);display_matches(h, eventdata, handles, varargin);display_inliers(h, eventdata, handles, varargin);%---------------------------------------------------------------------\\\% --------------------------------------------------------------------function display_corners_in_figure(handles)% extracting the handle of the axes in which to display the imageax_handle2 = handles.axes2;ax_handle3 = handles.axes3; ccr1 = handles.ccr1;ccr2 = handles.ccr2;axes(ax_handle2);hold onaxes(ax_handle3);hold on% plot(c_col, c_row, '+');plot(ccr1(:,1), ccr1(:,2), 'g+','Parent', ax_handle2);plot(ccr2(:,1), ccr2(:,2), 'r+','Parent', ax_handle3);axes(ax_handle2); hold offaxes(ax_handle3); hold off% --------------------------------------------------------------------function varargout = detect_corner_button_Callback(h, eventdata, handles, varargin)% Stub for Callback of the uicontrol handles.pushbutton3.disp('Calculating corners.')[ccr1] = torr_charris(handles.d1,handles.n_corners,handles.corner_width,handles.corner_sigma);[ccr2] = torr_charris(handles.d2,handles.n_corners,handles.corner_width,handles.corner_sigma);%normalize so that the centre of the image is the origin...ccr1(:,1) = ccr1(:,1) - handles.image_centrex;ccr1(:,2) = ccr1(:,2) - handles.image_centrey;ccr2(:,1) = ccr2(:,1) - handles.image_centrex;ccr2(:,2) = ccr2(:,2) - handles.image_centrey;handles.ccr1 = ccr1;handles.ccr2 = ccr2;handles.n_corners1 = length(ccr1);handles.n_corners2 = length(ccr2);display_corners_in_figure(handles)set(handles.save_corner_button, 'Enable', 'on');set(handles.match_button, 'Enable', 'on');set(handles.match_param_button, 'Enable', 'on');% set(handles.manual_match_button, 'Enable', 'on');guidata(handles.figure1, handles);% --------------------------------------------------------------------%here is phil's code to get a file, it uses the warning dialog%it has not been properly testedfunction [filename, pathname] = uigetfile_name(filer,message)[filename, pathname] = uigetfile(filer,message)if isequal(filename,0)|isequal(pathname,0) %recurse [filename, pathname] = uigetfile_name(filer,message);else disp(['File ', pathname, filename, ' found'])end% --------------------------------------------------------------------function [filename, pathname] = uiputfile_name(filer,message)[filename, pathname] = uiputfile(filer,message)if isequal(filename,0)|isequal(pathname,0) [filename, pathname] = uiputfile_name(filer,message);else disp(['File ', pathname, filename, ' has been saved'])end% --------------------------------------------------------------------function varargout = load_demo_image_button_Callback(h, eventdata, handles, varargin)% Stub for Callback of the uicontrol handles.pushbutton5.% [filename, pathname] = uigetfile_name('*.bmp;*.jpg;*.gif','Pick an input image')% [i1,map1] = imread([pathname filename]);% % [filename, pathname] = uigetfile_name('*.bmp;*.jpg;*.gif','Pick a second input image')% [i2,map2] = imread([pathname filename]);pathname1 = ['.\'];pathname2 = ['.\'];filename1=['j1.bmp'];filename2=['j2.bmp'];load_2images(h, eventdata, handles, varargin, filename1, pathname1,filename2, pathname2);%---------------------------------------------------------------------\\\function varargout = load_2images(h, eventdata, handles, varargin, ... filename1, pathname1,filename2, pathname2)if pathname1 == pathname2 handles.pathname = pathname1;else errordlg(['The two images should be in the same directory:' pathname1 pathname2],'not fatal'); handles.pathname = pathname1;end[i1,map1] = imread([pathname1 filename1]);[i2,map2] = imread([pathname2 filename2]);iii = size(size(i1));if iii(2) == 3 g1 = rgb2gray(i1); disp('converting to rgb');else g1 = i1;endiii = size(size(i2));if iii(2) == 3 g2 = rgb2gray(i2);else g2 = i2;end%if we successfully load:set(handles.detect_corner_button, 'Enable', 'on');set(handles.load_corner_button, 'Enable', 'on');set(handles.corn_param_button, 'Enable', 'on');set(handles.save_image1_button, 'Enable', 'on'); set(handles.save_image2_button, 'Enable', 'on');set(handles.Save_Images_menu, 'Enable', 'on');set(handles.manual_match_button, 'Enable', 'on');set(handles.load_match_button, 'Enable', 'on');d1 = double(g1);d2 = double(g2);% extracting the handle of the axes in which to display the imageax_handle2 = handles.axes2; axes(ax_handle2);set(get(ax_handle2, 'Title'), 'Visible', 'off');set(get(ax_handle2, 'Title'),'String', 'fff');[m,n] = size(d1);[m1,n1] = size(d2);if (m ~= m1) | (n ~= n1) error('images must be the same size')endaxis equal;colormap(map1);image(i1, 'Parent', ax_handle2,'XData',-n/2,'YData',-m/2);% imshow(i1, 'Parent', ax_handle2);ax_handle3 = handles.axes3; axes(ax_handle3);colormap(map1);image(i2, 'Parent', ax_handle3,'XData',-n/2,'YData',-m/2);handles.image_centrex = n/2;handles.image_centrey = m/2;handles.i1 = i1;handles.i2 = i2;handles.d1 = d1;handles.d2 = d2;handles.pathname = pathname1;% saving the GUI dataguidata(handles.figure1, handles);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -