Changeset 116


Ignore:
Timestamp:
Oct 16, 2010, 5:56:00 PM (11 years ago)
Author:
sommeria
Message:

geometry_calib is now updated when a new image is viewed by uvmat
imadoc2struct corrected for time reading

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r113 r116  
    770770set(handles.RUN, 'Enable','On')
    771771set(handles.RUN,'BackgroundColor',[1 0 0])
    772 if isequal(get(handles.BATCH, 'Enable'),'On')
     772  set(handles.BATCH,'Enable','On')
    773773    set(handles.BATCH,'BackgroundColor',[1 0 0])
    774 end
    775774
    776775%%%%% store the root input filename for future opening
     
    21072106    s=convert(t);
    21082107end
    2109 if batch
     2108    test_interp=0;
     2109    if batch
    21102110    if isfield(s,'BatchParam')
    21112111        sparam=s.BatchParam;
     
    21402140    end
    21412141    %test_interp=get(handles.test_interp,'Value');
    2142     test_interp=0;
     2142
    21432143    if  isfield(sparam,'PatchBin')
    21442144        if ~exist(sparam.PatchBin,'file')
  • trunk/src/geometry_calib.m

    r114 r116  
    7171% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
    7272%------------------------------------------------------------------------
    73 function geometry_calib_OpeningFcn(hObject, eventdata, handles, handles_uvmat,pos,inputfile)
     73function geometry_calib_OpeningFcn(hObject, eventdata, handles,inputfile,pos)
    7474%------------------------------------------------------------------------
    7575% Choose default command line output for geometry_calib
     
    8181
    8282%set the position of the interface
    83 if exist('pos','var')& length(pos)>2
     83if exist('pos','var')&& length(pos)>2
    8484    pos_gui=get(hObject,'Position');
    8585    pos_gui(1)=pos(1);
     
    9292set(handles.calib_type,'String',{'rescale';'linear';'quadr';'3D_linear';'3D_quadr';'3D_extrinsic'})
    9393inputxml='';
    94 if exist('inputfile','var')& ~isempty(inputfile)
     94if exist('inputfile','var')&& ~isempty(inputfile)
    9595    struct.XmlInputFile=inputfile;
    9696    set(hObject,'UserData',struct)
    9797    [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
    99101end
    100102set(handles.ListCoord,'String',{'......'})
    101 if exist(inputxml,'file')
    102     loadfile(handles,inputxml)% load the point coordiantes existing in the xml file
     103if exist(inputfile,'file')
     104    loadfile(handles,inputfile)% load the point coordiantes existing in the xml file
    103105end
    104106set(handles.ListCoord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function
     
    232234    set(hhuvmat.FixedLimits,'Value',0)% put FixedLimits option to 'off'
    233235    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)
    234239    uvmat('RootPath_Callback',hObject,eventdata,hhuvmat); %file input with xml reading  in uvmat, show the image in phys coordinates
    235240    MenuPlot_Callback(hObject, eventdata, handles)
     
    294299    %record the points
    295300    GeometryCalib.SourceCalib.PointCoord=Coord;
    296     errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
    297     if ~strcmp(errormsg,'')
    298         msgbox_uvmat('ERROR',errormsg);
    299     end
     301%     errormsg=update_imadoc(GeometryCalib,outputfile);% introduce the calibration data in the xml file
     302%     if ~strcmp(errormsg,'')
     303%         msgbox_uvmat('ERROR',errormsg);
     304%     end
    300305end
    301306display_intrinsic(GeometryCalib,handles)%display calibration intrinsic parameters
     
    412417% y1=XY_mat*a_Y1;
    413418% err_Y1=max(abs(y1-y_ima));%error
     419R=[a_X1(2),a_X1(3),0;a_Y1(2),a_Y1(3),0;0,0,0];
     420norm=abs(det(R));
    414421GeometryCalib.CalibrationType='linear';
    415 GeometryCalib.focal=1;
     422GeometryCalib.fx_fy=[norm norm];
    416423GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    417424R=[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];
     425GeometryCalib.Tx_Ty_Tz=[a_X1(1) a_Y1(1) 1];
    420426GeometryCalib.R=R/norm;
    421 
     427GeometryCalib.omc=(180/pi)*[acos(R(1,1)) 0 0];
    422428%------------------------------------------------------------------------
    423429% determine the tsai parameters for a view normal to the grid plane
     
    600606path_uvmat=which('geometry_calib');% check the path detected for source file uvmat
    601607path_UVMAT=fileparts(path_uvmat); %path to UVMAT
    602 x_1=Coord(:,4:5)';
    603 X_1=Coord(:,1:3)';
     608x_1=double(Coord(:,4:5)');%image coordiantes
     609X_1=double(Coord(:,1:3)');% phys coordinates
    604610huvmat=findobj(allchild(0),'Tag','uvmat');
    605611hhuvmat=guidata(huvmat);
    606 ny=str2num(get(hhuvmat.npy,'String'));
     612ny=str2double(get(hhuvmat.npy,'String'));
    607613x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates
    608614n_ima=1;
     
    615621fct_path=fullfile(path_UVMAT,'toolbox_calib');
    616622addpath(fct_path)
    617 Cx_Cy=ny-(GeometryCalib.Cx_Cy)';%reverse Cx_Cy(2) for calibration (inversion of px ordinate)
     623GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%reverse Cx_Cy(2) for calibration (inversion of px ordinate)
    618624% [omc1,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,...
    619625%     [Calib.f Calib.f*Calib.sx]',...
     
    621627%     [-Calib.kappa1*Calib.f^2 0 0 0 0]);
    622628[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]);
    626630rmpath(fct_path);
    627 
    628 std(ex')
    629631GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function
    630632GeometryCalib.Tx_Ty_Tz=Tc1';
     
    633635GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate
    634636GeometryCalib.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 coordinate
     637GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate
    636638GeometryCalib.omc=(180/pi)*omc';
    637639%GeometryCalib.R(3,1:3)=-GeometryCalib.R(3,1:3);%inversion for z upward
     640
    638641
    639642
     
    993996% --------------------------------------------------------------------
    994997function MenuHelp_Callback(hObject, eventdata, handles)
    995 path_to_uvmat=which ('uvmat');% check the path of uvmat
     998path_to_uvmat=which('uvmat');% check the path of uvmat
    996999pathelp=fileparts(path_to_uvmat);
    997     helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
     1000helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
    9981001if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    9991002else
     
    14091412GeometryCalib=s.GeometryCalib;
    14101413%GeometryCalib=load_calib(hObject, eventdata, handles)
    1411 calib=reshape(GeometryCalib.PointCoord',[],1);
     1414calib=reshape(GeometryCalib.PointCoord,[],1);
    14121415for ilist=1:numel(calib)
    14131416    CoordCell{ilist}=num2str(calib(ilist));
     
    14741477fileinput=[];%default
    14751478oldfile=''; %default
    1476 UserData=get(handles.geometry_calib,'UserData')
     1479UserData=get(handles.geometry_calib,'UserData');
    14771480if isfield(UserData,'XmlInputFile')
    14781481    oldfile=UserData.XmlInputFile;
     
    14971500function loadfile(handles,fileinput)
    14981501%------------------------------------------------------------------------
    1499 [s,errormsg]=imadoc2struct(fileinput,'GeometryCalib');
    1500 GeometryCalib=s.GeometryCalib
     1502fileinput
     1503[s,errormsg]=imadoc2struct(fileinput,'GeometryCalib')
     1504GeometryCalib=s.GeometryCalib;
    15011505fx=1;fy=1;Cx=0;Cy=0;kc=0; %default
    15021506%     Tabchar={};
     
    15341538        set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    15351539    end
    1536     calib=reshape(GeometryCalib.PointCoord',[],1);
     1540    calib=reshape(GeometryCalib.PointCoord,[],1);
    15371541    for ilist=1:numel(calib)
    15381542        CoordCell{ilist}=num2str(calib(ilist));
  • trunk/src/griddata_uvmat.m

    r115 r116  
    22%adapt the input of the matlab function griddata to the appropriate version of Matlab
    33function ZI = griddata_uvmat(X,Y,Z,XI,YI)
    4 whos X Y Z XI YI
    54txt=ver;
    65Release=txt(1).Release;
    7 relnumb=str2num(Release(3:4))
     6relnumb=str2num(Release(3:4));
    87if relnumb >= 20
    98    ZI=griddata(double(X),double(Y),double(Z),double(XI),double(YI),'linear',{'QJ'});
  • trunk/src/imadoc2struct.m

    r114 r116  
    217217        if strcmp(option,'GeometryCalib')
    218218            tsai.PointCoord=get_value(subt,'/GeometryCalib/SourceCalib/PointCoord',[0 0 0 0 0]);%time in TimeUnit
     219            size(tsai.PointCoord)
    219220        end
    220221        s.GeometryCalib=tsai;
     
    228229val=default;
    229230uid=find(t,label);%find the element iud(s)
    230 if ~isempty(uid)
    231    uid_child=children(t,uid);
     231if ~isempty(uid) %if the element named label exists
     232   uid_child=children(t,uid);%find the children
    232233   if ~isempty(uid_child)
    233        data=get(t,uid_child,'type');
    234        if iscell(data)
     234       data=get(t,uid_child,'type');%get the type of child
     235       if iscell(data)% case of multiple element
    235236           for icell=1:numel(data)
    236237               val_read=str2num(get(t,uid_child(icell),'value'));
     
    239240               end
    240241           end
    241            val=val';
    242        else
     242%           val=val';
     243       else % case of unique element value
    243244           val_read=str2num(get(t,uid_child,'value'));
    244245           if ~isempty(val_read)
  • trunk/src/series/merge_proj.m

    r109 r116  
    2323WaitbarPos=get(hseries.waitbar_frame,'Position'); %positiopn of waitbar frame
    2424%-------------------------------------------------
     25
     26
    2527
    2628%projection object
     
    229231if ~exist(res_subdir,'dir')
    230232    dircur=pwd;
    231     cd(fulldir)
    232     error=mkdir(subdir);
    233     cd(dircur)
     233    cd(fulldir);
     234    succeed=mkdir(subdir);
     235    if succeed
     236    cd(dircur);
     237    else
     238    msgbox_uvmat('ERROR',['Cannot create directory ' fulldir])
     239    return
     240    end       
    234241end
    235242filebasesub=fullfile(res_subdir,Series.RootFile{1});
     
    286293            % coord transform
    287294            % z index
     295     
    288296            if ~isempty(NbSlice_calib)
    289                 Field{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;
    290             end
     297                Field{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1
     298            end
     299%              Field{iview}.ZIndex=1;
    291300            if ~isempty(transform_fct)
    292                 Field{iview}=transform_fct(Field{iview},XmlData{iview});%transform to phys if requested
     301                XmlData{iview}.GeometryCalib
     302                Field{iview}=transform_fct(Field{iview},XmlData{iview});               
     303                %transform to phys if requested
    293304            end
    294305            if testcivx
     
    301312            end
    302313        end   
    303        
    304314         %----------END LOOP ON VIEWS----------------------
    305315         
     
    376386            %MergeData.dt=1;
    377387            MergeData.Time=time_i;
    378             error=struct2nc(mergename,MergeData); %save result file
     388            error=struct2nc(mergename,MergeData);%save result file
    379389            if isempty(error)
    380390                display(['output file ' mergename ' written'])
  • trunk/src/transform_field/phys.m

    r79 r116  
    5858end
    5959%transform of X,Y coordinates for vector fields
    60 if isfield(Data,'ZIndex')&&~isempty(Data.ZIndex)
     60if isfield(Data,'ZIndex')&&~isempty(Data.ZIndex)&&~isnan(Data.ZIndex)
    6161    ZIndex=Data.ZIndex;
    6262else
    63     ZIndex=0;
     63    ZIndex=1;
    6464end
    6565if test_1
     
    111111    DataOut.TimeUnit='s';
    112112    %transform of X,Y coordinates for vector fields
    113     if isfield(Data,'ZIndex') && ~isempty(Data.ZIndex)
    114         Z=Data.ZIndex;
     113    if isfield(Data,'ZIndex') && ~isempty(Data.ZIndex)&&~isnan(Data.ZIndex)
     114        Z=Data.ZIndex
    115115    else
    116116        Z=0;
     
    153153end
    154154
    155 
    156155%%%%%%%%%%%%%%%%%%%%
    157156function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex)
     157
     158if ndims(A)==3
     159    A=mean(A,3);
     160end
     161
     162
    158163xcorner=[];
    159164ycorner=[];
    160165npx=[];
    161166npy=[];
     167dx=ones(1,length(A));
     168dy=ones(1,length(A));
    162169for icell=1:length(A)
    163170    siz=size(A{icell});
     
    165172    npy=[npy siz(1)];
    166173    Calib=CalibIn{icell};
    167     xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordiantes of corners
     174    xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners
    168175    yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];
    169176    [xcorner_new,ycorner_new]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates
     
    177184Rangy(2)=min(ycorner);
    178185Rangy(1)=max(ycorner);
    179 test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));
     186test_multi=(max(npx)~=min(npx)) || (max(npy)~=min(npy)); %different image lengths
    180187npX=1+round((Rangx(2)-Rangx(1))/min(dx));% nbre of pixels in the new image (use the finest resolution min(dx) in the set of images)
    181188npY=1+round((Rangy(1)-Rangy(2))/min(dy));
     
    187194for icell=1:length(A)
    188195    Calib=CalibIn{icell};
    189     if (isfield(Calib,'R') && ~isequal(Calib.R(2,1),0) && ~isequal(Calib.R(1,2),0)) ||...
    190         ((isfield(Calib,'kappa1')&& ~isequal(Calib.kappa1,0))) || test_multi || ~isequal(Calib,CalibIn{1})
     196    if isfield(Calib,'R') || isfield(Calib,'kc')|| test_multi ||~isequal(Calib,CalibIn{1})% the image needs to be interpolated to the new coordinates
    191197        zphys=0; %default
    192198        if isfield(Calib,'SliceCoord') %.Z= index of plane
     
    227233            A_out{icell}=uint16(A_out{icell});
    228234        end
    229     else%
    230        
     235    else%     
    231236        A_out{icell}=A{icell};%no transform
    232237        Rangx=[0.5 npx-0.5];%image coordiantes of corners
    233238        Rangy=[npy-0.5 0.5];
    234         [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],[ZIndex ZIndex]);%case of translations without rotation and quadratic deformation
    235         [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,[ZIndex ZIndex]);
    236     end
    237 end
    238 
     239        [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation
     240        [xx,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex);
     241    end
     242end
     243
     244%------------------------------------------------------------------------
    239245%'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters
    240246% function [Xphys,Yphys]=phys_XYZ(Calib,X,Y,Z)
     
    245251%Z: index of plane
    246252function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)
    247 if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z
     253%------------------------------------------------------------------------
     254if exist('Z','var')&& isequal(Z,round(Z))&& Z>0 && isfield(Calib,'SliceCoord')&&length(Calib.SliceCoord)>=Z
    248255    Zindex=Z;
    249256    Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE
    250257else
    251 %     if exist('Z','var')
    252 %         Zphys=Z;
    253 %     else
    254         Zphys=0;
    255 %     end
     258    Zphys=0;
    256259end
    257260if ~exist('X','var')||~exist('Y','var')
     
    260263    return
    261264end
    262 Xphys=X;%default
    263 Yphys=Y;
    264 %image transform
     265%coordinate transform
     266if ~isfield(Calib,'fx_fy')
     267     Calib.fx_fy=[1 1];
     268end
     269if ~isfield(Calib,'Tx_Ty_Tz')
     270     Calib.Tx_Ty_Tz=[0 0 1];
     271end
     272if ~isfield(Calib,'Cx_Cy')
     273     Calib.Cx_Cy=[0 0];
     274end
     275if ~isfield(Calib,'kc')
     276     Calib.kc=0;
     277end
    265278if isfield(Calib,'R')
    266279    R=(Calib.R)';
     280    Tx=Calib.Tx_Ty_Tz(1);
     281    Ty=Calib.Tx_Ty_Tz(2);
     282    Tz=Calib.Tx_Ty_Tz(3);
     283    f=Calib.fx_fy(1);%dpy=1; sx=1
     284    dpx=Calib.fx_fy(2)/Calib.fx_fy(1);
    267285    Dx=R(5)*R(7)-R(4)*R(8);
    268286    Dy=R(1)*R(8)-R(2)*R(7);
    269     D0=Calib.f*(R(2)*R(4)-R(1)*R(5));
     287    D0=f*(R(2)*R(4)-R(1)*R(5));
    270288    Z11=R(6)*R(8)-R(5)*R(9);
    271289    Z12=R(2)*R(9)-R(3)*R(8); 
     
    274292    Zx0=R(3)*R(5)-R(2)*R(6);
    275293    Zy0=R(1)*R(6)-R(3)*R(4);
    276     A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;
    277     A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;
    278     A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;
    279     A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;
    280     X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);
    281     Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);
     294    A11=R(8)*Ty-R(5)*Tz+Z11*Zphys;
     295    A12=R(2)*Tz-R(8)*Tx+Z12*Zphys;
     296    A21=-R(7)*Ty+R(4)*Tz+Z21*Zphys;
     297    A22=-R(1)*Tz+R(7)*Tx+Z22*Zphys;
     298    X0=f*(R(5)*Tx-R(2)*Ty+Zx0*Zphys);
     299    Y0=f*(-R(4)*Tx+R(1)*Ty+Zy0*Zphys);
    282300        %px to camera:
    283     Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates
    284     Yd=Calib.dpy*(Y-Calib.Cy);
    285     dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor
    286     Xu=dist_fact.*Xd;%undistorted sensor coordinates
    287     Yu=dist_fact.*Yd;
     301    Xd=dpx*(X-Calib.Cx_Cy(1)); % sensor coordinates
     302    Yd=(Y-Calib.Cx_Cy(2));
     303    dist_fact=1+Calib.kc*(Xd.*Xd+Yd.*Yd)/(f*f); %distortion factor
     304    Xu=Xd./dist_fact;%undistorted sensor coordinates
     305    Yu=Yd./dist_fact;
    288306    denom=Dx*Xu+Dy*Yu+D0;
    289307    % denom2=denom.*denom;
    290308    Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates
    291309    Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;
     310%     Xd=(X-Calib.Cx_Cy(1))/Calib.fx_fy(1); % sensor coordinates
     311%     Yd=(Y-Calib.Cx_Cy(2))/Calib.fx_fy(2);
     312%     dist_fact=1+Calib.kc*(Xd.*Xd+Yd.*Yd); %distortion factor
     313%     Xu=Xd./dist_fact;%undistorted sensor coordinates
     314%     Yu=Yd./dist_fact;
     315%     A11=R(7)*Xu-R(1);
     316%     A12=R(8)*Xu-R(2);
     317%     A21=R(7)*Yu-R(4);
     318%     A22=R(8)*Yu-R(5);
     319%     B1=(R(3)-R(9)*Xu)*Zphys-Tz*Xu+Tx;
     320%     B2=(R(6)-R(9)*Yu)*Zphys-Tz*Yu+Ty;
     321%     deter=A12.*A21-A11.*A22;
     322%     Xphys=(A21.*B1-A11.*B2)./deter;
     323%     Yphys=(-A22.*B1+A12.*B2)./deter;
     324else
     325    Xphys=-Calib.Tx_Ty_Tz(1)+X/Calib.fx_fy(1);
     326    Yphys=-Calib.Tx_Ty_Tz(2)+Y/Calib.fx_fy(2);
    292327end
    293328
  • trunk/src/transform_field/px.m

    r40 r116  
    1818%      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
    1919%      Other fields in DataIn: copied to DataOut without modification
    20 % Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters
     20% Calib: structure containing the  substructure Calib.GeometryCalib with the calibration parameters
    2121%
    2222% call the function  px_XYZ (case of images) for pointwise coordinate transforms
     
    3636    DataOut=px_1(Data,CalibData.GeometryCalib);
    3737end
    38 if exist('Data_1','var')
     38if isfield(DataOut,'Z')
     39    DataOut=rmfield(DataOut,'Z');
     40end
     41if exist('Data_1','var')% if there is a second input field, it is also transformed
    3942    if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
    4043        DataOut_1=Data_1;
     
    4245        DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
    4346    end
    44 else
     47    if isfield(DataOut_1,'Z')
     48        DataOut_1=rmfield(DataOut_1,'Z');
     49    end
     50else % no second input field then empty second output field
    4551    DataOut_1=[];
    4652end
     
    5258
    5359%Act only if .CoordType=phys, and Calib defined
    54 if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)
     60if isfield(Data,'CoordType')&& isequal(Data.CoordType,'phys')&& ~isempty(Calib)
    5561    DataOut.CoordType='px'; %put flag for pixel coordinates
    5662    DataOut.CoordUnit='px';
    5763    %transform of X,Y coordinates
    58     if isfield(Data,'Z')&~isempty(Data.Z)
     64    if isfield(Data,'Z')&&~isempty(Data.Z)
    5965        Z=Data.Z;
    6066    else
     
    97103% [Zphys]: corresponding array of z physical coordinates (0 by default)
    98104
    99 
    100 function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
    101 X=[];%default
    102 Y=[];
    103 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
    104 %     Zindex=Z;
    105 %     planepos=Calib.PlanePos{Zindex};
    106 %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
    107 % else
    108 %     zphys=0;
     105%
     106% function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
     107% X=[];%default
     108% Y=[];
     109% % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
     110% %     Zindex=Z;
     111% %     planepos=Calib.PlanePos{Zindex};
     112% %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
     113% % else
     114% %     zphys=0;
     115% % end
     116% if ~exist('Zphys','var')
     117%     Zphys=0;
    109118% end
    110 if ~exist('Zphys','var')
    111     Zphys=0;
    112 end
    113 
    114 %%%%%%%%%%%%%
    115 if isfield(Calib,'R')
    116     R=(Calib.R)';
    117     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
    118     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
    119     zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
    120 %undistorted image coordinates
    121     Xu=Calib.f*xc./zc;
    122     Yu=Calib.f*yc./zc;
    123 %distorted image coordinates
    124     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
    125 % distortion=1;
    126     Xd=Xu./distortion;
    127     Yd=Yu./distortion;
    128 %pixel coordinates
    129     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
    130     Y=Yd/Calib.dpy+Calib.Cy;
    131 
    132 elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 
    133         X=Xphys*Calib.Pxcmx;
    134         Y=Yphys*Calib.Pxcmy;
    135 end
     119%
     120% %%%%%%%%%%%%%
     121% if isfield(Calib,'R')
     122%     R=(Calib.R)';
     123%     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
     124%     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
     125%     zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
     126% %undistorted image coordinates
     127%     Xu=Calib.f*xc./zc;
     128%     Yu=Calib.f*yc./zc;
     129% %distorted image coordinates
     130%     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
     131% % distortion=1;
     132%     Xd=Xu./distortion;
     133%     Yd=Yu./distortion;
     134% %pixel coordinates
     135%     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
     136%     Y=Yd/Calib.dpy+Calib.Cy;
     137%
     138% elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 
     139%         X=Xphys*Calib.Pxcmx;
     140%         Y=Yphys*Calib.Pxcmy;
     141% end
    136142
    137143
  • trunk/src/uvmat.m

    r114 r116  
    744744    set(handles.view_xml,'BackgroundColor',[1 1 1])
    745745    drawnow
     746    if isfield(XmlData, 'GeometryCalib') && ~isempty(XmlData.GeometryCalib)
     747        hgeometry_calib=findobj('tag','geometry_calib');
     748        if ~isempty(hgeometry_calib)
     749            GUserData=get(hgeometry_calib,'UserData');
     750            if ~(isfield(GUserData,'XmlInputFile') && strcmp(GUserData.XmlInputFile,filexml))
     751                answer=msgbox_uvmat('INPUT_Y-N','replace the display of geometry_calib with the new input data?');
     752                if strcmp(answer,'Yes')
     753                    geometry_calib(filexml);%diplay the new calibration points and parameters in geometry_calib
     754                end
     755            end
     756        end
     757    end 
    746758elseif exist(fileciv,'file')% if .civ file found
    747759    [error,XmlData.Time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([FileBase '.civ']);
     
    45654577pos(2)=pos(2)-0.02;
    45664578[FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);
    4567 [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface     
     4579[UvData.hset_object,UvData.sethandles]=geometry_calib(FileName,pos);% call the geometry_calib interface
    45684580pos_uvmat=get(handles.uvmat,'Position');
    45694581
  • trunk/src/view_field.m

    r102 r116  
    605605%-------------------------------------------------------
    606606function decimate4_Callback(hObject, eventdata, handles)
     607'TEST'
    607608update_plot(handles)
    608609
Note: See TracChangeset for help on using the changeset viewer.