Changeset 682 for trunk/src/geometry_calib.m
- Timestamp:
- Sep 2, 2013, 7:44:19 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r680 r682 50 50 % Edit the above text to modify the response to help geometry_calib 51 51 52 % Last Modified by GUIDE v2.5 31-Jul-2013 23:03:1852 % Last Modified by GUIDE v2.5 02-Sep-2013 16:47:27 53 53 54 54 % Begin initialization code - DO NOT edit … … 147 147 end 148 148 149 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function150 151 152 149 %------------------------------------------------------------------------ 153 150 % --- Outputs from this function are returned to the command line. … … 181 178 %------------------------------------------------------------------------ 182 179 %% look for the GUI uvmat and check for an image as input 180 set(handles.APPLY,'BackgroundColor',[1 1 0]) 183 181 huvmat=findobj(allchild(0),'Name','uvmat'); 184 182 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat … … 198 196 [GeometryCalib,index]=calibrate(handles,hhuvmat);% apply calibration 199 197 200 %% copy the xml file from the old location if appropriate, then update with the calibration parameters 201 if ~exist(outputfile,'file') && ~isempty(SubDirBase) 202 oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml']; 203 if exist(oldxml,'file') 204 [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention 205 end 206 end 207 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file 208 if ~strcmp(errormsg,'') 209 msgbox_uvmat('ERROR',errormsg); 210 end 211 212 %% display image with new calibration in the currently opened uvmat interface 213 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers 214 if ~isempty(hhh) 215 delete(hhh); 216 end 217 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points'); 218 if ~isempty(hhh) 219 delete(hhh); 220 end 221 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' 222 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 223 UserData=get(handles.geometry_calib,'UserData'); 224 UserData.XmlInputFile=outputfile;%save the current xml file name 225 set(handles.geometry_calib,'UserData',UserData) 226 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 227 PLOT_Callback(hObject, eventdata, handles) 228 Data=get(handles.ListCoord,'Data'); 229 Data(:,6)=zeros(size(Data,1),1); 230 Data(index,6)=1;% indicate in the list the point with max deviation (possible mistake) 231 set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake) 232 figure(handles.geometry_calib) 198 if isempty(GeometryCalib) % if calibration cancelled 199 set(handles.APPLY,'BackgroundColor',[1 0 1]) 200 else % if calibration confirmed 201 202 %% copy the xml file from the old location if appropriate, then update with the calibration parameters 203 if ~exist(outputfile,'file') && ~isempty(SubDirBase) 204 oldxml=[fullfile(RootPath,SubDirBase,get(hhuvmat.RootFile,'String')) '.xml']; 205 if exist(oldxml,'file') 206 [success,message]=copyfile(oldxml,outputfile);%copy the old xml file to a new one with the new convention 207 end 208 end 209 errormsg=update_imadoc(GeometryCalib,outputfile,'GeometryCalib');% introduce the calibration data in the xml file 210 if ~strcmp(errormsg,'') 211 msgbox_uvmat('ERROR',errormsg); 212 end 213 214 %% display image with new calibration in the currently opened uvmat interface 215 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_marker');% delete calib points and markers 216 if ~isempty(hhh) 217 delete(hhh); 218 end 219 hhh=findobj(hhuvmat.PlotAxes,'Tag','calib_points'); 220 if ~isempty(hhh) 221 delete(hhh); 222 end 223 set(hhuvmat.CheckFixLimits,'Value',0)% put FixedLimits option to 'off' 224 set(hhuvmat.CheckFixLimits,'BackgroundColor',[0.7 0.7 0.7]) 225 UserData=get(handles.geometry_calib,'UserData'); 226 UserData.XmlInputFile=outputfile;%save the current xml file name 227 set(handles.geometry_calib,'UserData',UserData) 228 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 229 PLOT_Callback(hObject, eventdata, handles) 230 Data=get(handles.ListCoord,'Data'); 231 Data(:,6)=zeros(size(Data,1),1); 232 Data(index,6)=1;% indicate in the list the point with max deviation (possible mistake) 233 set(handles.ListCoord,'Data',Data)% indicate in the list the point with max deviation (possible mistake) 234 figure(handles.geometry_calib) 235 set(handles.APPLY,'BackgroundColor',[1 0 0]) 236 end 233 237 234 238 %------------------------------------------------------------------------ … … 348 352 %% get plane position(s) 349 353 if ~strcmp(answer,'Yes') 354 GeometryCalib=[]; 355 index=1; 350 356 return 351 357 end … … 773 779 set(handles.ListCoordFiles,'String',{''}) 774 780 775 % %------------------------------------------------------------------------776 % function XObject_Callback(hObject, eventdata, handles)777 % %------------------------------------------------------------------------778 % update_list(hObject, eventdata,handles)779 %780 % %------------------------------------------------------------------------781 % function YObject_Callback(hObject, eventdata, handles)782 % %------------------------------------------------------------------------783 % update_list(hObject, eventdata,handles)784 %785 % %------------------------------------------------------------------------786 % function ZObject_Callback(hObject, eventdata, handles)787 % %------------------------------------------------------------------------788 % update_list(hObject, eventdata,handles)789 %790 % %------------------------------------------------------------------------791 % function update_list(hObject, eventdata, handles)792 % %------------------------------------------------------------------------793 % newval(4)=str2double(get(handles.XImage,'String'));794 % newval(5)=str2double(get(handles.YImage,'String'));795 % newval(1)=str2double(get(handles.XObject,'String'));796 % newval(2)=str2double(get(handles.YObject,'String'));797 % newval(3)=str2double(get(handles.ZObject,'String'));798 % if isnan(newval(3))799 % newval(3)=0;%put z to 0 by default800 % end801 % Coord=get(handles.ListCoord,'String');802 % Coord(end)=[]; %remove last string '.....'803 % val=get(handles.ListCoord,'Value');804 % data=read_geometry_calib(Coord);805 % data.Coord(val,:)=newval;806 % for i=1:size(data.Coord,1)807 % for j=1:5808 % Coord_cell{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits809 % end810 % end811 %812 % Tabchar=cell2tab(Coord_cell,' | ');813 % Tabchar=[Tabchar ;{'......'}];814 % set(handles.ListCoord,'String',Tabchar)815 %816 % %update the plot817 % ListCoord_Callback(hObject, eventdata, handles)818 % PLOT_Callback(hObject, eventdata, handles)819 820 781 %------------------------------------------------------------------------ 821 782 % --- Executes on selection change in CheckEnableMouse. … … 836 797 set(handles.CheckEnableMouse,'BackgroundColor',[0.7 0.7 0.7]) 837 798 end 838 839 % function NEW_Callback(hObject, eventdata, handles)840 % %A METTRE SOUS UN BOUTON841 % huvmat=findobj(allchild(0),'Name','uvmat');842 % hchild=get(huvmat,'children');843 % hcoord=findobj(hchild,'Tag','menu_coord');844 % coordtype=get(hcoord,'Value');845 % haxes=findobj(hchild,'Tag','axes3');846 % AxeData=get(haxes,'UserData');847 % if ~isequal(hcoord,2)848 % set(hcoord,'Value',2)849 % huvmat=uvmat(AxeData);850 % 'relancer uvmat';851 % end852 % if ~isfield(AxeData,'ZoomAxes')853 % msgbox_uvmat('ERROR','first draw a window around a grid marker')854 % return855 % end856 % XLim=get(AxeData.ZoomAxes,'XLim');857 % YLim=get(AxeData.ZoomAxes,'YLim');858 % np=size(AxeData.A);859 % ind_sub_x=round(XLim);860 % ind_sub_y=np(1)-round(YLim);861 % Mfiltre=AxeData.A(ind_sub_y(2):ind_sub_y(1) ,ind_sub_x,:);862 % Mfiltre_norm=double(Mfiltre);863 % Mfiltre_norm=Mfiltre_norm/sum(sum(Mfiltre_norm));864 % Mfiltre_norm=100*(Mfiltre_norm-mean(mean(Mfiltre_norm)));865 % Atype=class(AxeData.A);866 % Data.NbDim=2;867 % Data.A=filter2(Mfiltre_norm,double(AxeData.A));868 % Data.A=feval(Atype,Data.A);869 % Data.AName='image';870 % Data.AX=AxeData.AX;871 % Data.AY=AxeData.AY;872 % Data.CoordType='px';873 % plot_field(Data)874 799 875 800 … … 887 812 % -------------------------------------------------------------------- 888 813 function MenuSetScale_Callback(hObject, eventdata, handles) 889 % hObject handle to MenuSetScale (see GCBO) 890 % eventdata reserved - to be defined in a future version of MATLAB 891 % handles structure with handles and user data (see GUIDATA) 892 answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?','') 814 815 answer=msgbox_uvmat('INPUT_TXT','scale pixel/cm?',''); 893 816 %create test points 894 817 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle … … 902 825 Coord=[x y zeros(4,1) Xima Yima zeros(4,1)]; 903 826 set(handles.ListCoord,'Data',Coord) 827 set(handles.APPLY,'BackgroundColor',[1 0 1]) 904 828 905 829 %------------------------------------------------------------------------ … … 918 842 Coord(1:size(T,1),1:3)=T;%update the existing list of phys coordinates from the GUI create_grid 919 843 set(handles.ListCoord,'Data',Coord) 844 set(handles.APPLY,'BackgroundColor',[1 0 1]) 920 845 921 846 % ----------------------------------------------------------------------- … … 952 877 [T,CalibData.grid,white_test]=create_grid(grid_input,'detect_grid');%display the GUI create_grid, read the set of phys coordinates T 953 878 set(handles.geometry_calib,'UserData',CalibData)%store the phys grid parameters for later use 954 955 956 879 957 880 %% read the current image, displayed in the GUI uvmat … … 1051 974 set(handles.ListCoord,'Data',Coord) 1052 975 PLOT_Callback(hObject, eventdata, handles) 976 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1053 977 1054 978 %----------------------------------------------------------------------- … … 1070 994 Coord(:,3)=T(3)+Coord(:,3); 1071 995 set(handles.ListCoord,'Data',Coord); 996 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1072 997 1073 998 % -------------------------------------------------------------------- … … 1103 1028 Coord(:,2)=r3*x+r4*y; 1104 1029 set(handles.ListCoord,'Data',Coord) 1030 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1105 1031 1106 1032 % -------------------------------------------------------------------- … … 1116 1042 set(handles.ListCoord,'Data',Coord) 1117 1043 PLOT_Callback(handles.geometry_calib, [], handles) 1044 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1118 1045 1119 1046 % ----------------------------------------------------------------------- … … 1187 1114 Heading=s.Heading; 1188 1115 end 1189 1116 1190 1117 GeometryCalib=s.GeometryCalib; 1191 1118 fx=1;fy=1;Cx=0;Cy=0;kc=0; %default … … 1196 1123 % choose the calibration option 1197 1124 if isfield(GeometryCalib,'CalibrationType') 1198 calib_list=get(handles.calib_type,'String');1199 for ilist=1:numel(calib_list)1200 if strcmp(calib_list{ilist},GeometryCalib.CalibrationType)1201 val_cal=ilist;1202 break1203 end1204 end1125 calib_list=get(handles.calib_type,'String'); 1126 for ilist=1:numel(calib_list) 1127 if strcmp(calib_list{ilist},GeometryCalib.CalibrationType) 1128 val_cal=ilist; 1129 break 1130 end 1131 end 1205 1132 end 1206 1133 display_intrinsic(GeometryCalib,handles)%intrinsic param … … 1218 1145 end 1219 1146 if isfield(GeometryCalib,'SourceCalib') 1220 calib=GeometryCalib.SourceCalib.PointCoord; 1221 Coord=[calib zeros(size(calib,1),1)]; 1222 set(handles.ListCoord,'Data',Coord) 1223 end 1224 % CoordCell=reshape(CoordCell,[],5); 1225 % Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display 1147 calib=GeometryCalib.SourceCalib.PointCoord; 1148 Coord=[calib zeros(size(calib,1),1)]; 1149 set(handles.ListCoord,'Data',Coord) 1150 end 1226 1151 PLOT_Callback(handles.geometry_calib, [], handles) 1152 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1227 1153 end 1228 1154 set(handles.calib_type,'Value',val_cal) … … 1347 1273 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard 1348 1274 %------------------------------------------------------------------------ 1349 function key_press_fcn(hObject,eventdata,handles) 1350 1275 function ListCoord_KeyPressFcn(hObject, eventdata, handles) 1351 1276 xx=double(get(handles.geometry_calib,'CurrentCharacter'));%get the keyboard character 1352 %if ismember(xx,[8 127])%backspace or delete1353 1277 if ismember(xx,[30 31 127])% arrow upward, downward, or delete 1354 1278 Coord=get(handles.ListCoord,'Data'); … … 1363 1287 Coord(ind,:)=[]; 1364 1288 PLOT_Callback(hObject,eventdata,handles) 1289 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1290 otherwise 1365 1291 end 1366 1292 set(handles.ListCoord,'Data',Coord); 1367 end 1368 1293 else 1294 set(handles.APPLY,'BackgroundColor',[1 0 1]) 1295 end 1369 1296 1370 1297
Note: See TracChangeset
for help on using the changeset viewer.