Ignore:
Timestamp:
Dec 17, 2014, 12:32:52 PM (9 years ago)
Author:
sommeria
Message:

stereo_civ updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/stereo_civ.m

    r844 r845  
    3939
    4040function [Data,errormsg,result_conv]= stereo_civ(Param)
     41Data=[];
    4142errormsg='';
    4243
    4344%% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed
    4445if isstruct(Param) && isequal(Param.Action.RUN,0)% function activated from the GUI series but not RUN
     46    if size(Param.InputTable,1)<2
     47        msgbox_uvmat('WARNING','two input file series must be entered')
     48        return
     49    end
    4550    path_series=fileparts(which('series'));
    4651    addpath(fullfile(path_series,'series'))
     
    285290        end
    286291        [A,Rangx,Rangy]=phys_ima(A,XmlData,1);
    287        
    288 
     292        [Npy,Npx]=size(A{1});
    289293        PhysImageA=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.png','_1a',i1_series_Civ1(ifield),[],1);
    290294        PhysImageB=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.png','_1a',i1_series_Civ1(ifield),[],2);
     
    323327       
    324328        % set the list of variables
    325         Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C'};%  cell array containing the names of the fields to record
    326         Data.VarDimName={'nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1'};
     329        Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C','Xphys','Yphys','Zphys','Civ1_E'};%  cell array containing the names of the fields to record
     330        Data.VarDimName={'nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1'};
    327331        Data.VarAttribute{1}.Role='coord_x';
    328332        Data.VarAttribute{2}.Role='coord_y';
     
    334338        % calculate velocity data (y and v in indices, reverse to y component)
    335339        [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ1);
    336         if ~isempty(errormsg)
    337             disp_uvmat('ERROR',errormsg,checkrun)
    338             return
    339         end
    340340        Data.Civ1_X=reshape(xtable,[],1);
    341341        Data.Civ1_Y=reshape(par_civ1.ImageHeight-ytable+1,[],1);
    342342        % get z from u and v (displacements)
    343343        Data.Civ1_U=reshape(utable,[],1);
    344         Data.Civ1_V=reshape(-vtable,[],1);
    345        
     344        Data.Civ1_V=reshape(-vtable,[],1);     
    346345        Data.Civ1_C=reshape(ctable,[],1);
    347346        Data.Civ1_F=reshape(F,[],1);
     347        Data.Xphys=Rangx(1)+(Rangx(2)-Rangx(1))*(Data.Civ1_X-0.5)/(Npx-1);
     348        Data.Yphys=Rangy(1)+(Rangy(2)-Rangy(1))*(Data.Civ1_Y-0.5)/(Npy-1);
     349        U=Data.Civ1_U*(Rangx(2)-Rangx(1))/(Npx-1);
     350        V=Data.Civ1_V*(Rangy(2)-Rangy(1))/(Npy-1);
     351        [Data.Zphys,Data.Civ1_E]=shift2z(Data.Xphys,Data.Yphys,U,V,XmlData);
     352        if ~isempty(errormsg)
     353            disp_uvmat('ERROR',errormsg,checkrun)
     354            return
     355        end
    348356    end
    349357   
     
    10161024end
    10171025
    1018 
    1019 
    1020 
     1026%INPUT:
     1027% xmid- u/2: set of apparent phys x coordinates in the ref plane, image A
     1028% ymid- v/2: set of apparent phys y coordinates in the ref plane, image A
     1029% xmid+ u/2: set of apparent phys x coordinates in the ref plane, image B
     1030% ymid+ v/2: set of apparent phys y coordinates in the ref plane, image B
     1031% XmlData: content of the xml files containing geometric calibration parameters
     1032function [z,error]=shift2z(xmid, ymid, u, v,XmlData)
     1033z=0;
     1034error=0;
     1035
     1036%% first image
     1037Calib_A=XmlData{1}.GeometryCalib;
     1038R=(Calib_A.R)';
     1039x_a=xmid- u/2;
     1040y_a=ymid- v/2;
     1041z_a=R(7)*x_a+R(8)*y_a+R(9)*Calib_A.SliceCoord(1,3);
     1042X=(R(1)*x_a+R(2)*y_a+R(3)*Calib_A.SliceCoord(1,3))./z_a;
     1043Y=(R(4)*x_a+R(5)*y_a+R(6)*Calib_A.SliceCoord(1,3))./z_a;
     1044A_1_1=R(1)-R(7)*x_a;
     1045A_1_2=R(2)-R(8)*x_a;
     1046A_1_3=R(3)-R(9)*x_a;
     1047A_2_1=R(4)-R(7)*y_a;
     1048A_2_2=R(5)-R(8)*y_a;
     1049A_2_3=R(6)-R(9)*y_a;
     1050Det=A_1_1.*A_2_2-A_1_2.*A_2_1;
     1051Dxa=(A_1_2.*A_2_3-A_2_2.*A_1_3)./Det;
     1052Dya=(A_2_1.*A_1_3-A_1_1.*A_2_3)./Det;
     1053
     1054%% second image
     1055Calib_A=XmlData{1}.GeometryCalib;
     1056R=(Calib_A.R)';
     1057x_a=xmid+ u/2;
     1058y_a=ymid+ v/2;
     1059z_a=R(7)*x_a+R(8)*y_a+R(9)*Calib_A.SliceCoord(1,3);
     1060X=(R(1)*x_a+R(2)*y_a+R(3)*Calib_A.SliceCoord(1,3))./z_a;
     1061Y=(R(4)*x_a+R(5)*y_a+R(6)*Calib_A.SliceCoord(1,3))./z_a;
     1062A_1_1=R(1)-R(7)*x_a;
     1063A_1_2=R(2)-R(8)*x_a;
     1064A_1_3=R(3)-R(9)*x_a;
     1065A_2_1=R(4)-R(7)*y_a;
     1066A_2_2=R(5)-R(8)*y_a;
     1067A_2_3=R(6)-R(9)*y_a;
     1068Det=A_1_1.*A_2_2-A_1_2.*A_2_1;
     1069Dxb=(A_1_2.*A_2_3-A_2_2.*A_1_3)./Det;
     1070Dyb=(A_2_1.*A_1_3-A_1_1.*A_2_3)./Det;
     1071
     1072%% result
     1073Den=(Dxb-Dxa).*(Dxb-Dxa)+(Dyb-Dya).*(Dyb-Dya);
     1074error=((Dyb-Dya).*u-(Dxb-Dxa).*v)./Den;
     1075z=((Dxb-Dxa).*u-(Dyb-Dya).*v)./Den;
Note: See TracChangeset for help on using the changeset viewer.