Changeset 17 for trunk/src/geometry_calib.m
- Timestamp:
- Feb 18, 2010, 7:37:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r12 r17 109 109 %set(htable,'ColumnNames',{'x','y','z','X(pixels)','Y(pixels)'}) 110 110 111 %------------------------------------------------------------------------ 111 112 % --- Outputs from this function are returned to the command line. 112 113 function varargout = geometry_calib_OutputFcn(hObject, eventdata, handles) 113 % varargout cell array for returning output args (see VARARGOUT); 114 % hObject handle to figure 115 % eventdata reserved - to be defined in a future version of MATLAB 116 % handles structure with handles and user data (see GUIDATA) 117 114 %------------------------------------------------------------------------ 118 115 % Get default command line output from handles structure 119 116 varargout{1} = handles.output; … … 123 120 function Phi_Callback(hObject, eventdata, handles) 124 121 125 126 127 128 %-------------------------------------------------- 122 %------------------------------------------------------------------------ 129 123 %read input xml file and update the edit boxes 130 124 function loadfile(handles,fileinput) 131 125 %------------------------------------------------------------------------ 132 126 %read the input xml file 133 127 t=xmltree(fileinput); … … 267 261 unit=unitlist{get(handles.CoordUnit,'value')}; 268 262 GeometryCalib.CoordUnit=unit; 269 263 GeometryCalib.SourceCalib.PointCoord=Object.Coord; 270 264 huvmat=findobj(allchild(0),'Name','uvmat'); 271 265 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat … … 285 279 outputfile=answer{1}; 286 280 end 287 testappend=0; 288 if exist(outputfile,'file');%=1 if the output file already exists, 0 else 289 t=xmltree(outputfile); %read the file 290 backupfile=outputfile; 291 testexist=2; 292 while testexist==2 293 backupfile=[backupfile '~'];% make a backup name by adding ~ to the xml file name 294 testexist=exist(backupfile,'file'); 295 end 296 [success,message]=copyfile(outputfile,backupfile);%make backup 297 t=xmltree(outputfile); %read the file 298 uid=find(t,'ImaDoc'); 299 if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup) 300 if isequal(success,1) 301 delete(outputfile) 302 else 303 msgbox_uvmat('ERROR',['error in the backup of the existing xml file: ' message]) 304 return 305 end 306 else 307 uid_calib=find(t,'ImaDoc/GeometryCalib'); 308 testappend=1; 309 if isempty(uid_calib) 310 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 311 else %if GeometryCalib already exists, delete its content 312 uid_child=children(t,uid_calib); 313 t=delete(t,uid_child); 314 % testappend=1; 315 end 316 end 317 end 318 if ~testappend %create a new xml file for calibration data 319 t=xmltree; 320 t=set(t,1,'name','ImaDoc'); 321 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 322 end 323 % hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata 324 % imagename=get(hgrid,'UserData'); 325 % if exist(imagename,'file') 326 % GeometryCalib.SourceCalib.ImageCalib=imagename; 281 update_imadoc(GeometryCalib,outputfile) 282 % testappend=0; 283 % if exist(outputfile,'file');%=1 if the output file already exists, 0 else 284 % t=xmltree(outputfile); %read the file 285 % backupfile=outputfile; 286 % testexist=2; 287 % while testexist==2 288 % backupfile=[backupfile '~'];% make a backup name by adding ~ to the xml file name 289 % testexist=exist(backupfile,'file'); 290 % end 291 % [success,message]=copyfile(outputfile,backupfile);%make backup 292 % t=xmltree(outputfile); %read the file 293 % uid=find(t,'ImaDoc'); 294 % if ~isequal(uid,1)%if the xml file is not ImaDoc, delete it (after backup) 295 % if isequal(success,1) 296 % delete(outputfile) 297 % else 298 % msgbox_uvmat('ERROR',['error in the backup of the existing xml file: ' message]) 299 % return 300 % end 301 % else 302 % uid_calib=find(t,'ImaDoc/GeometryCalib'); 303 % testappend=1; 304 % if isempty(uid_calib) 305 % [t,uid_calib]=add(t,1,'element','GeometryCalib'); 306 % else %if GeometryCalib already exists, delete its content 307 % uid_child=children(t,uid_calib); 308 % t=delete(t,uid_child); 309 % % testappend=1; 310 % end 311 % end 327 312 % end 328 GeometryCalib.SourceCalib.PointCoord=Object.Coord; 329 t=struct2xml(GeometryCalib,t,uid_calib); 330 save(t,outputfile); 313 % if ~testappend %create a new xml file for calibration data 314 % t=xmltree; 315 % t=set(t,1,'name','ImaDoc'); 316 % [t,uid_calib]=add(t,1,'element','GeometryCalib'); 317 % end 318 % % hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata 319 % % imagename=get(hgrid,'UserData'); 320 % % if exist(imagename,'file') 321 % % GeometryCalib.SourceCalib.ImageCalib=imagename; 322 % % end 323 % GeometryCalib.SourceCalib.PointCoord=Object.Coord; 324 % t=struct2xml(GeometryCalib,t,uid_calib); 325 % save(t,outputfile); 331 326 msgbox_uvmat('CONFIRMATION',{[outputfile ' updated with calibration data'];... 332 327 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... … … 364 359 end 365 360 % %record image source 366 % hgrid=get(handles.REPLICATE,'parent');%read the calibration image source on the interface userdata367 % imagename=get(hgrid,'UserData');368 % if exist(imagename,'file')369 % GeometryCalib.SourceCalib.ImageCalib=imagename;370 % end371 361 GeometryCalib.SourceCalib.PointCoord=Object.Coord; 372 373 374 %root PROJETS375 362 376 363 %open and read the dataview GUI … … 380 367 end 381 368 CalibData=get(handles.figure1,'UserData');%read the calibration image source on the interface userdata 382 % filename='PROJETS';%default383 % if isfield(CalibData,'XmlInput')384 % [pp,filename]=fileparts(CalibData.XmlInput);385 % end386 % while ~isequal(filename,'PROJETS') && numel(filename)>1387 % filename_1=filename;388 % pp_1=pp;389 % [pp,filename]=fileparts(pp)390 % end391 % projinput=fullfile(pp_1,filename_1)392 % dd=dataview(projinput)393 394 %395 % Device=[];%default396 %397 % h_dataview=dataview;398 % hhdataview=guidata(h_dataview);399 % drawnow400 369 401 370 if isfield(CalibData,'XmlInput') … … 443 412 end 444 413 if testinput 445 outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib) %,SubCampaignTest)414 outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib) 446 415 end 447 416 % %A COMPLETER … … 955 924 set(handles.ListCoord,'String',Tabchar) 956 925 ListCoord_Callback(hObject, eventdata, handles) 957 PLOT_Callback(hObject,eventdata,handles)926 MenuPlot_Callback(hObject,eventdata,handles) 958 927 end 959 928 … … 1051 1020 end 1052 1021 1053 1054 1055 % -------------------------------------------------------------------- 1022 %------------------------------------------------------------------------ 1056 1023 function MenuCreateGrid_Callback(hObject, eventdata, handles) 1024 %------------------------------------------------------------------------ 1057 1025 hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib 1058 1026 CalibData=get(hcalib,'UserData'); … … 1061 1029 Tinput=CalibData.grid; 1062 1030 end 1063 T=create_grid(Tinput) ;%display translate_points GUI and get shift parameters1031 T=create_grid(Tinput)%display the GUI create_grid 1064 1032 CalibData.grid=T; 1065 1033 set(hcalib,'UserData',CalibData) … … 1067 1035 %grid in phys space 1068 1036 Coord_cell=get(handles.ListCoord,'String'); 1069 data=read_geometry_calib(Coord_cell); 1070 data.Coord(:,1)=T(1)+data.Coord(:,1); 1071 data.Coord(:,2)=T(2)+data.Coord(:,2); 1072 data.Coord(:,3)=T(3)+data.Coord(:,3); 1073 data.Coord(:,[4 5])=data.Coord(:,[4 5]); 1074 for i=1:size(data.Coord,1) 1075 for j=1:5 1076 Coord{i,j}=num2str(data.Coord(i,j),4);%phys x,y,z 1037 data=read_geometry_calib(Coord_cell) 1038 nbpoints=size(data.Coord,1); %nbre of calibration points 1039 data.Coord(1:size(T,1),1:3)=T; 1040 for i=1:nbpoints 1041 for j=1:5 1042 Coord{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits 1077 1043 end 1078 1044 end 1045 for i=nbpoints+1:size(data.Coord,1) 1046 for j=1:3 1047 Coord{i,j}=num2str(data.Coord(i,j),4);%display coordiantes with 4 digits 1048 end 1049 for j=4:5 1050 Coord{i,j}='';%display coordiantes with 4 digi 1051 end 1052 end 1053 1054 1055 %size(data.Coord,1) 1079 1056 Tabchar=cell2tab(Coord,' | '); 1080 1057 set(handles.ListCoord,'Value',1) 1081 1058 set(handles.ListCoord,'String',Tabchar) 1082 1059 1083 1084 1085 % -------------------------------------------------------------------- 1060 %----------------------------------------------------------------------- 1086 1061 function MenuTranslatePoints_Callback(hObject, eventdata, handles) 1062 %----------------------------------------------------------------------- 1087 1063 hcalib=get(handles.calib_type,'parent');%handles of the GUI geometry_calib 1088 1064 CalibData=get(hcalib,'UserData')
Note: See TracChangeset
for help on using the changeset viewer.