Changeset 755 for trunk


Ignore:
Timestamp:
Apr 27, 2014, 11:58:49 PM (10 years ago)
Author:
sommeria
Message:
 
Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r745 r755  
    506506    coord_files={};
    507507end
     508%retrieve the calibration points stored in the files listed in the popup list ListCoordFiles
     509x_1=Coord(:,4:5)';%px coordinates of the ref points
     510if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on')
     511    msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration')
     512  return
     513end
     514nx=str2num(get(hhuvmat.num_Npx,'String'));
     515ny=str2num(get(hhuvmat.num_Npy,'String'));
     516x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates
     517X_1=Coord(:,1:3)';%phys coordinates of the ref points
     518n_ima=numel(coord_files)+1;
     519if ~isempty(coord_files)
     520    msgbox_uvmat('CONFIRMATION',['The xy coordinates of the calibration points in ' num2str(n_ima) ' planes will be used'])
     521    for ifile=1:numel(coord_files)
     522    t=xmltree(coord_files{ifile});
     523    s=convert(t);%convert to matlab structure
     524        if isfield(s,'GeometryCalib')
     525            if isfield(s.GeometryCalib,'SourceCalib')
     526                if isfield(s.GeometryCalib.SourceCalib,'PointCoord')
     527                PointCoord=s.GeometryCalib.SourceCalib.PointCoord;
     528                Coord_file=zeros(length(PointCoord),5);%default
     529                for i=1:length(PointCoord)
     530                    line=str2num(PointCoord{i});
     531                    Coord_file(i,4:5)=line(4:5);%px x
     532                    Coord_file(i,1:3)=line(1:3);%phys x
     533                end
     534                eval(['x_' num2str(ifile+1) '=Coord_file(:,4:5)'';']);
     535                eval(['x_' num2str(ifile+1) '(2,:)=ny-x_' num2str(ifile+1) '(2,:);' ]);
     536                eval(['X_' num2str(ifile+1) '=Coord_file(:,1:3)'';']);
     537                end
     538            end
     539        end
     540    end
     541end
     542n_ima=numel(coord_files)+1;
     543est_dist=[0;0;0;0;0];
     544est_aspect_ratio=0;
     545est_fc=[1;1];
     546center_optim=0;
     547run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
     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
     566
     567%------------------------------------------------------------------------
     568function GeometryCalib=calib_3D_quadr(Coord,handles)
     569%------------------------------------------------------------------
     570
     571path_uvmat=which('uvmat');% check the path detected for source file uvmat
     572path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     573huvmat=findobj(allchild(0),'Tag','uvmat');
     574hhuvmat=guidata(huvmat);
     575if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on')
     576    msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration')
     577  return
     578end
     579% check_cond=0;
     580coord_files=get(handles.ListCoordFiles,'String');
     581if ischar(coord_files)
     582    coord_files={coord_files};
     583end
     584if isempty(coord_files{1}) || isequal(coord_files,{''})
     585    coord_files={};
     586end
     587
    508588%retrieve the calibration points stored in the files listed in the popup list ListCoordFiles
    509589x_1=Coord(:,4:5)';%px coordinates of the ref points
     
    537617end
    538618n_ima=numel(coord_files)+1;
    539 est_dist=[0;0;0;0;0];
    540 est_aspect_ratio=0;
    541 est_fc=[1;1];
    542 center_optim=0;
    543 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'
    544 if exist('Rc_1','var')
    545     GeometryCalib.CalibrationType='3D_linear';
    546     GeometryCalib.fx_fy=fc';
    547     GeometryCalib.Cx_Cy=cc';
    548     GeometryCalib.kc=kc(1);
    549     GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    550     GeometryCalib.Tx_Ty_Tz=Tc_1';
    551     GeometryCalib.R=Rc_1;
    552     GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
    553     GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate
    554     GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
    555     GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees
    556     GeometryCalib.ErrorRMS=[];
    557     GeometryCalib.ErrorMax=[];
    558 else
    559     msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])
    560     GeometryCalib=[];
    561 end
    562 
    563 %------------------------------------------------------------------------
    564 function GeometryCalib=calib_3D_quadr(Coord,handles)
    565 %------------------------------------------------------------------
    566 
    567 path_uvmat=which('uvmat');% check the path detected for source file uvmat
    568 path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    569 huvmat=findobj(allchild(0),'Tag','uvmat');
    570 hhuvmat=guidata(huvmat);
    571 % check_cond=0;
    572 coord_files=get(handles.ListCoordFiles,'String');
    573 if ischar(coord_files)
    574     coord_files={coord_files};
    575 end
    576 if isempty(coord_files{1}) || isequal(coord_files,{''})
    577     coord_files={};
    578 end
    579 
    580 %retrieve the calibration points stored in the files listed in the popup list ListCoordFiles
    581 x_1=Coord(:,4:5)';%px coordinates of the ref points
    582 nx=str2num(get(hhuvmat.num_Npx,'String'));
    583 ny=str2num(get(hhuvmat.num_Npy,'String'));
    584 x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates
    585 X_1=Coord(:,1:3)';%phys coordinates of the ref points
    586 n_ima=numel(coord_files)+1;
    587 if ~isempty(coord_files)
    588     msgbox_uvmat('CONFIRMATION',['The xy coordinates of the calibration points in ' num2str(n_ima) ' planes will be used'])
    589     for ifile=1:numel(coord_files)
    590     t=xmltree(coord_files{ifile});
    591     s=convert(t);%convert to matlab structure
    592         if isfield(s,'GeometryCalib')
    593             if isfield(s.GeometryCalib,'SourceCalib')
    594                 if isfield(s.GeometryCalib.SourceCalib,'PointCoord')
    595                 PointCoord=s.GeometryCalib.SourceCalib.PointCoord;
    596                 Coord_file=zeros(length(PointCoord),5);%default
    597                 for i=1:length(PointCoord)
    598                     line=str2num(PointCoord{i});
    599                     Coord_file(i,4:5)=line(4:5);%px x
    600                     Coord_file(i,1:3)=line(1:3);%phys x
    601                 end
    602                 eval(['x_' num2str(ifile+1) '=Coord_file(:,4:5)'';']);
    603                 eval(['x_' num2str(ifile+1) '(2,:)=ny-x_' num2str(ifile+1) '(2,:);' ]);
    604                 eval(['X_' num2str(ifile+1) '=Coord_file(:,1:3)'';']);
    605                 end
    606             end
    607         end
    608     end
    609 end
    610 n_ima=numel(coord_files)+1;
    611619est_dist=[1;0;0;0;0];
    612620est_aspect_ratio=1;
     
    642650huvmat=findobj(allchild(0),'Tag','uvmat');
    643651hhuvmat=guidata(huvmat);
     652if ~strcmp(get(hhuvmat.Scalar,'Visible'),'on')
     653    msgbox_uvmat('ERROR','An image needs to be opened in uvmat for calibration')
     654  return
     655end
    644656ny=str2double(get(hhuvmat.num_Npy,'String'));
    645657x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates
  • trunk/src/nc2struct.m

    r748 r755  
    33% The corresponding dimensions and variable attributes are then extracted
    44%----------------------------------------------------------------------
    5 % function [Data,var_detect,ichoice]=nc2struct(nc,varargin)
     5% function [Data,var_detect,ichoice,errormsg]=nc2struct(nc,varargin)
    66%
    77% OUTPUT:
Note: See TracChangeset for help on using the changeset viewer.