Ignore:
Timestamp:
Feb 27, 2014, 8:57:02 PM (10 years ago)
Author:
sommeria
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r699 r724  
    283283%------------------------------------------------------------------------
    284284%% read the current calibration points
     285index=[];
    285286Coord=get(handles.ListCoord,'Data');
    286287Coord(:,6)=[];
    287288% apply the calibration, whose type is selected in  handles.calib_type
     289GeometryCalib=[];
    288290if ~isempty(Coord)
    289291    calib_cell=get(handles.calib_type,'String');
     
    292294else
    293295    msgbox_uvmat('ERROR','No calibration points, abort')
     296end
     297if isempty(GeometryCalib)
    294298    return
    295 end 
     299end
    296300Z_plane=[];
    297301if ~isempty(Coord)
     
    542546center_optim=0;
    543547run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
    544 GeometryCalib.CalibrationType='3D_linear';
    545 GeometryCalib.fx_fy=fc';
    546 GeometryCalib.Cx_Cy=cc';
    547 GeometryCalib.kc=kc(1);
    548 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    549 GeometryCalib.Tx_Ty_Tz=Tc_1';
    550 GeometryCalib.R=Rc_1;
    551 GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
    552 GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate
    553 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
    554 GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees
    555 GeometryCalib.ErrorRMS=[];
    556 GeometryCalib.ErrorMax=[];
     548if exist('Rc_1','var')
     549    GeometryCalib.CalibrationType='3D_linear';
     550    GeometryCalib.fx_fy=fc';
     551    GeometryCalib.Cx_Cy=cc';
     552    GeometryCalib.kc=kc(1);
     553    GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
     554    GeometryCalib.Tx_Ty_Tz=Tc_1';
     555    GeometryCalib.R=Rc_1;
     556    GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
     557    GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate
     558    GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
     559    GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees
     560    GeometryCalib.ErrorRMS=[];
     561    GeometryCalib.ErrorMax=[];
     562else
     563    msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])
     564    GeometryCalib=[];
     565end
    557566
    558567%------------------------------------------------------------------------
     
    609618run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
    610619
    611 GeometryCalib.CalibrationType='3D_quadr';
    612 GeometryCalib.fx_fy=fc';
    613 GeometryCalib.Cx_Cy=cc';
    614 GeometryCalib.kc=kc(1);
    615 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    616 GeometryCalib.Tx_Ty_Tz=Tc_1';
    617 if ~exist('Rc_1','var')
    618     msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])
    619     return
    620 end
    621 GeometryCalib.R=Rc_1;
    622 GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
    623 GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate
    624 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
    625 GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees
    626 GeometryCalib.ErrorRMS=[];
    627 GeometryCalib.ErrorMax=[];
    628 
     620if exist('Rc_1','var')
     621    GeometryCalib.CalibrationType='3D_quadr';
     622    GeometryCalib.fx_fy=fc';
     623    GeometryCalib.Cx_Cy=cc';
     624    GeometryCalib.kc=kc(1);
     625    GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
     626    GeometryCalib.Tx_Ty_Tz=Tc_1';
     627    GeometryCalib.R=Rc_1;
     628    GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
     629    GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate
     630    GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
     631    GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees
     632    GeometryCalib.ErrorRMS=[];
     633    GeometryCalib.ErrorMax=[];
     634else
     635    msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])
     636    GeometryCalib=[];
     637end
    629638
    630639%------------------------------------------------------------------------
     
    633642path_uvmat=which('geometry_calib');% check the path detected for source file uvmat
    634643path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    635 x_1=double(Coord(:,4:5)');%image coordiantes
     644x_1=double(Coord(:,4:5)');%image coordinates
    636645X_1=double(Coord(:,1:3)');% phys coordinates
    637646huvmat=findobj(allchild(0),'Tag','uvmat');
     
    641650n_ima=1;
    642651GeometryCalib.CalibrationType='3D_extrinsic';
     652fx=str2num(get(handles.fx,'String'));
     653fy=str2num(get(handles.fy,'String'));
     654Cx=str2num(get(handles.Cx,'String'));
     655Cy=str2num(get(handles.Cy,'String'));
     656errormsg='';
     657if isempty(fx)
     658    errormsg='focal length fx needs to be introduced';
     659elseif isempty(fy)
     660    errormsg='focal length fy needs to be introduced';
     661elseif isempty(Cx)
     662    errormsg='shift Cx to image centre needs to be introduced';
     663elseif isempty(Cy)
     664    errormsg='shift Cy to image centre needs to be introduced';
     665end
     666if ~isempty(errormsg)
     667    GeometryCalib=[];
     668    msgbox_uvmat('ERROR',errormsg)
     669    return
     670end
    643671GeometryCalib.fx_fy(1)=str2num(get(handles.fx,'String'));
    644672GeometryCalib.fx_fy(2)=str2num(get(handles.fy,'String'));
     
    660688GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
    661689GeometryCalib.omc=(180/pi)*omc';
    662 %GeometryCalib.R(3,1:3)=-GeometryCalib.R(3,1:3);%inversion for z upward
    663 
    664 
    665690
    666691%------------------------------------------------------------------------
     
    11611186        set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    11621187    end
    1163     if isfield(GeometryCalib,'SourceCalib')
     1188    if isfield(GeometryCalib,'SourceCalib')&& isfield(GeometryCalib.SourceCalib,'PointCoord')
    11641189        calib=GeometryCalib.SourceCalib.PointCoord;
    11651190        Coord=[calib zeros(size(calib,1),1)];
Note: See TracChangeset for help on using the changeset viewer.