- Timestamp:
- Feb 17, 2017, 12:17:59 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ_3D.m
r977 r999 1 %'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume 1 %'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume 2 2 %------------------------------------------------------------------------ 3 3 % provides an interface for the software CIVx … … 55 55 % varargin command line arguments to civ_3D (see VARARGIN) 56 56 global test_batch patch_new_exe%=1 if patch processing available 57 %filebase: root name 57 %filebase: root name 58 58 %nom_type: nomencalture used ('png_old','_i_j'...) 59 59 %list of field numbers to process 60 %subdir: subdirectory of the opened netcdf file 60 %subdir: subdirectory of the opened netcdf file 61 61 %ind_opening: operation number advised for beginning (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2), 62 62 %ind_a_opening ind_b_opening chosen pair from the opened netcdf file … … 70 70 nom_type=[]; % nomenclature type 71 71 ext=[]; 72 testall=0; 72 testall=0; 73 73 browse=[]; 74 74 75 %load the initial parameters if the interface is started from uvmat 75 %load the initial parameters if the interface is started from uvmat 76 76 if ~isempty(varargin)% the interface is opened from uvmat 77 77 varcell=varargin{1}; … … 95 95 ind_opening=1; % proposed operation number (1=civ1,2=fix1,3=patch1,4=civ2,5=fix2,6=patch2) 96 96 ind_a_opening=1; % proposed index in the menu of fields a 97 ind_b_opening=2; % proposed index in the menu of fields b 97 ind_b_opening=2; % proposed index in the menu of fields b 98 98 end 99 99 100 100 if exist('ext','var') & length(ext)>1 & (~isempty(imformats(ext([2:end])))|... 101 101 isequal(ext,'.avi')|isequal(ext,'.AVI'));%if an image file has been opened by uvmat 102 browse.ext_ima=ext; 102 browse.ext_ima=ext; 103 103 if exist('nom_type_read','var') 104 104 browse.nom_type_ima=nom_type_read; % the image nomenclature is stored … … 116 116 117 117 % set(handles.ImaDoc,'String',ext) 118 118 119 119 %read names of the .exe file to adjust the interface according to 120 120 %available prog … … 139 139 end 140 140 end 141 141 142 142 patch_new_exe=''; 143 143 todo_patch=''; … … 152 152 if isfield(sparam,'SGE') 153 153 sge=str2num(sparam.SGE); 154 end 154 end 155 155 name_todo=fullfile(todo_path,'TODO.txt') 156 156 test_batch=1; … … 160 160 test_batch=0; 161 161 end 162 if exist(name_todo,'file')~=2 162 if exist(name_todo,'file')~=2 163 163 msgbox_uvmat('ERROR',['no batch distributed processing available, queue file ' name_todo ' absent']); 164 164 % test_batch=0; % Problems to detect file on linux/nfs filesystems … … 233 233 else 234 234 num_ref_j=floor((num_a+num_b)/2); 235 browse.incr_pair(2)=num_b-num_a; 235 browse.incr_pair(2)=num_b-num_a; 236 236 end 237 237 set(handles.first_i,'String',num2str(num_ref_i)); … … 240 240 set(handles.browse_root,'UserData',browse); 241 241 if ~isempty(varargin)% the interface is opened from uvmat 242 displ_filebase_Callback(hObject, eventdata, handles); 242 displ_filebase_Callback(hObject, eventdata, handles); 243 243 end 244 244 … … 275 275 end 276 276 if isfield(h,'RootPath')&ischar(h.RootPath) 277 % oldfile=h.filebase{1} 277 % oldfile=h.filebase{1} 278 278 oldfile=h.RootPath; 279 279 end … … 291 291 292 292 [FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile); 293 fileinput=[PathName FileName];%complete file name 293 fileinput=[PathName FileName];%complete file name 294 294 sizf=size(fileinput); 295 295 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string … … 327 327 if length(ext)>1 & (~isempty(imformats(ext([2:end])))||... 328 328 isequal(lower(ext),'.avi')||isequal(ext,'.vol'));%if an image file has been opened by uvmat 329 browse.ext_ima=ext; 329 browse.ext_ima=ext; 330 330 browse.nom_type_ima=nom_type; 331 331 browse.field_count=str2num(field_count); … … 335 335 if isequal(ext,'.nc') 336 336 browse.nom_type_nc=nom_type; 337 ind_opening=2;% propose 'fix' as the default option 337 ind_opening=2;% propose 'fix' as the default option 338 338 Data=nc2struct(fileinput,[]); 339 339 if isfield(Data,'fix') & isequal(Data.fix,1) … … 379 379 set(handles.first_i,'String',num2str(ref_i)); 380 380 set(handles.last_i,'String',num2str(ref_i)); 381 set(handles.ref_i,'String',num2str(ref_i)); 381 set(handles.ref_i,'String',num2str(ref_i)); 382 382 end 383 383 if isequal(ind_opening,1) … … 427 427 field_count=1;%default 428 428 nom_type_nc=[]; 429 npx=[];%default 429 npx=[];%default 430 430 npy=[]; 431 431 TimeUnit='s'; %default … … 437 437 ext=get(handles.ImaDoc,'String'); 438 438 browse=get(handles.browse_root,'UserData');%default 439 if ~isempty(browse) 439 if ~isempty(browse) 440 440 if isfield(browse,'ext_ima') 441 441 ext_ima=browse.ext_ima; … … 468 468 if isfield(browse,'pxcmx') & isfield(browse,'pxcmy') 469 469 pxcmx=num2str(browse.pxcmx); 470 pxcmy=num2str(browse.pxcmy); 470 pxcmy=num2str(browse.pxcmy); 471 471 else 472 472 pxcmx=1;%default 473 pxcmy=1; 473 pxcmy=1; 474 474 end 475 475 %look for an image documentation file … … 481 481 ext='.civ_3D'; 482 482 set(handles.ImaDoc,'String','.civ_3D') 483 elseif exist([filebase '.avi'],'file') 483 elseif exist([filebase '.avi'],'file') 484 484 ext='.avi'; 485 485 set(handles.ImaDoc,'String','.avi') … … 511 511 if isfield(XmlData,'GeometryCalib') 512 512 tsai=XmlData.GeometryCalib; 513 if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') 513 if isfield(tsai,'f') & isfield(tsai,'Tz') & isfield(tsai,'dpx') & isfield(tsai,'dpy')& isfield(tsai,'R') 514 514 rot2D=tsai.R([1:2],[1,2]); 515 515 pxcmx_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpx); 516 pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); 516 pxcmy_search=tsai.f * sqrt(det(rot2D))/(tsai.Tz*tsai.dpy); 517 517 end 518 if isfield(tsai,'CoordUnit') 518 if isfield(tsai,'CoordUnit') 519 519 CoordUnit=tsai.CoordUnit; 520 520 end 521 end 521 end 522 522 if isempty(ext_ima_read) 523 523 ext_ima='.png';%default … … 531 531 nom_type_ima=nom_type_read; 532 532 end 533 534 elseif isequal(ext,'.avi')|isequal(ext,'.AVI') 533 534 elseif isequal(ext,'.avi')|isequal(ext,'.AVI') 535 535 nom_type_ima='avi'; 536 536 ext_ima=ext; … … 542 542 nbfield=info.NumFrames;%number of frames 543 543 end 544 time=(dt*[0:nbfield-1])';%list of image times 544 time=(dt*[0:nbfield-1])';%list of image times 545 545 set(handles.dt,'String',num2str(dt*1000));%store the time interval between successive images 546 547 % no image documentation file found: look for a series of existing images or .nc files 548 elseif ~isequal(ext,'.nc') 546 547 % no image documentation file found: look for a series of existing images or .nc files 548 elseif ~isequal(ext,'.nc') 549 549 subdir=get(handles.subdir_civ1,'String'); 550 550 incr_pair=[0 0];%default … … 572 572 field_i=field_count;%look for the minimum file number in the series 573 573 idetect=1; 574 while idetect==1 574 while idetect==1 575 575 field_i=field_i-1; 576 576 imagename=name_generator(filebase,field_i,1,ext_ima,nom_type_ima); … … 592 592 end 593 593 if isequal(nom_type_ima,'none')% no file numbering used 594 first_i=1; 594 first_i=1; 595 595 last_i=1; 596 596 first_j=1; … … 653 653 end 654 654 end 655 mode_Callback(hObject, eventdata, handles) 655 mode_Callback(hObject, eventdata, handles) 656 656 657 657 %%%%%% initialize waitbars and RUN button … … 666 666 set(handles.BATCH,'BackgroundColor',[1 0 0]) 667 667 end 668 668 669 669 %%%%% store the root input filename for future opening 670 670 dir_perso=prefdir; … … 678 678 relnumb=str2num(Release(3:4)); 679 679 if relnumb >= 14 680 save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat 680 save (profil_perso,'RootPath','-V6'); %store the root name for future opening of uvmat 681 681 else 682 682 save (profil_perso,'RootPath'); %store the root name for future opening of uvmat … … 742 742 displ_num(3,index)=0; 743 743 displ_num(4,index)=0; 744 end 744 end 745 745 set(handles.jtext,'Visible','On') 746 746 set(handles.first_j,'Visible','On') … … 764 764 set(handles.ref_i,'Visible','Off') 765 765 end 766 elseif isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') 766 elseif isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') 767 767 for index=1:min(nbfield-1,200) 768 768 displ_num(1,index)=0; … … 778 778 set(handles.ref_i,'Visible','On') 779 779 elseif isequal(mode,'displacement')%the pairs have the same indices 780 displ_num(1,1)=0; 780 displ_num(1,1)=0; 781 781 displ_num(2,1)=0; 782 782 displ_num(3,1)=0; … … 812 812 set(handles.ref_j,'Visible','Off') 813 813 end 814 end 814 end 815 815 set(handles.list_pair_civ1,'UserData',displ_num); 816 816 find_netcpair_civ1(hObject, eventdata, handles) … … 855 855 else 856 856 nom_type_nc='_i_j1-j2'; 857 end 857 end 858 858 end 859 859 browse.nom_type_nc=nom_type_nc; … … 874 874 if isempty(time) 875 875 time=[0 1]; 876 end 876 end 877 877 displ_num=get(handles.list_pair_civ1,'UserData'); 878 878 879 %eliminate the first pairs inconsistent with the position 879 %eliminate the first pairs inconsistent with the position 880 880 if isempty(displ_num) 881 881 nbpair=0; … … 890 890 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 891 891 892 %look for existing processed pairs involving the field at the middle of the series if civ1 will not 892 %look for existing processed pairs involving the field at the middle of the series if civ1 will not 893 893 % be performed, while the result is needed for next steps. 894 894 displ_pair={''}; … … 897 897 if get(handles.CIV1,'Value')==0 % 898 898 dirname=fullfile(filepath,subdir_civ1,ext_dir); 899 if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') 899 if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir') 900 900 msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']); 901 901 set(handles.list_pair_civ1,'String',{}); 902 902 return 903 903 end 904 for ipair=1:nbpair 904 for ipair=1:nbpair 905 905 filename=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 906 906 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); … … 908 908 end 909 909 if ~exist('select','var') | isequal(select,zeros(size(1:nbpair))) 910 if isfield(browse,'incr_pair') 910 if isfield(browse,'incr_pair') 911 911 num_i1=ref_i-floor(browse.incr_pair(1)/2); 912 912 num_i2=ref_i+ceil(browse.incr_pair(1)/2); … … 917 917 testpair=1; 918 918 else 919 if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 919 if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 920 920 msgbox_uvmat('ERROR',['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]); 921 921 else … … 928 928 end 929 929 end 930 if isequal(mode,'series(Di)') 930 if isequal(mode,'series(Di)') 931 931 if testpair 932 displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; 933 else 932 displ_pair{1}=['Di= ' num2str(-floor(browse.incr_pair(1)/2)) '|' num2str(ceil(browse.incr_pair(1)/2))]; 933 else 934 934 for ipair=1:nbpair 935 if select(ipair) 935 if select(ipair) 936 936 dt=time(ref_i+displ_num(4,ipair),1)-time(ref_i+displ_num(3,ipair),1);%time interval dt 937 937 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; 938 else 938 else 939 939 displ_pair{ipair}='...'; %pair not displayed in the menu 940 940 end … … 947 947 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 948 948 ' :dt= ' num2str(dt*1000)]; 949 else 949 else 950 950 displ_pair{ipair}='...'; %pair not displayed in the menu 951 end 951 end 952 952 end 953 953 elseif isequal(mode,'displacement') 954 displ_pair={'Di=Dj=0'}; 955 end 954 displ_pair={'Di=Dj=0'}; 955 end 956 956 set(handles.list_pair_civ1,'String',displ_pair'); 957 957 ichoice=min(find(select)); … … 968 968 set(gcf,'Pointer','arrow') 969 969 %-------------------------------------------------------------- 970 % determine the menu for civ2 pairs depending on the existing netcdf file at the 971 %middle of the series set by first_i, incr, last_i 970 % determine the menu for civ2 pairs depending on the existing netcdf file at the 971 %middle of the series set by first_i, incr, last_i 972 972 %-------------------------------------------------------------- 973 973 function find_netcpair_civ2(hObject, eventdata, handles) … … 1002 1002 else 1003 1003 nom_type_nc='_i_j1-j2'; 1004 end 1004 end 1005 1005 end 1006 1006 browse.nom_type_nc=nom_type_nc; … … 1032 1032 1033 1033 1034 %eliminate the first pairs inconsistent with the position 1034 %eliminate the first pairs inconsistent with the position 1035 1035 if isempty(displ_num) 1036 1036 nbpair=0; 1037 1037 else 1038 1038 nbpair=length(displ_num(1,:));%nbre of displayed pairs 1039 if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') 1039 if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') 1040 1040 nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index 1041 elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 1041 elseif isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 1042 1042 nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index 1043 1043 end … … 1045 1045 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200 1046 1046 1047 %look for existing processed pairs involving the field at the middle of the series if civ1 will not 1047 %look for existing processed pairs involving the field at the middle of the series if civ1 will not 1048 1048 % be performed, while the result is needed for next steps. 1049 1049 displ_pair={''}; %default 1050 1050 select=ones(size(1:nbpair));%default =1 for nubers of displayed pairs 1051 1051 if get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0%&... 1052 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 1052 if ~exist(fullfile(filepath,subdir_civ2,ext_dir),'dir') 1053 1053 errordlg(['no civ2 file available: subdirectory ' subdir_civ2 ' does not exist']) 1054 1054 set(handles.list_pair_civ2,'String',{}); 1055 1055 return 1056 1056 end 1057 for ipair=1:nbpair 1057 for ipair=1:nbpair 1058 1058 [filename]=name_generator(filebase,ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair),'.nc',nom_type_nc,1,... 1059 1059 ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair),subdir_civ1); … … 1061 1061 end 1062 1062 if isequal(select,zeros(size(1:nbpair))) 1063 if isfield(browse,'incr_pair') 1063 if isfield(browse,'incr_pair') 1064 1064 num_i1=ref_i-floor(browse.incr_pair(1)/2); 1065 1065 num_i2=ref_i+floor((browse.incr_pair(1)+1)/2); … … 1069 1069 select(1)=exist(filename,'file'); 1070 1070 else 1071 if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 1071 if isequal(mode,'series(Dj)') | isequal(mode,'st_series(Dj)') 1072 1072 msgbox_uvmat('ERROR',['no civ2 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ2]) 1073 1073 else … … 1079 1079 end 1080 1080 end 1081 if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') 1081 if isequal(mode,'series(Di)') | isequal(mode,'st_series(Di)') 1082 1082 if ~isequal(get(handles.ext_txt,'String'),'dt(ms)=') 1083 1083 for ipair=1:nbpair … … 1085 1085 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt 1086 1086 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; 1087 else 1087 else 1088 1088 displ_pair{ipair}='...'; %pair not displayed in the menu 1089 1089 end … … 1093 1093 if select(ipair) 1094 1094 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt_unit*ipair)]; 1095 else 1095 else 1096 1096 displ_pair{ipair}='...'; %pair not displayed in the menu 1097 1097 end … … 1103 1103 dt=time(ref_i+displ_num(4,ipair),ref_j+displ_num(2,ipair))-time(ref_i+displ_num(3,ipair),ref_j+displ_num(1,ipair));%time interval dt 1104 1104 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2)) ' :dt= ' num2str(dt*1000)]; 1105 else 1105 else 1106 1106 displ_pair{ipair}='...'; %pair not displayed in the menu 1107 1107 end … … 1113 1113 displ_pair{ipair}=['j= ' num2stra(displ_num(1,ipair),nom_type_ima) '-' num2stra(displ_num(2,ipair),nom_type_ima) ... 1114 1114 ' :dt= ' num2str(dt*1000)]; 1115 else 1115 else 1116 1116 displ_pair{ipair}='...'; %pair not displayed in the menu 1117 end 1117 end 1118 1118 end 1119 1119 elseif isequal(mode,'displacement') 1120 displ_pair={'Di=Dj=0'}; 1121 end 1120 displ_pair={'Di=Dj=0'}; 1121 end 1122 1122 set(handles.list_pair_civ2,'String',displ_pair'); 1123 1123 ichoice=min(find(select)); … … 1128 1128 set(gcf,'Pointer','arrow') 1129 1129 %---------------------------------------------------- 1130 % determine the list of index pairs of processing file 1130 % determine the list of index pairs of processing file 1131 1131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1132 1132 function [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... … … 1150 1150 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end; 1151 1151 num1=[first_i:incr:last_i]; 1152 if isequal (mode,'series(Di)') 1152 if isequal (mode,'series(Di)') 1153 1153 %recognize the pair civ1 from the display 1154 1154 indsel=find((double(str_civ1)<48)|(double(str_civ1)>57));% character indices of non numerical characters 1155 1155 str_raw=str_civ1(indsel); 1156 1156 indsepar=find(str_raw=='|'); %character index of the separator … … 1160 1160 else 1161 1161 d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1])); 1162 end 1162 end 1163 1163 %recognize the pair civ2 from the display 1164 1164 num1_civ1=num1-d1;% set of first image numbers … … 1251 1251 set(handles.list_pair_civ2,'Value',index_pair); 1252 1252 1253 %update first_i and last_i according to the chosen image pairs 1253 %update first_i and last_i according to the chosen image pairs 1254 1254 mode_list=get(handles.mode,'String'); 1255 1255 mode_value=get(handles.mode,'Value'); … … 1281 1281 set(handles.first_j,'String',num2str(num1(1))); 1282 1282 set(handles.last_j,'String',num2str(num1(end))); 1283 end 1283 end 1284 1284 1285 1285 %------------------------------------------------------------------ … … 1287 1287 function list_pair_civ2_Callback(hObject, eventdata, handles) 1288 1288 1289 index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu 1290 1291 %update first_i and last_i according to the chosen image pairs 1289 index_pair=get(handles.list_pair_civ2,'Value');%get the selected position index in the menu 1290 1291 %update first_i and last_i according to the chosen image pairs 1292 1292 mode_list=get(handles.mode,'String'); 1293 1293 mode_value=get(handles.mode,'Value'); … … 1319 1319 set(handles.first_j,'String',num2str(num1(1))); 1320 1320 set(handles.last_j,'String',num2str(num1(end))); 1321 end 1321 end 1322 1322 1323 1323 … … 1392 1392 return 1393 1393 end 1394 1394 1395 1395 %choice of batch priority 1396 1396 ind_answer=2; … … 1404 1404 'SelectionMode','single',... 1405 1405 'ListString',str,'ListSize',[200 200],'Name','job priority','InitialValue',3); 1406 if isequal(v,0) % to handle Cancel button and figure close, 1406 if isequal(v,0) % to handle Cancel button and figure close, 1407 1407 return % a better way should be create 1408 1408 end … … 1426 1426 cur_dir=pwd; 1427 1427 if ~isequal(cur_dir(2:3),':\') 1428 cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: 1428 cd(matlabroot); %move to the Matlab root directory if the current Matlab dir does not allow the dos command or is M: 1429 1429 end 1430 1430 [ss,ww]=dos(['net use ' filebase(1:2)]); … … 1457 1457 1458 1458 [num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=... 1459 find_pair_indices(handles,mode); %determine the pairs of processing file 1459 find_pair_indices(handles,mode); %determine the pairs of processing file 1460 1460 1461 1461 %check dir … … 1491 1491 nbfield=length(num1_civ1); 1492 1492 nbslice=length(num_a_civ1); 1493 1493 1494 1494 %check the existence of the netcdf and image files involved 1495 1495 % if box_test(1)==1;%CIV1 activated 1496 detect=1; 1496 detect=1; 1497 1497 while detect==1 %name a new subdir if one of the netcdf files already exists 1498 1498 for ifile=1:nbfield … … 1529 1529 cd(currentdir) 1530 1530 return 1531 end 1531 end 1532 1532 if ~exist(filecell_ima2_civ1{ifile},'file') 1533 1533 msgbox_uvmat('ERROR',[filecell_ima2_civ1{ifile} ' not found']) … … 1539 1539 end 1540 1540 1541 cd(currentdir);%come back to the initial working directory 1541 cd(currentdir);%come back to the initial working directory 1542 1542 % if ~isequal(m2,'') 1543 1543 % msgbox(m2);%error message for directory creation … … 1549 1549 1550 1550 for ifile=1:nbfield 1551 i_cmd=0; 1551 i_cmd=0; 1552 1552 cmd='#!/bin/bash'; 1553 1553 cmd=char({cmd;'#$ -cwd'}); … … 1556 1556 filename_cmx([end-1:end])='cm';%name of cmx file 1557 1557 filename_cmx=[filename_cmx 'x']; 1558 1558 1559 1559 %CIV1 1560 1560 if box_test(1)==1 … … 1575 1575 civAllxml=set(civAllxml,1,'name','civ3d3c'); 1576 1576 % save(civAllxml) 1577 1578 1579 1577 par_civ1_3d_xml=fullfile(par_civ1.path,[resu_file '.xml']);%[par_civ1.path '/test_to_change.xml']; 1578 pvalue=num2str((1-ind_answer)*500) 1579 save(civAllxml,par_civ1_3d_xml); 1580 1580 nb_processor='8'; 1581 1582 1583 1584 end 1581 ['echo /CIVX/bin/MPI/lam-7.1.3_g95/bin/mpirun C ' Civ3D3CBin ' -p ' par_civ1_3d_xml '|qsub -p ' pvalue ' -q lam.q -pe lam_loose ' nb_processor ' -e ' par_civ1_3d_xml '.errors -o ' par_civ1_3d_xml '.log' ] 1582 eval ( ['!echo /CIVX/bin/MPI/lam-7.1.3_g95/bin/mpirun C ' Civ3D3CBin ' -p ' par_civ1_3d_xml '|qsub -p ' pvalue ' -q lam.q -pe lam_loose ' nb_processor ' -e ' par_civ1_3d_xml '.errors -o ' par_civ1_3d_xml '.log' ]) 1583 1584 end 1585 1585 end 1586 1586 … … 1591 1591 [Path,Name]=fileparts(filebase); 1592 1592 namefig=fullfile(Path,subdir_civ2,Name); 1593 detect=1; 1593 detect=1; 1594 1594 while detect==1 1595 1595 namefigfull=[namefig '.fig']; … … 1619 1619 end 1620 1620 1621 1621 1622 1622 %---------------------------------------------------- 1623 1623 function first_j_Callback(hObject, eventdata, handles) … … 1714 1714 num_a=1; 1715 1715 num_b=1; 1716 elseif isequal (mode, 'series(Dj)') 1716 elseif isequal (mode, 'series(Dj)') 1717 1717 num1=1; 1718 1718 num2=1; … … 1752 1752 subdir=get(handles.subdir_civ1,'String'); 1753 1753 set(handles.subdir_civ2,'String',subdir); 1754 if get(handles.CIV1,'Value')==0 1754 if get(handles.CIV1,'Value')==0 1755 1755 find_netcpair_civ1(hObject, eventdata, handles); %update the list of available pairs from netcdf files in the new directory 1756 1756 end … … 1828 1828 set(handles.get_mask_civ2,'Value',1) 1829 1829 set(handles.get_mask_fix2,'Value',1) 1830 end 1830 end 1831 1831 set(handles.mask_fix1,'String',mask_displ) 1832 1832 set(handles.mask_civ2,'String',mask_displ) … … 1858 1858 else 1859 1859 set(handles.get_mask_fix2,'Value',1) 1860 end 1860 end 1861 1861 set(handles.mask_civ2,'String',mask_displ) 1862 1862 set(handles.mask_fix2,'String',mask_displ) … … 1884 1884 if isequal(mask_displ,'no mask') 1885 1885 set(handles.get_mask_fix2,'Value',0) 1886 end 1886 end 1887 1887 set(handles.mask_fix2,'String',mask_displ) 1888 1888 end … … 1890 1890 %--------------------------------------- 1891 1891 function [nbslice, flag_mask]=get_mask(filebase,handles) 1892 %detect mask files, images with appropriate file base 1892 %detect mask files, images with appropriate file base 1893 1893 %[filebase '_' xx 'mask'], xx=nbslice 1894 1894 %flag_mask=1 indicates detection … … 1930 1930 nbslice=1; 1931 1931 end 1932 end 1932 end 1933 1933 %------------------------------ 1934 1934 … … 2013 2013 value=get(handles.browse_gridciv1,'Value'); 2014 2014 if value 2015 2016 2015 filebase=get(handles.displ_filebase,'String'); 2016 [FileName, PathName, filterindex] = uigetfile( ... 2017 2017 {'*.grid', ' (*.grid)'; 2018 2018 '*.grid', '.grid files '; ... 2019 2019 '*.*', 'All Files (*.*)'}, ... 2020 2020 'Pick a file',filebase); 2021 2021 filegrid=fullfile(PathName,FileName); 2022 2022 if isempty(FileName)|isempty(PathName)|isequal(FileName,0)|~exist(filegrid,'file') 2023 2023 set(handles.browse_gridciv1,'Value',0); 2024 2024 set(handles.grid_civ1,'string',''); 2025 2026 2027 2025 set(handles.dx_civ1,'Visible','on'); 2026 set(handles.dy_civ1,'Visible','on'); 2027 set(handles.grid_civ2,'string',''); 2028 2028 if get(handles.CIV2,'Value') 2029 2030 2029 set(handles.dx_civ2,'Visible','on'); 2030 set(handles.dy_civ2,'Visible','on'); 2031 2031 end 2032 2032 else 2033 2034 2035 2036 2037 2038 2033 set(handles.grid_civ1,'string',filegrid); 2034 set(handles.dx_civ1,'Visible','off'); 2035 set(handles.dy_civ1,'Visible','off'); 2036 set(handles.grid_civ2,'string',filegrid); 2037 set(handles.dx_civ2,'Visible','off'); 2038 set(handles.dy_civ2,'Visible','off'); 2039 2039 % set(handles.grid_patch1,'string',filegrid); 2040 2040 % set(handles.grid_patch2,'string',filegrid); … … 2042 2042 else 2043 2043 set(handles.grid_civ1,'string',''); 2044 2045 2046 2044 set(handles.dx_civ1,'Visible','on'); 2045 set(handles.dy_civ1,'Visible','on'); 2046 set(handles.grid_civ2,'string',''); 2047 2047 if get(handles.CIV2,'Value') 2048 2049 2048 set(handles.dx_civ2,'Visible','on'); 2049 set(handles.dy_civ2,'Visible','on'); 2050 2050 end 2051 2051 end … … 2286 2286 set(handles.MaxIma2,'Visible','off') 2287 2287 set(handles.ImaThreshold2,'Value',0) 2288 if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) 2288 if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) 2289 2289 set(handles.list_pair_civ2,'Visible','off') 2290 2290 set(handles.subdir_civ2,'Visible','off') … … 2323 2323 % set(handles.rho_civ2_title,'Visible','off') 2324 2324 % set(handles.frame_subdirciv2,'BackgroundColor',[0.831 0.816 0.784]) 2325 % if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) 2325 % if isequal(get(handles.FIX2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) 2326 2326 % set(handles.list_pair_civ2,'Visible','off') 2327 2327 % set(handles.subdir_civ2,'Visible','off') … … 2367 2367 set(handles.inf_sup2,'Visible','off') 2368 2368 set(handles.field_ref2,'Visible','off') 2369 if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) 2369 if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.PATCH2,'Value'),0) 2370 2370 set(handles.list_pair_civ2,'Visible','off') 2371 2371 set(handles.subdir_civ2,'Visible','off') … … 2407 2407 set(handles.get_gridpatch2,'Visible','off') 2408 2408 set(handles.grid_patch2,'Visible','off') 2409 if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) 2409 if isequal(get(handles.CIV2,'Value'),0) & isequal(get(handles.FIX2,'Value'),0) 2410 2410 set(handles.list_pair_civ2,'Visible','off') 2411 2411 set(handles.subdir_civ2,'Visible','off') … … 2459 2459 par.ratioHoverZ=1; 2460 2460 2461 % 2461 % 2462 2462 % %---------------------------------------------------------------- 2463 2463 % function par=read_param_civ2(handles,file_ima) … … 2469 2469 % par.dx=get(handles.dx_civ2,'String'); 2470 2470 % par.dy=get(handles.dy_civ2,'String'); 2471 % if isequal(str2num(par.dx),[]) 2471 % if isequal(str2num(par.dx),[]) 2472 2472 % if isempty(get(handles.grid_civ2,'String')); 2473 2473 % par.dx='0'; %just read by civ_3D program, not used … … 2487 2487 % par.pxcmx=get(handles.pxcmx,'String'); 2488 2488 % par.pxcmy=get(handles.pxcmy,'String'); 2489 % if isempty(str2num(par.pxcmx)) |isempty(str2num(par.pxcmy)) 2489 % if isempty(str2num(par.pxcmx)) |isempty(str2num(par.pxcmy)) 2490 2490 % par.pxcmx='1'; 2491 2491 % par.pxcmy='1'; … … 2515 2515 %changes : filename_cmx -> filename ( no extension ) 2516 2516 2517 2518 2519 end2520 2517 if isequal(par.Dt,'0') 2518 par.Dt='1' ;%case of 'displacement' mode 2519 end 2520 2521 2521 textcmx={'############## CMX file';... 2522 2522 ['FirstImage ' par.filename_ima_a];... … … 2555 2555 % timeL2=clock; 2556 2556 % timciv1=etime(timeL2,timeL1) 2557 if sge 2557 if sge 2558 2558 cmd_CIV1=[civ1_exe ' -f ' filename '.cmx' ]; % redirect standard output to the log file 2559 2559 else … … 2561 2561 end 2562 2562 if(isunix) 2563 2564 2565 2563 [Rootbat,Filebat,extbat]=fileparts(namelog); 2564 ncName=fullfile(Rootbat,[ Filebat '.nc']); 2565 cmd_CIV1=char({cmd_CIV1 ; ['mv ' namelog ' ' namelog '.civ1.log'];['chmod g+w ' ncName]}); 2566 2566 else 2567 2567 cmd_CIV1=char({cmd_CIV1 ; ['copy /Y ' namelog ' ' namelog '.civ1.log']}); … … 2577 2577 civ1.image1=par.filename_ima_a; 2578 2578 civ1.image2=par.filename_ima_b; 2579 civ1.imageSize_X=par.npx; 2579 civ1.imageSize_X=par.npx; 2580 2580 civ1.imageSize_Y=par.npy; 2581 2581 civ1.outputFileName=[filename '.nc']; … … 2602 2602 civ1.pixcmy=par.pxcmy; 2603 2603 civ1.convectFlow='n'; 2604 2604 2605 2605 xml_civ1_parameters=civ1; 2606 2606 2607 2607 %--------------------------------------------------------- 2608 2608 %CIV2 CIV2 CIV2 CIV2 … … 2613 2613 if isequal(par.Dt,'0') 2614 2614 par.Dt='1' ;%case of 'displacement' mode 2615 end 2615 end 2616 2616 textcmx={'############## CMX file';... 2617 2617 ['FirstImage ' par.filename_ima_a];... … … 2620 2620 ['Mask ' par.maskflag];... 2621 2621 ['MaskName ' par.maskname];... 2622 ['ImageSize ' par.npx ' ' par.npy];... 2622 ['ImageSize ' par.npx ' ' par.npy];... 2623 2623 ['CorrelationBoxesSize ' par.ibx ' ' par.iby];... 2624 2624 ['SearchBoxeSize ' par.ibx ' ' par.iby];... … … 2660 2660 if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC') 2661 2661 else 2662 web([helpfile '#civ_3D']) 2662 web([helpfile '#civ_3D']) 2663 2663 end 2664 2664 … … 2675 2675 A=uint16(A); 2676 2676 elseif isequal(nom_type,'raw_SMD') 2677 [fid,message]=fopen(filename,'r'); 2677 [fid,message]=fopen(filename,'r'); 2678 2678 B=fread(fid,Inf,'int16',0,'ieee-le');%read 16 bit binary file 2679 2679 A=(reshape(B,npx,npy))'; %remplissage ligne par ligne avec une matrice colonne ? transposer(uB) pour avoir une matrice ligne … … 2688 2688 A=uint16(A); 2689 2689 end 2690 2690 2691 2691 %---------------------------------------------------------------- 2692 2692 %Executes on carriage return on the time interval dt … … 2718 2718 mode_value=get(handles.mode,'Value'); 2719 2719 mode=mode_list{mode_value}; 2720 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)') 2720 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Di)') 2721 2721 find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files 2722 2722 end … … 2731 2731 mode_value=get(handles.mode,'Value'); 2732 2732 mode=mode_list{mode_value}; 2733 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)') 2733 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)') 2734 2734 find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files 2735 2735 end … … 2747 2747 browse.nom_type_ima1=browse.nom_type_ima; 2748 2748 set(handles.browse_root,'UserData',browse); 2749 set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible 2749 set(handles.displ_filebase2,'Visible','On');%mkes the second file input window visible 2750 2750 set(handles.displ_filebase2,'String',filebase); 2751 2751 mode_store=get(handles.mode,'String');%get the present 'mode' … … 2772 2772 '*.*', 'All Files (*.*)'}, ... 2773 2773 'Pick a file',filebase); 2774 2774 2775 2775 fileinput=[PathName FileName]; 2776 2776 sizf=size(fileinput); … … 2820 2820 set(handles.thresh_vel,'String','1');%default threshold 2821 2821 set(handles.ref_fix1,'Enable','on') 2822 2822 2823 2823 %--------------------------------------------------------------- 2824 2824 % --- Executes on button press in get_ref_fix2. … … 2850 2850 % [path,name]=fileparts(ref.filebase); 2851 2851 set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); 2852 set(handles.ref_fix2,'UserData',ref) 2852 set(handles.ref_fix2,'UserData',ref) 2853 2853 menu_field{1}='civ1'; 2854 2854 % [cte_detect,vdt,cte_read]=read_netcdf(fileinput,{'patch','civ2','patch2'}); … … 2893 2893 set(handles.ref_fix1,'String',''); 2894 2894 set(handles.thresh_vel1,'String','0'); 2895 2895 2896 2896 2897 2897 %------------------------------------------------------ … … 3092 3092 3093 3093 3094 %'name2display': extracts the root name and field numbers from an input filename 3094 %'name2display': extracts the root name and field numbers from an input filename 3095 3095 %-------------------------------------------------------------------- 3096 3096 %[RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput) … … 3161 3161 last=double(last_str);%corresponding ascii code 3162 3162 penult=double(RootFile(indcur-1));%ascii code of the penultimate character 3163 testsub=0; %default 3163 testsub=0; %default 3164 3164 % % case of an indexed series in a single file 3165 3165 % if strcmpi(ext,'.avi') … … 3168 3168 % %the penultimate character is a number and the last one a letter (lower case: last >= 97 && last <= 122 3169 3169 % % capital 3170 % % letter: last >= 65 && last <= 90) 3170 % % letter: last >= 65 && last <= 90) 3171 3171 if penult >= 48 && penult <= 57 && ((last >= 65 && last <= 90)||(last >= 97 && last <= 122)) 3172 3172 str_a=last_str; %extract appendix a,b,c... or A,B,C... as output. … … 3185 3185 else 3186 3186 nom_type=[nom_type 'a']; 3187 end 3187 end 3188 3188 elseif strcmp(filelit(end-2:end),'-_-_')%new nomenclature appendix num1-num2_num_a-num_b 3189 3189 field_count=num0; … … 3201 3201 testsub=1; 3202 3202 indcur=separ1-1; 3203 elseif strcmp(filelit(end-2:end),'__-')%new nomenclature appendix num1_num2-num2 3203 elseif strcmp(filelit(end-2:end),'__-')%new nomenclature appendix num1_num2-num2 3204 3204 indcur=separ1-1; 3205 3205 field_count=num1; … … 3231 3231 elseif RootFile(indcur-2)=='_'% search appendix a,b,c,d 3232 3232 lasts=RootFile(indcur-1:indcur); 3233 % if isequal(length(last),2) 3233 % if isequal(length(last),2) 3234 3234 str_a=lasts(1);%put appendix a,b,c, ou d 3235 3235 str_b=lasts(2);%put appendix a,b,c, ou d … … 3237 3237 field_count=RootFile(separ0+1:separ1-1); 3238 3238 indcur=separ0; 3239 if double(lasts) >= 97 & double(lasts)<= 122 3239 if double(lasts) >= 97 & double(lasts)<= 122 3240 3240 nom_type='_ab'; 3241 3241 testsub=1; 3242 elseif double(lasts) >= 65 & double(lasts) <= 90 3242 elseif double(lasts) >= 65 & double(lasts) <= 90 3243 3243 nom_type='_AB'; 3244 3244 testsub=1; … … 3249 3249 %search for other names with counter 3250 3250 else 3251 if length(ext)>1 3251 if length(ext)>1 3252 3252 num=1;count=0; % extract the numerical appendix 3253 3253 while num==1; 3254 3254 filascii=double(RootFile(indcur)); 3255 3255 if (48>filascii)||(filascii>57); % select the non-numerical characters 3256 num=0; 3256 num=0; 3257 3257 else 3258 3258 indcur=indcur-1; count=count+1; 3259 3259 end 3260 3260 end 3261 if count~=0 3261 if count~=0 3262 3262 field_count=RootFile(indcur+1:indcur+count);% set the selected field number'%03d' 3263 3263 charstring=['%0' num2str(length(field_count)) 'd']; -
trunk/src/toolbox_calib/init_intrinsic_param.m
r926 r999 9 9 %OUTPUT: fc: Camera focal length 10 10 % cc: Principal point coordinates 11 % 11 % kc: Distortion coefficients 12 12 % alpha_c: skew coefficient 13 13 % KK: The camera matrix (containing fc, cc and alpha_c) … … 89 89 90 90 for kk=1:n_ima, 91 91 92 92 if active_images(kk), 93 93 94 94 eval(['Hkk = H_' num2str(kk) ';']); 95 96 Hkk = Sub_cc * Hkk; 97 95 96 Hkk = Sub_cc * Hkk; 97 98 98 % Extract vanishing points (direct and diagonals): 99 99 100 100 V_hori_pix = Hkk(:,1); 101 101 V_vert_pix = Hkk(:,2); 102 102 V_diag1_pix = (Hkk(:,1)+Hkk(:,2))/2; 103 103 V_diag2_pix = (Hkk(:,1)-Hkk(:,2))/2; 104 104 105 105 V_hori_pix = V_hori_pix/norm(V_hori_pix); 106 106 V_vert_pix = V_vert_pix/norm(V_vert_pix); 107 107 V_diag1_pix = V_diag1_pix/norm(V_diag1_pix); 108 108 V_diag2_pix = V_diag2_pix/norm(V_diag2_pix); 109 109 110 110 a1 = V_hori_pix(1); 111 111 b1 = V_hori_pix(2); 112 112 c1 = V_hori_pix(3); 113 113 114 114 a2 = V_vert_pix(1); 115 115 b2 = V_vert_pix(2); 116 116 c2 = V_vert_pix(3); 117 117 118 118 a3 = V_diag1_pix(1); 119 119 b3 = V_diag1_pix(2); 120 120 c3 = V_diag1_pix(3); 121 121 122 122 a4 = V_diag2_pix(1); 123 123 b4 = V_diag2_pix(2); 124 124 c4 = V_diag2_pix(3); 125 125 126 126 A_kk = [a1*a2 b1*b2; 127 127 a3*a4 b3*b4]; 128 128 129 129 b_kk = -[c1*c2;c3*c4]; 130 131 130 131 132 132 A = [A;A_kk]; 133 133 b = [b;b_kk]; 134 134 135 135 end; 136 136 137 137 end; 138 138 … … 148 148 end; 149 149 150 150 151 151 152 152 if two_focals_init … … 185 185 fprintf(1,'Principal point: cc = [ %3.5f %3.5f ]\n',cc); 186 186 fprintf(1,'Skew: alpha_c = [ %3.5f ] => angle of pixel = %3.5f degrees\n',alpha_c,90 - atan(alpha_c)*180/pi); 187 fprintf(1,'Distortion: kc = [ %3.5f %3.5f %3.5f %3.5f %5.5f ]\n',kc); 187 fprintf(1,'Distortion: kc = [ %3.5f %3.5f %3.5f %3.5f %5.5f ]\n',kc); -
trunk/src/toolbox_calib/normalize_pixel.m
r926 r999 41 41 42 42 if norm(kc) ~= 0, 43 44 43 % Third: Compensate for lens distortion: 44 xn = comp_distortion_oulu(x_distort,kc); 45 45 else 46 46 xn = x_distort;
Note: See TracChangeset
for help on using the changeset viewer.