Changeset 116 for trunk/src/geometry_calib.m
- Timestamp:
- Oct 16, 2010, 5:56:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r114 r116 71 71 % parameters on the uvmat interface (obtained by 'get_plot_handle.m') 72 72 %------------------------------------------------------------------------ 73 function geometry_calib_OpeningFcn(hObject, eventdata, handles, handles_uvmat,pos,inputfile)73 function geometry_calib_OpeningFcn(hObject, eventdata, handles,inputfile,pos) 74 74 %------------------------------------------------------------------------ 75 75 % Choose default command line output for geometry_calib … … 81 81 82 82 %set the position of the interface 83 if exist('pos','var')& length(pos)>283 if exist('pos','var')&& length(pos)>2 84 84 pos_gui=get(hObject,'Position'); 85 85 pos_gui(1)=pos(1); … … 92 92 set(handles.calib_type,'String',{'rescale';'linear';'quadr';'3D_linear';'3D_quadr';'3D_extrinsic'}) 93 93 inputxml=''; 94 if exist('inputfile','var')& ~isempty(inputfile)94 if exist('inputfile','var')&& ~isempty(inputfile) 95 95 struct.XmlInputFile=inputfile; 96 96 set(hObject,'UserData',struct) 97 97 [Pathsub,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(inputfile); 98 inputxml=[fullfile(Pathsub,RootFile) '.xml']; 98 if ~strcmp(ext,'.xml') 99 inputfile=[fullfile(Pathsub,RootFile) '.xml']%xml file corresponding to the input file 100 end 99 101 end 100 102 set(handles.ListCoord,'String',{'......'}) 101 if exist(input xml,'file')102 loadfile(handles,input xml)% load the point coordiantes existing in the xml file103 if exist(inputfile,'file') 104 loadfile(handles,inputfile)% load the point coordiantes existing in the xml file 103 105 end 104 106 set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function … … 232 234 set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off' 233 235 set(hhuvmat.FixedLimits,'BackgroundColor',[0.7 0.7 0.7]) 236 UserData=get(handles.geometry_calib,'UserData'); 237 UserData.XmlInputFile=outputfile;%save the current xml file name 238 set(handles.geometry_calib,'UserData',UserData) 234 239 uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading in uvmat, show the image in phys coordinates 235 240 MenuPlot_Callback(hObject, eventdata, handles) … … 294 299 %record the points 295 300 GeometryCalib.SourceCalib.PointCoord=Coord; 296 errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file297 if ~strcmp(errormsg,'')298 msgbox_uvmat('ERROR',errormsg);299 end301 % errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file 302 % if ~strcmp(errormsg,'') 303 % msgbox_uvmat('ERROR',errormsg); 304 % end 300 305 end 301 306 display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters … … 412 417 % y1=XY_mat*a_Y1; 413 418 % err_Y1=max(abs(y1-y_ima));%error 419 R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,0]; 420 norm=abs(det(R)); 414 421 GeometryCalib.CalibrationType='linear'; 415 GeometryCalib.f ocal=1;422 GeometryCalib.fx_fy=[norm norm]; 416 423 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function 417 424 R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,0]; 418 norm=det(R); 419 GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) norm]; 425 GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) 1]; 420 426 GeometryCalib.R=R/norm; 421 427 GeometryCalib.omc=(180/pi)*[acos(R(1,1)) 0 0]; 422 428 %------------------------------------------------------------------------ 423 429 % determine the tsai parameters for a view normal to the grid plane … … 600 606 path_uvmat=which('geometry_calib');% check the path detected for source file uvmat 601 607 path_UVMAT=fileparts(path_uvmat); %path to UVMAT 602 x_1= Coord(:,4:5)';603 X_1= Coord(:,1:3)';608 x_1=double(Coord(:,4:5)');%image coordiantes 609 X_1=double(Coord(:,1:3)');% phys coordinates 604 610 huvmat=findobj(allchild(0),'Tag','uvmat'); 605 611 hhuvmat=guidata(huvmat); 606 ny=str2 num(get(hhuvmat.npy,'String'));612 ny=str2double(get(hhuvmat.npy,'String')); 607 613 x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates 608 614 n_ima=1; … … 615 621 fct_path=fullfile(path_UVMAT,'toolbox_calib'); 616 622 addpath(fct_path) 617 Cx_Cy=ny-(GeometryCalib.Cx_Cy)';%reverse Cx_Cy(2) for calibration (inversion of px ordinate)623 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%reverse Cx_Cy(2) for calibration (inversion of px ordinate) 618 624 % [omc1,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,... 619 625 % [Calib.f Calib.f*Calib.sx]',... … … 621 627 % [-Calib.kappa1*Calib.f^2 0 0 0 0]); 622 628 [omc,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,... 623 (GeometryCalib.fx_fy)',... 624 Cx_Cy,[GeometryCalib.kc 0 0 0 0]); 625 %get the euler angles ??? 629 (GeometryCalib.fx_fy)',GeometryCalib.Cx_Cy',[GeometryCalib.kc 0 0 0 0]); 626 630 rmpath(fct_path); 627 628 std(ex')629 631 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function 630 632 GeometryCalib.Tx_Ty_Tz=Tc1'; … … 633 635 GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate 634 636 GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate 635 %GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate637 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate 636 638 GeometryCalib.omc=(180/pi)*omc'; 637 639 %GeometryCalib.R(3,1:3)=-GeometryCalib.R(3,1:3);%inversion for z upward 640 638 641 639 642 … … 993 996 % -------------------------------------------------------------------- 994 997 function MenuHelp_Callback(hObject, eventdata, handles) 995 path_to_uvmat=which 998 path_to_uvmat=which('uvmat');% check the path of uvmat 996 999 pathelp=fileparts(path_to_uvmat); 997 1000 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html'); 998 1001 if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package') 999 1002 else … … 1409 1412 GeometryCalib=s.GeometryCalib; 1410 1413 %GeometryCalib=load_calib(hObject, eventdata, handles) 1411 calib=reshape(GeometryCalib.PointCoord ',[],1);1414 calib=reshape(GeometryCalib.PointCoord,[],1); 1412 1415 for ilist=1:numel(calib) 1413 1416 CoordCell{ilist}=num2str(calib(ilist)); … … 1474 1477 fileinput=[];%default 1475 1478 oldfile=''; %default 1476 UserData=get(handles.geometry_calib,'UserData') 1479 UserData=get(handles.geometry_calib,'UserData'); 1477 1480 if isfield(UserData,'XmlInputFile') 1478 1481 oldfile=UserData.XmlInputFile; … … 1497 1500 function loadfile(handles,fileinput) 1498 1501 %------------------------------------------------------------------------ 1499 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib'); 1500 GeometryCalib=s.GeometryCalib 1502 fileinput 1503 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib') 1504 GeometryCalib=s.GeometryCalib; 1501 1505 fx=1;fy=1;Cx=0;Cy=0;kc=0; %default 1502 1506 % Tabchar={}; … … 1534 1538 set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4)) 1535 1539 end 1536 calib=reshape(GeometryCalib.PointCoord ',[],1);1540 calib=reshape(GeometryCalib.PointCoord,[],1); 1537 1541 for ilist=1:numel(calib) 1538 1542 CoordCell{ilist}=num2str(calib(ilist));
Note: See TracChangeset
for help on using the changeset viewer.