Changeset 128 for trunk/src/geometry_calib.m
- Timestamp:
- Nov 21, 2010, 10:06:11 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r121 r128 54 54 'gui_LayoutFcn', [] , ... 55 55 'gui_Callback', []); 56 if nargin && ischar(varargin{1}) 56 if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback','once')) 57 57 gui_State.gui_Callback = str2func(varargin{1}); 58 58 end … … 95 95 if exist('inputfile','var')&& ~isempty(inputfile) 96 96 struct.XmlInputFile=inputfile; 97 set(hObject,'UserData',struct) 98 [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile); 97 [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile); 99 98 if ~strcmp(ext,'.xml') 100 99 inputfile=[fullfile(Pathsub,RootFile) '.xml'];%xml file corresponding to the input file … … 103 102 set(handles.ListCoord,'String',{'......'}) 104 103 if exist(inputfile,'file') 105 loadfile(handles,inputfile)% load the point coordiantes existing in the xml file 106 end 104 Heading=loadfile(handles,inputfile);% load the point coordiantes existing in the xml file 105 end 106 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign) 107 struct.Campaign=Heading.Campaign; 108 end 109 set(hObject,'UserData',struct) 107 110 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function 108 111 … … 213 216 ['Error rms (along x,y)=' num2str(GeometryCalib.ErrorRms) ' pixels'];... 214 217 ['Error max (along x,y)=' num2str(GeometryCalib.ErrorMax) ' pixels']}); 218 219 %% record the calibration parameters and display the current image of uvmat in the new phys coordinates 215 220 if strcmp(answer,'Yes') 216 221 if strcmp(calib_cell{val}(1:2),'3D')%set the plane position for 3D (projection) calibration … … 219 224 Z_plane=0; %default 220 225 else 221 Z_plane=str2 num(answer_1);226 Z_plane=str2double(answer_1); 222 227 end 223 228 GeometryCalib.NbSlice=1; … … 228 233 msgbox_uvmat('ERROR',errormsg); 229 234 end 235 230 236 %display image with new calibration in the currently opened uvmat interface 231 237 hhh=findobj(hhuvmat.axes3,'Tag','calib_marker');% delete calib points and markers … … 251 257 %------------------------------------------------------------------ 252 258 % --- Executes on button press in calibrate_lin. 259 253 260 function REPLICATE_Callback(hObject, eventdata, handles) 254 % %%%%%%Todo: correct on the model of APPLY_Callback%%%%%%%%%% 255 %------------------------------------------------------------------------ 256 calib_cell=get(handles.calib_type,'String'); 257 val=get(handles.calib_type,'Value'); 258 Coord_cell=get(handles.ListCoord,'String'); 259 Object=read_geometry_calib(Coord_cell); 260 GeometryCalib=feval(['calib_' calib_cell{val}],Object.Coord,handles); 261 %------------------------------------------------------------------------ 262 263 %% Apply calibration 264 calib_cell=get(handles.calib_type,'String'); %#ok<NASGU> 265 val=get(handles.calib_type,'Value'); %#ok<NASGU> 261 266 262 267 %read the current calibration points … … 288 293 [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima)); 289 294 [EM,ind_dim]=max(GeometryCalib.ErrorMax); 290 index=index(ind_dim);295 % index=index(ind_dim); 291 296 %set the Z position of the reference plane used for calibration 292 297 Z_plane=[]; … … 295 300 end 296 301 answer_1=msgbox_uvmat('INPUT_TXT',' Z= ',num2str(Z_plane)); 297 Z_plane=str2 num(answer_1);302 Z_plane=str2double(answer_1); 298 303 GeometryCalib.NbSlice=1; 299 304 GeometryCalib.SliceCoord=[0 0 Z_plane]; … … 304 309 %record the points 305 310 GeometryCalib.SourceCalib.PointCoord=Coord; 306 % errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file 307 % if ~strcmp(errormsg,'') 308 % msgbox_uvmat('ERROR',errormsg); 309 % end 310 end 311 end 312 313 %% display calibration paprameters 311 314 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters 312 315 … … 319 322 set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4)) 320 323 321 % indicate the plane of the calibration grid if defined 322 % huvmat=findobj(allchild(0),'Name','uvmat'); 323 % hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 324 % RootPath=''; 325 % RootFile=''; 326 % if ~isempty(hhuvmat.RootPath)& ~isempty(hhuvmat.RootFile) 327 % testhandle=1; 328 % RootPath=get(hhuvmat.RootPath,'String'); 329 % RootFile=get(hhuvmat.RootFile,'String'); 330 % filebase=fullfile(RootPath,RootFile); 331 % outputfile=[filebase '.xml']; 332 % else 333 % question={'save the calibration data and point coordinates in'}; 334 % def={fullfile(RootPath,['ObjectCalib.xml'])}; 335 % options.Resize='on'; 336 % answer=inputdlg(question,'save average in a new file',1,def,options); 337 % outputfile=answer{1}; 338 % end 339 340 %open and read the dataview GUI 324 %% open the GUI dataview 341 325 h_dataview=findobj(allchild(0),'name','dataview'); 342 326 if ~isempty(h_dataview) … … 344 328 end 345 329 CalibData=get(handles.geometry_calib,'UserData');%read the calibration image source on the interface userdata 346 330 InputFile=''; 347 331 if isfield(CalibData,'XmlInputFile') 348 XmlInput=fileparts(CalibData.XmlInputFile);349 [ XmlInput,filename,ext]=fileparts(XmlInput);332 InputDir=fileparts(CalibData.XmlInputFile); 333 [InputDir,DirName]=fileparts(InputDir); 350 334 end 351 335 SubCampaignTest='n'; %default 352 testinput=0; 353 if isfield(CalibData,'Heading') 354 Heading=CalibData.Heading; 355 if isfield(Heading,'Record') && isequal([filename ext],Heading.Record) 356 [XmlInput,filename,ext]=fileparts(XmlInput); 357 end 358 if isfield(Heading,'Device') && isequal([filename ext],Heading.Device) 359 [XmlInput,filename,ext]=fileparts(XmlInput); 360 Device=Heading.Device; 361 end 362 if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment) 363 [PP,filename,ext]=fileparts(XmlInput); 364 end 365 testinput=0; 366 if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign) 367 SubCampaignTest='y'; 368 testinput=1; 369 elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign) 370 testinput=1; 371 end 372 end 373 if ~testinput 374 filename='PROJETS';%default 375 if isfield(CalibData,'XmlInputFile') 376 [pp,filename]=fileparts(CalibData.XmlInputFile); 377 end 378 while ~isequal(filename,'PROJETS') && numel(filename)>1 379 filename_1=filename; 380 pp_1=pp; 381 [pp,filename]=fileparts(pp); 382 end 383 XmlInput=fullfile(pp_1,filename_1); 384 testinput=1; 385 end 386 if testinput 387 outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib); 388 end 336 testup=0; 337 if isfield(CalibData,'SubCampaign') 338 SubCampaignTest='y'; 339 dir_ref=CalibData.SubCampaign; 340 testup=1; 341 elseif isfield(CalibData,'Campaign') 342 dir_ref=CalibData.Campaign; 343 testup=1; 344 end 345 while testup 346 [InputDir,DirName]=fileparts(InputDir); 347 if strcmp(DirName,dir_ref) 348 break 349 end 350 end 351 InputDir=fullfile(InputDir,DirName); 352 answer=msgbox_uvmat('INPUT_TXT','Campaign ?',InputDir); 353 if strcmp(answer,'Cancel') 354 return 355 end 356 357 dataview(answer,SubCampaignTest,GeometryCalib); 358 359 % if isfield(Heading,'Device') && isequal([filename ext],Heading.Device) 360 % [XmlInput,filename,ext]=fileparts(XmlInput); 361 % Device=Heading.Device; 362 % end 363 % if isfield(Heading,'Experiment') && isequal([filename ext],Heading.Experiment) 364 % [PP,filename,ext]=fileparts(XmlInput); 365 % end 366 % testinput=0; 367 % if isfield(Heading,'SubCampaign') && isequal([filename ext],Heading.SubCampaign) 368 % SubCampaignTest='y'; 369 % testinput=1; 370 % elseif isfield(Heading,'Campaign') && isequal([filename ext],Heading.Campaign) 371 % testinput=1; 372 % % end 373 % end 374 % if ~testinput 375 % filename='PROJETS';%default 376 % if isfield(CalibData,'XmlInputFile') 377 % [pp,filename]=fileparts(CalibData.XmlInputFile); 378 % end 379 % while ~isequal(filename,'PROJETS') && numel(filename)>1 380 % filename_1=filename; 381 % pp_1=pp; 382 % [pp,filename]=fileparts(pp); 383 % end 384 % XmlInput=fullfile(pp_1,filename_1); 385 % testinput=1; 386 % end 387 % if testinput 388 % outcome=dataview(XmlInput,SubCampaignTest,GeometryCalib); 389 % end 389 390 390 391 %------------------------------------------------------------------------ … … 434 435 R=[R;[0 0]]; 435 436 GeometryCalib.R=[R [0;0;1]]; 436 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0] 437 GeometryCalib.omc=(180/pi)*[acos(GeometryCalib.R(1,1)) 0 0]; 437 438 %------------------------------------------------------------------------ 438 439 % determine the tsai parameters for a view normal to the grid plane … … 700 701 701 702 %-------------------------------------------------------------------------- 702 function GeometryCalib=calib_tsai(Coord,handles)% old version using gauthier's bianry ccal_fo703 function GeometryCalib=calib_tsai(Coord,handles)% OBSOLETE: old version using gauthier's bianry ccal_fo 703 704 % NOT USED 704 705 %------------------------------------------------------------------------ … … 811 812 huvmat=findobj(allchild(0),'Name','uvmat'); 812 813 hhuvmat=guidata(huvmat);%handles of elements in the GUI uvmat 813 RootPath='';814 RootFile='';814 % RootPath=''; 815 % RootFile=''; 815 816 if ~isempty(hhuvmat.RootPath)&& ~isempty(hhuvmat.RootFile) 816 817 testhandle=1; … … 830 831 listfile={outputfile}; 831 832 else 832 listfile=[listfile;{outputfile}] %update the list of coord files833 listfile=[listfile;{outputfile}];%update the list of coord files 833 834 end 834 835 set(handles.coord_files,'string',listfile); … … 901 902 end 902 903 coord_str=Coord_cell{val}; 903 k=findstr(' |',coord_str);904 k=findstr(' | ',coord_str); 904 905 if isempty(k)%last line '.....' selected 905 906 if ~isempty(hhh) … … 1000 1001 %------------------------------------------------------------------------ 1001 1002 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 1002 UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface1003 %UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface 1003 1004 hhuvmat=guidata(huvmat); %handles of GUI elements in uvmat 1004 hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat1005 %hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat 1005 1006 h_menu_coord=findobj(huvmat,'Tag','transform_fct'); 1006 1007 menu=get(h_menu_coord,'String'); … … 1079 1080 1080 1081 %size(data.Coord,1) 1081 Tabchar=cell2tab(Coord,' |');1082 Tabchar=cell2tab(Coord,' | '); 1082 1083 Tabchar=[Tabchar ;{'......'}]; 1083 1084 set(handles.ListCoord,'String',Tabchar) … … 1236 1237 Coord{ipoint,5}=num2str(Ypx(ipoint),4);%display coordiantes with 4 digits 1237 1238 end 1238 Tabchar=cell2tab(Coord(end:-1:1,:),' |');1239 Tabchar=cell2tab(Coord(end:-1:1,:),' | '); 1239 1240 Tabchar=[Tabchar ;{'......'}]; 1240 1241 set(handles.ListCoord,'Value',1) … … 1266 1267 end 1267 1268 end 1268 Tabchar=cell2tab(Coord,' |');1269 Tabchar=cell2tab(Coord,' | '); 1269 1270 Tabchar=[Tabchar; {'.....'}]; 1270 1271 %set(handles.ListCoord,'Value',1) … … 1310 1311 end 1311 1312 end 1312 Tabchar=cell2tab(Coord,' |');1313 Tabchar=cell2tab(Coord,'| '); 1313 1314 Tabchar=[Tabchar;{'......'}]; 1314 1315 set(handles.ListCoord,'Value',1) … … 1460 1461 end 1461 1462 CoordCell=reshape(CoordCell,[],5); 1462 Tabchar=cell2tab(CoordCell,' |');%transform cells into table ready for display1463 Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display 1463 1464 Tabchar=[Tabchar;{'......'}]; 1464 1465 set(handles.ListCoord,'Value',1) … … 1541 1542 1542 1543 % ----------------------------------------------------------------------- 1543 function loadfile(handles,fileinput) 1544 %------------------------------------------------------------------------ 1544 function Heading=loadfile(handles,fileinput) 1545 %------------------------------------------------------------------------ 1546 Heading=[];%default 1545 1547 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib'); 1548 if ~isempty(errormsg) 1549 msgbox_uvmat('ERROR',['Error for reading ' fileinput ': ' errormsg]) 1550 return 1551 end 1552 if ~isempty(s.Heading) 1553 Heading=s.Heading; 1554 end 1555 1546 1556 GeometryCalib=s.GeometryCalib; 1547 1557 fx=1;fy=1;Cx=0;Cy=0;kc=0; %default … … 1585 1595 end 1586 1596 CoordCell=reshape(CoordCell,[],5); 1587 Tabchar=cell2tab(CoordCell,' |');%transform cells into table ready for display1597 Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display 1588 1598 MenuPlot_Callback(handles.geometry_calib, [], handles) 1589 1599 end
Note: See TracChangeset
for help on using the changeset viewer.