Changeset 845
- Timestamp:
- Dec 17, 2014, 12:32:52 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series.m
r844 r845 1308 1308 function RUN_Callback(hObject, eventdata, handles) 1309 1309 1310 %% read the data on the GUI series1311 Param=read_GUI_series(handles);%displayed parameters1312 SeriesData=get(handles.series,'UserData');%hidden parameters1313 if ~isfield(SeriesData,'i1_series')1314 msgbox_uvmat('ERROR','The input field series needs to be refreshed: press REFRESH')1315 return1316 end1317 if isfield(Param,'InputFields')&& isequal(Param.InputFields.FieldName,'get_field...')1318 msgbox_uvmat('ERROR','input field name(s) not defined, select get_field...')1319 return1320 end1321 1322 1310 %% settings of the button RUN 1323 1311 set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel' … … 1326 1314 drawnow 1327 1315 set(handles.status,'Value',0)% desable status display if relevant 1328 status_Callback(hObject, eventdata, handles) 1316 status_Callback([], eventdata, handles) 1317 1318 %% launch action 1319 errormsg=launch_action(handles); 1320 if ~isempty(errormsg) 1321 msgbox_uvmat('ERROR',errormsg) 1322 end 1323 1324 %% reset the GUI series 1325 update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished 1326 set(handles.RUN, 'Enable','On') 1327 set(handles.RUN,'BackgroundColor',[1 0 0]) 1328 set(handles.RUN, 'Value',0) 1329 1330 %------------------------------------------------------------------------ 1331 % --- called by RUN_Callback 1332 %------------------------------------------------------------------------ 1333 function errormsg=launch_action(handles) 1334 errormsg='';%default 1335 1336 %% read the data on the GUI series 1337 Param=read_GUI_series(handles);%displayed parameters 1338 SeriesData=get(handles.series,'UserData');%hidden parameters 1339 if ~isfield(SeriesData,'i1_series') 1340 errormsg='The input field series needs to be refreshed: press REFRESH'; 1341 return 1342 end 1343 if isfield(Param,'InputFields')&& isequal(Param.InputFields.FieldName,'get_field...') 1344 errormsg='input field name(s) not defined, select get_field...'; 1345 return 1346 end 1329 1347 1330 1348 %% select the Action mode, 'local', 'background' or 'cluster' (if available) … … 1341 1359 ActionName=Param.Action.ActionName; 1342 1360 ActionPath=Param.Action.ActionPath; 1343 1344 1361 path_series=fileparts(which('series')); 1345 1362 … … 1349 1366 eval(['spath=which(''' ActionName ''');']) %spath = current path of the selected function ACTION 1350 1367 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']; 1352 1369 return 1353 1370 end … … 1390 1407 end 1391 1408 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'; 1393 1410 return 1394 1411 end … … 1463 1480 1464 1481 %% create the output data directory if needed 1465 Outpu Dir='';1482 OutputDir=''; 1466 1483 if isfield(Param,'OutputSubDir') 1467 1484 SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt]; … … 1472 1489 answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); 1473 1490 if strcmp(answer,'Cancel') 1474 errormsg='Cancel';1491 set(handles.RUN,'backgroundcolor',[1 0 0]) 1475 1492 return 1476 1493 elseif strcmp(answer,'Yes') … … 1495 1512 [tild,msg1]=mkdir(OutputDir); 1496 1513 if ~strcmp(msg1,'') 1497 msgbox_uvmat('ERROR',['cannot create ' OutputDir ': ' msg1]);%error message for directory creation1514 errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation 1498 1515 return 1499 1516 end … … 1501 1518 if success==0 1502 1519 msgbox_uvmat('WARNING',{['unable to set group write access to ' OutputDir ':']; msg1});%error message for directory creation 1503 return1504 1520 end 1505 1521 end … … 1512 1528 [tild,msg1]=mkdir(DirXml); 1513 1529 if ~strcmp(msg1,'') 1514 msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation1530 errormsg=['cannot create ' DirXml ': ' msg1];%error message for directory creation 1515 1531 return 1516 1532 end … … 1540 1556 end 1541 1557 if 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'; 1545 1559 return 1546 1560 end … … 1626 1640 end 1627 1641 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 option1630 % return1631 1642 else 1632 1643 %% processing on a different session of the same computer (background) or cluster, create executable files … … 1643 1654 [tild,msg1]=mkdir(DirBat); 1644 1655 if ~strcmp(msg1,'') 1645 msgbox_uvmat('ERROR',['cannot create ' DirBat ': ' msg1]);%error message for directory creation1656 errormsg=['cannot create ' DirBat ': ' msg1];%error message for directory creation 1646 1657 return 1647 1658 end … … 1652 1663 [tild,msg1]=mkdir(DirLog); 1653 1664 if ~strcmp(msg1,'') 1654 msgbox_uvmat('ERROR',['cannot create ' DirLog ': ' msg1]);%error message for directory creation1665 errormsg=['cannot create ' DirLog ': ' msg1];%error message for directory creation 1655 1666 return 1656 1667 end … … 1684 1695 [fid,message]=fopen(filebat,'w');% create the executable file 1685 1696 if isequal(fid,-1) 1686 msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);1697 errormsg=['creation of .bat file: ' message]; 1687 1698 return 1688 1699 end … … 1742 1753 for iprocess=1:NbProcess 1743 1754 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']) 1745 1756 end 1746 1757 case 'cluster_oar' % option 'oar-parexec' used … … 1755 1766 [tild,msg1]=mkdir(DirOAR); 1756 1767 if ~strcmp(msg1,'') 1757 msgbox_uvmat('ERROR',['cannot create ' DirOAR ': ' msg1]);%error message for directory creation1768 errormsg=['cannot create ' DirOAR ': ' msg1];%error message for directory creation 1758 1769 return 1759 1770 end … … 1785 1796 msgbox_uvmat('CONFIRMATION',[ActionName ' launched in cluster: press STATUS to see results']) 1786 1797 end 1787 1788 %% reset the GUI series1789 update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate launching is finished1790 set(handles.RUN, 'Enable','On')1791 set(handles.RUN,'BackgroundColor',[1 0 0])1792 set(handles.RUN, 'Value',0)1793 1798 1794 1799 %------------------------------------------------------------------------ … … 2192 2197 end 2193 2198 set(handles.OutputDirExt,'String',OutputDirExt) 2194 OutputDirVisible='off'; 2195 OutputSubDirMode='auto';%default 2196 SubDirOut=''; 2197 if isfield(ParamOut,'OutputSubDirMode') 2198 OutputSubDirMode=ParamOut.OutputSubDirMode; 2199 end2200 switch OutputSubDirMode 2201 case 'auto';%default 2202 OutputDirVisible='on';2203 SubDir=InputTable(1:end,2); %set of subdirectories2204 SubDirOut=SubDir{1};2205 if numel(SubDir)>12206 for ilist=2:numel(SubDir)2207 SubDirOut=[SubDirOut '-' SubDir{ilist}];2208 end2199 end 2200 OutputDirVisible='off'; 2201 OutputSubDirMode='auto';%default 2202 SubDirOut=''; 2203 if isfield(ParamOut,'OutputSubDirMode') 2204 OutputSubDirMode=ParamOut.OutputSubDirMode; 2205 end 2206 switch 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}]; 2209 2214 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 2222 end 2223 set(handles.OutputSubDir,'String',SubDirOut) 2224 set(handles.OutputDirExt,'Visible',OutputDirVisible) 2225 set(handles.OutputSubDir,'Visible',OutputDirVisible) 2226 set(handles.OutputDir_title,'Visible',OutputDirVisible) 2227 SeriesData.ActionName=ActionName;%record ActionName for next use 2228 2229 2230 %% visibility of the run mode (local or background or cluster) 2231 if strcmp(OutputSubDirMode,'none') 2232 RunModeVisible='off';% only local mode available if no output file is produced 2233 else 2234 RunModeVisible='on'; 2235 end 2236 set(handles.RunMode,'Visible',RunModeVisible) 2237 set(handles.ActionExt,'Visible',RunModeVisible) 2238 set(handles.RunMode_title,'Visible',RunModeVisible) 2239 set(handles.ActionExt_title,'Visible',RunModeVisible) 2240 2235 2241 2236 2242 %% Expected nbre of output files … … 2987 2993 if ~isfield(Param,'OutputSubDir') 2988 2994 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]) 2989 2996 return 2990 2997 end -
trunk/src/series/stereo_civ.m
r844 r845 39 39 40 40 function [Data,errormsg,result_conv]= stereo_civ(Param) 41 Data=[]; 41 42 errormsg=''; 42 43 43 44 %% set the input elements needed on the GUI series when the action is selected in the menu ActionName or InputTable refreshed 44 45 if 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 45 50 path_series=fileparts(which('series')); 46 51 addpath(fullfile(path_series,'series')) … … 285 290 end 286 291 [A,Rangx,Rangy]=phys_ima(A,XmlData,1); 287 288 292 [Npy,Npx]=size(A{1}); 289 293 PhysImageA=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.png','_1a',i1_series_Civ1(ifield),[],1); 290 294 PhysImageB=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.png','_1a',i1_series_Civ1(ifield),[],2); … … 323 327 324 328 % 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 record326 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'}; 327 331 Data.VarAttribute{1}.Role='coord_x'; 328 332 Data.VarAttribute{2}.Role='coord_y'; … … 334 338 % calculate velocity data (y and v in indices, reverse to y component) 335 339 [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ1); 336 if ~isempty(errormsg)337 disp_uvmat('ERROR',errormsg,checkrun)338 return339 end340 340 Data.Civ1_X=reshape(xtable,[],1); 341 341 Data.Civ1_Y=reshape(par_civ1.ImageHeight-ytable+1,[],1); 342 342 % get z from u and v (displacements) 343 343 Data.Civ1_U=reshape(utable,[],1); 344 Data.Civ1_V=reshape(-vtable,[],1); 345 344 Data.Civ1_V=reshape(-vtable,[],1); 346 345 Data.Civ1_C=reshape(ctable,[],1); 347 346 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 348 356 end 349 357 … … 1016 1024 end 1017 1025 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 1032 function [z,error]=shift2z(xmid, ymid, u, v,XmlData) 1033 z=0; 1034 error=0; 1035 1036 %% first image 1037 Calib_A=XmlData{1}.GeometryCalib; 1038 R=(Calib_A.R)'; 1039 x_a=xmid- u/2; 1040 y_a=ymid- v/2; 1041 z_a=R(7)*x_a+R(8)*y_a+R(9)*Calib_A.SliceCoord(1,3); 1042 X=(R(1)*x_a+R(2)*y_a+R(3)*Calib_A.SliceCoord(1,3))./z_a; 1043 Y=(R(4)*x_a+R(5)*y_a+R(6)*Calib_A.SliceCoord(1,3))./z_a; 1044 A_1_1=R(1)-R(7)*x_a; 1045 A_1_2=R(2)-R(8)*x_a; 1046 A_1_3=R(3)-R(9)*x_a; 1047 A_2_1=R(4)-R(7)*y_a; 1048 A_2_2=R(5)-R(8)*y_a; 1049 A_2_3=R(6)-R(9)*y_a; 1050 Det=A_1_1.*A_2_2-A_1_2.*A_2_1; 1051 Dxa=(A_1_2.*A_2_3-A_2_2.*A_1_3)./Det; 1052 Dya=(A_2_1.*A_1_3-A_1_1.*A_2_3)./Det; 1053 1054 %% second image 1055 Calib_A=XmlData{1}.GeometryCalib; 1056 R=(Calib_A.R)'; 1057 x_a=xmid+ u/2; 1058 y_a=ymid+ v/2; 1059 z_a=R(7)*x_a+R(8)*y_a+R(9)*Calib_A.SliceCoord(1,3); 1060 X=(R(1)*x_a+R(2)*y_a+R(3)*Calib_A.SliceCoord(1,3))./z_a; 1061 Y=(R(4)*x_a+R(5)*y_a+R(6)*Calib_A.SliceCoord(1,3))./z_a; 1062 A_1_1=R(1)-R(7)*x_a; 1063 A_1_2=R(2)-R(8)*x_a; 1064 A_1_3=R(3)-R(9)*x_a; 1065 A_2_1=R(4)-R(7)*y_a; 1066 A_2_2=R(5)-R(8)*y_a; 1067 A_2_3=R(6)-R(9)*y_a; 1068 Det=A_1_1.*A_2_2-A_1_2.*A_2_1; 1069 Dxb=(A_1_2.*A_2_3-A_2_2.*A_1_3)./Det; 1070 Dyb=(A_2_1.*A_1_3-A_1_1.*A_2_3)./Det; 1071 1072 %% result 1073 Den=(Dxb-Dxa).*(Dxb-Dxa)+(Dyb-Dya).*(Dyb-Dya); 1074 error=((Dyb-Dya).*u-(Dxb-Dxa).*v)./Den; 1075 z=((Dxb-Dxa).*u-(Dyb-Dya).*v)./Den;
Note: See TracChangeset
for help on using the changeset viewer.