Changeset 845


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

stereo_civ updated

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r844 r845  
    13081308function RUN_Callback(hObject, eventdata, handles)
    13091309
    1310 %% read the data on the GUI series
    1311 Param=read_GUI_series(handles);%displayed parameters
    1312 SeriesData=get(handles.series,'UserData');%hidden parameters
    1313 if ~isfield(SeriesData,'i1_series')
    1314     msgbox_uvmat('ERROR','The input field series needs to be refreshed: press REFRESH')
    1315     return
    1316 end
    1317 if isfield(Param,'InputFields')&& isequal(Param.InputFields.FieldName,'get_field...')
    1318     msgbox_uvmat('ERROR','input field name(s) not defined, select get_field...')
    1319     return
    1320 end
    1321 
    13221310%% settings of the button RUN
    13231311set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel'
     
    13261314drawnow
    13271315set(handles.status,'Value',0)% desable status display if relevant
    1328 status_Callback(hObject, eventdata, handles)
     1316status_Callback([], eventdata, handles)
     1317
     1318%% launch action
     1319errormsg=launch_action(handles);
     1320if ~isempty(errormsg)
     1321     msgbox_uvmat('ERROR',errormsg)
     1322end
     1323
     1324%% reset the GUI series
     1325update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
     1326set(handles.RUN, 'Enable','On')
     1327set(handles.RUN,'BackgroundColor',[1 0 0])
     1328set(handles.RUN, 'Value',0)
     1329
     1330%------------------------------------------------------------------------
     1331% --- called by RUN_Callback
     1332%------------------------------------------------------------------------
     1333function errormsg=launch_action(handles)
     1334errormsg='';%default
     1335
     1336%% read the data on the GUI series
     1337Param=read_GUI_series(handles);%displayed parameters
     1338SeriesData=get(handles.series,'UserData');%hidden parameters
     1339if ~isfield(SeriesData,'i1_series')
     1340    errormsg='The input field series needs to be refreshed: press REFRESH';
     1341    return
     1342end
     1343if isfield(Param,'InputFields')&& isequal(Param.InputFields.FieldName,'get_field...')
     1344    errormsg='input field name(s) not defined, select get_field...';
     1345    return
     1346end
    13291347
    13301348%% select the Action mode, 'local', 'background' or 'cluster' (if available)
     
    13411359ActionName=Param.Action.ActionName;
    13421360ActionPath=Param.Action.ActionPath;
    1343 
    13441361path_series=fileparts(which('series'));
    13451362
     
    13491366        eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION
    13501367        if ~exist(ActionPath,'dir')
    1351             msgbox_uvmat('ERROR',['The prescribed function path ' ActionPath ' does not exist']);
     1368            errormsg=['The prescribed function path ' ActionPath ' does not exist'];
    13521369            return
    13531370        end
     
    13901407    end
    13911408    if isempty(RunTime) && strcmp(RunMode,'cluster_oar')
    1392         msgbox_uvmat('ERROR','RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster')
     1409       errormsg='RunTime name not found in PARAM.xml, compiled version .sh cannot run on cluster';
    13931410        return
    13941411    end
     
    14631480
    14641481%% create the output data directory if needed
    1465 OutpuDir='';
     1482OutputDir='';
    14661483if isfield(Param,'OutputSubDir')
    14671484    SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt];
     
    14721489        answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']);
    14731490        if strcmp(answer,'Cancel')
    1474             errormsg='Cancel';
     1491            set(handles.RUN,'backgroundcolor',[1 0 0])
    14751492            return
    14761493        elseif strcmp(answer,'Yes')
     
    14951512        [tild,msg1]=mkdir(OutputDir);
    14961513        if ~strcmp(msg1,'')
    1497             msgbox_uvmat('ERROR',['cannot create ' OutputDir ': ' msg1]);%error message for directory creation
     1514            errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation
    14981515            return
    14991516        end
     
    15011518        if success==0
    15021519            msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation
    1503             return
    15041520        end
    15051521    end
     
    15121528    [tild,msg1]=mkdir(DirXml);
    15131529    if ~strcmp(msg1,'')
    1514         msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation
     1530        errormsg=['cannot create ' DirXml ': ' msg1];%error message for directory creation
    15151531        return
    15161532    end
     
    15401556end
    15411557if last_i < first_i || last_j < first_j
    1542     msgbox_uvmat('ERROR', 'series/Run_Callback:last field index must be larger or equal to the first one')
    1543     set(handles.RUN, 'Enable','On'),
    1544     set(handles.RUN,'BackgroundColor',[1 0 0])
     1558    errormsg= 'series/Run_Callback:last field index must be larger or equal to the first one';
    15451559    return
    15461560end
     
    16261640        end
    16271641    end
    1628 % elseif strcmp(get(handles.OutputDirExt,'Visible'),'off')
    1629 %     msgbox_uvmat('ERROR',['no output file for Action ' ActionName ', use run mode = local']);% a output dir is needed for background option
    1630 %     return
    16311642else
    16321643    %% processing on a different session of the same computer (background) or cluster, create executable files
     
    16431654        [tild,msg1]=mkdir(DirBat);
    16441655        if ~strcmp(msg1,'')
    1645             msgbox_uvmat('ERROR',['cannot create ' DirBat ': ' msg1]);%error message for directory creation
     1656            errormsg=['cannot create ' DirBat ': ' msg1];%error message for directory creation
    16461657            return
    16471658        end
     
    16521663        [tild,msg1]=mkdir(DirLog);
    16531664        if ~strcmp(msg1,'')
    1654             msgbox_uvmat('ERROR',['cannot create ' DirLog ': ' msg1]);%error message for directory creation
     1665            errormsg=['cannot create ' DirLog ': ' msg1];%error message for directory creation
    16551666            return
    16561667        end
     
    16841695        [fid,message]=fopen(filebat,'w');% create the executable file
    16851696        if isequal(fid,-1)
    1686             msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
     1697            errormsg=['creation of .bat file: ' message];
    16871698            return
    16881699        end
     
    17421753        for iprocess=1:NbProcess
    17431754            system([batch_file_list{iprocess} ' &'])% directly execute the command file for each process
    1744             msgbox_uvmat('CONFIRMATION',[ActionName 'launched in background: press STATUS to see results'])
     1755            msgbox_uvmat('CONFIRMATION',[ActionName ' launched in background: press STATUS to see results'])
    17451756        end
    17461757    case 'cluster_oar' % option 'oar-parexec' used
     
    17551766            [tild,msg1]=mkdir(DirOAR);
    17561767            if ~strcmp(msg1,'')
    1757                 msgbox_uvmat('ERROR',['cannot create ' DirOAR ': ' msg1]);%error message for directory creation
     1768                errormsg=['cannot create ' DirOAR ': ' msg1];%error message for directory creation
    17581769                return
    17591770            end
     
    17851796        msgbox_uvmat('CONFIRMATION',[ActionName ' launched in cluster: press STATUS to see results'])
    17861797end
    1787 
    1788 %% reset the GUI series
    1789 update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished
    1790 set(handles.RUN, 'Enable','On')
    1791 set(handles.RUN,'BackgroundColor',[1 0 0])
    1792 set(handles.RUN, 'Value',0)
    17931798
    17941799%------------------------------------------------------------------------
     
    21922197    end
    21932198    set(handles.OutputDirExt,'String',OutputDirExt)
    2194     OutputDirVisible='off';
    2195     OutputSubDirMode='auto';%default
    2196     SubDirOut='';
    2197     if isfield(ParamOut,'OutputSubDirMode')
    2198         OutputSubDirMode=ParamOut.OutputSubDirMode;
    2199     end
    2200     switch OutputSubDirMode
    2201         case 'auto';%default
    2202             OutputDirVisible='on';
    2203             SubDir=InputTable(1:end,2); %set of subdirectories
    2204             SubDirOut=SubDir{1};
    2205             if numel(SubDir)>1
    2206                 for ilist=2:numel(SubDir)
    2207                     SubDirOut=[SubDirOut '-' SubDir{ilist}];
    2208                 end
     2199end
     2200OutputDirVisible='off';
     2201OutputSubDirMode='auto';%default
     2202SubDirOut='';
     2203if isfield(ParamOut,'OutputSubDirMode')
     2204    OutputSubDirMode=ParamOut.OutputSubDirMode;
     2205end
     2206switch OutputSubDirMode
     2207    case 'auto';%default
     2208        OutputDirVisible='on';
     2209        SubDir=InputTable(1:end,2); %set of subdirectories
     2210        SubDirOut=SubDir{1};
     2211        if numel(SubDir)>1
     2212            for ilist=2:numel(SubDir)
     2213                SubDirOut=[SubDirOut '-' SubDir{ilist}];
    22092214            end
    2210         case 'first'
    2211             OutputDirVisible='on';
    2212             SubDirOut=InputTable{1,2}; %use the first subdir name (+OutputDirExt) as output  subdirectory
    2213         case 'last'
    2214             OutputDirVisible='on';
    2215             SubDirOut=InputTable{end,2}; %use the last subdir name (+OutputDirExt) as output  subdirectory
    2216     end
    2217     set(handles.OutputSubDir,'String',SubDirOut)
    2218     set(handles.OutputDirExt,'Visible',OutputDirVisible)
    2219     set(handles.OutputSubDir,'Visible',OutputDirVisible)
    2220     set(handles.OutputDir_title,'Visible',OutputDirVisible)
    2221     SeriesData.ActionName=ActionName;%record ActionName for next use
    2222    
    2223    
    2224     %% visibility of the run mode (local or background or cluster)
    2225     if strcmp(OutputSubDirMode,'none')
    2226         RunModeVisible='off';% only local mode available if no output file is produced
    2227     else
    2228         RunModeVisible='on';
    2229     end
    2230     set(handles.RunMode,'Visible',RunModeVisible)
    2231     set(handles.ActionExt,'Visible',RunModeVisible)
    2232     set(handles.RunMode_title,'Visible',RunModeVisible)
    2233     set(handles.ActionExt_title,'Visible',RunModeVisible)
    2234 end
     2215        end
     2216    case 'first'
     2217        OutputDirVisible='on';
     2218        SubDirOut=InputTable{1,2}; %use the first subdir name (+OutputDirExt) as output  subdirectory
     2219    case 'last'
     2220        OutputDirVisible='on';
     2221        SubDirOut=InputTable{end,2}; %use the last subdir name (+OutputDirExt) as output  subdirectory
     2222end
     2223set(handles.OutputSubDir,'String',SubDirOut)
     2224set(handles.OutputDirExt,'Visible',OutputDirVisible)
     2225set(handles.OutputSubDir,'Visible',OutputDirVisible)
     2226set(handles.OutputDir_title,'Visible',OutputDirVisible)
     2227SeriesData.ActionName=ActionName;%record ActionName for next use
     2228
     2229
     2230%% visibility of the run mode (local or background or cluster)
     2231if strcmp(OutputSubDirMode,'none')
     2232    RunModeVisible='off';% only local mode available if no output file is produced
     2233else
     2234    RunModeVisible='on';
     2235end
     2236set(handles.RunMode,'Visible',RunModeVisible)
     2237set(handles.ActionExt,'Visible',RunModeVisible)
     2238set(handles.RunMode_title,'Visible',RunModeVisible)
     2239set(handles.ActionExt_title,'Visible',RunModeVisible)
     2240
    22352241
    22362242%% Expected nbre of output files
     
    29872993    if ~isfield(Param,'OutputSubDir')   
    29882994        msgbox_uvmat('ERROR','no standard sub-directory definition for output files, use a browser to check the output')
     2995        set(handles.status,'BackgroundColor',[0 1 0])
    29892996        return
    29902997    end
  • 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.