- Timestamp:
- Apr 6, 2022, 8:36:16 PM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_field_cells.m
r1107 r1115 162 162 cell_counter=cell_counter+1; 163 163 icell=cell_counter; 164 CellInfo{icell}.FieldName=Data.ListVarName{ind_scalar(iscalar)}; 164 165 CellInfo{icell}.VarType='scalar'; 165 166 DimCell{icell}=Data.VarDimName{ind_scalar(iscalar)}; -
trunk/src/geometry_calib.m
r1113 r1115 122 122 123 123 %% set menu of calibration options 124 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_ extrinsic'})124 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_order4';'3D_extrinsic'}) 125 125 if exist('inputfile','var')&& ~isempty(inputfile) 126 126 [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile); … … 232 232 233 233 %% Apply calibration 234 [GeometryCalib,index,ind_removed]=calibrate(Coord,CalibFcn,Intrinsic);% apply calibration 234 est_dist=[0;0;0;0;0]; %default 235 switch CalibFcn 236 case 'calib_3D_linear' 237 CalibFcn='calib_3D'; 238 case 'calib_3D_quadr' 239 est_dist=[1;0;0;0;0]; 240 CalibFcn='calib_3D' 241 case 'calib_3D_order4' 242 est_dist=[1;1;0;0;0]; 243 CalibFcn='calib_3D' 244 end 245 246 [GeometryCalib,index,ind_removed]=calibrate(Coord,CalibFcn,est_dist,Intrinsic);% apply calibration 235 247 if isempty(GeometryCalib) 236 248 return … … 393 405 %------------------------------------------------------------------------ 394 406 % --- activate calibration and store parameters in ouputfile . 395 function [GeometryCalib,ind_max,ind_removed]=calibrate(Coord,CalibFcn, Intrinsic)407 function [GeometryCalib,ind_max,ind_removed]=calibrate(Coord,CalibFcn,est_dist,Intrinsic) 396 408 %------------------------------------------------------------------------ 397 409 … … 403 415 CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours 404 416 if ~isempty(Coord) 405 GeometryCalib=feval(CalibFcn,CoordFlip, Intrinsic);417 GeometryCalib=feval(CalibFcn,CoordFlip,est_dist,Intrinsic); 406 418 else 407 419 msgbox_uvmat('ERROR','No calibration points, abort') … … 433 445 CoordFlip=Coord; 434 446 CoordFlip(:,3)=Coord(:,3);% the calibration function assume a z ccordinate along the camera view, opposite to ours 435 GeometryCalib=feval(CalibFcn,CoordFlip, Intrinsic);447 GeometryCalib=feval(CalibFcn,CoordFlip,est_dist,Intrinsic); 436 448 X=Coord(:,1); 437 449 Y=Coord(:,2); … … 448 460 %------------------------------------------------------------------------ 449 461 % --- determine the parameters for a calibration by an affine function (rescaling and offset, no rotation) 450 function GeometryCalib=calib_rescale(Coord, Intrinsic)462 function GeometryCalib=calib_rescale(Coord,est_dist,Intrinsic) 451 463 %------------------------------------------------------------------------ 452 464 X=Coord(:,1); … … 464 476 %------------------------------------------------------------------------ 465 477 % --- determine the parameters for a calibration by a linear transform matrix (rescale and rotation) 466 function GeometryCalib=calib_linear(Coord, Intrinsic)478 function GeometryCalib=calib_linear(Coord,est_dist,Intrinsic) 467 479 %------------------------------------------------------------------------ 468 480 X=Coord(:,1); … … 494 506 % --- determine the tsai parameters for a view normal to the grid plane 495 507 % NOT USED 496 function GeometryCalib=calib_normal(Coord, Intrinsic)508 function GeometryCalib=calib_normal(Coord,est_dist,Intrinsic) 497 509 %------------------------------------------------------------------------ 498 510 Calib.fx=str2num(get(handles.fx,'String')); … … 555 567 alpha=calib_param(5); 556 568 GeometryCalib.R=[cos(alpha) sin(alpha) 0;-sin(alpha) cos(alpha) 0;0 0 -1]; 557 558 % ------------------------------------------------------------------------559 function GeometryCalib=calib_3D_linear(Coord,Intrinsic)560 % ------------------------------------------------------------------------561 coord_files=Intrinsic.coord_files;562 if ischar(Intrinsic.coord_files)563 coord_files={coord_files};564 end565 if isempty(coord_files{1}) || isequal(coord_files,{''})566 coord_files={};567 end568 % retrieve the calibration points stored in the files listed in the popup list ListCoordFiles569 x_1=Coord(:,4:5)';%px coordinates of the ref points570 571 nx=Intrinsic.Npx;572 ny=Intrinsic.Npy;573 x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates574 X_1=Coord(:,1:3)';%phys coordinates of the ref points575 n_ima=numel(coord_files)+1;576 if ~isempty(coord_files)577 msgbox_uvmat('CONFIRMATION',['The xy coordinates of the calibration points in ' num2str(n_ima) ' planes will be used'])578 for ifile=1:numel(coord_files)579 t=xmltree(coord_files{ifile});580 s=convert(t);%convert to matlab structure581 if isfield(s,'GeometryCalib')582 if isfield(s.GeometryCalib,'SourceCalib')583 if isfield(s.GeometryCalib.SourceCalib,'PointCoord')584 PointCoord=s.GeometryCalib.SourceCalib.PointCoord;585 Coord_file=zeros(length(PointCoord),5);%default586 for i=1:length(PointCoord)587 line=str2num(PointCoord{i});588 Coord_file(i,4:5)=line(4:5);%px x589 Coord_file(i,1:3)=line(1:3);%phys x590 end591 eval(['x_' num2str(ifile+1) '=Coord_file(:,4:5)'';']);592 eval(['x_' num2str(ifile+1) '(2,:)=ny-x_' num2str(ifile+1) '(2,:);' ]);593 eval(['X_' num2str(ifile+1) '=Coord_file(:,1:3)'';']);594 end595 end596 end597 end598 end599 n_ima=numel(coord_files)+1;600 est_dist=[0;0;0;0;0];601 est_aspect_ratio=0;602 est_fc=[1;1];603 center_optim=0;604 path_uvmat=which('uvmat');% check the path detected for source file uvmat605 path_UVMAT=fileparts(path_uvmat); %path to UVMAT606 run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim'607 if exist('Rc_1','var')608 GeometryCalib.CalibrationType='3D_extrinsic';609 GeometryCalib.fx_fy=fc';610 GeometryCalib.Cx_Cy=cc';611 GeometryCalib.kc=kc(1);612 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function613 GeometryCalib.Tx_Ty_Tz=Tc_1';614 GeometryCalib.R=Rc_1;615 GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate616 GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate617 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate618 GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees619 GeometryCalib.ErrorRMS=[];620 GeometryCalib.ErrorMax=[];621 else622 msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic'])623 GeometryCalib=[];624 end625 626 %------------------------------------------------------------------------ 627 function GeometryCalib=calib_3D _quadr(Coord,Intrinsic)569 % 570 % %------------------------------------------------------------------------ 571 % function GeometryCalib=calib_3D_linear(Coord,Intrinsic) 572 % %------------------------------------------------------------------------ 573 % coord_files=Intrinsic.coord_files; 574 % if ischar(Intrinsic.coord_files) 575 % coord_files={coord_files}; 576 % end 577 % if isempty(coord_files{1}) || isequal(coord_files,{''}) 578 % coord_files={}; 579 % end 580 % %retrieve the calibration points stored in the files listed in the popup list ListCoordFiles 581 % x_1=Coord(:,4:5)';%px coordinates of the ref points 582 % 583 % nx=Intrinsic.Npx; 584 % ny=Intrinsic.Npy; 585 % x_1(2,:)=ny-x_1(2,:);%reverse the y image coordinates 586 % X_1=Coord(:,1:3)';%phys coordinates of the ref points 587 % n_ima=numel(coord_files)+1; 588 % if ~isempty(coord_files) 589 % msgbox_uvmat('CONFIRMATION',['The xy coordinates of the calibration points in ' num2str(n_ima) ' planes will be used']) 590 % for ifile=1:numel(coord_files) 591 % t=xmltree(coord_files{ifile}); 592 % s=convert(t);%convert to matlab structure 593 % if isfield(s,'GeometryCalib') 594 % if isfield(s.GeometryCalib,'SourceCalib') 595 % if isfield(s.GeometryCalib.SourceCalib,'PointCoord') 596 % PointCoord=s.GeometryCalib.SourceCalib.PointCoord; 597 % Coord_file=zeros(length(PointCoord),5);%default 598 % for i=1:length(PointCoord) 599 % line=str2num(PointCoord{i}); 600 % Coord_file(i,4:5)=line(4:5);%px x 601 % Coord_file(i,1:3)=line(1:3);%phys x 602 % end 603 % eval(['x_' num2str(ifile+1) '=Coord_file(:,4:5)'';']); 604 % eval(['x_' num2str(ifile+1) '(2,:)=ny-x_' num2str(ifile+1) '(2,:);' ]); 605 % eval(['X_' num2str(ifile+1) '=Coord_file(:,1:3)'';']); 606 % end 607 % end 608 % end 609 % end 610 % end 611 % n_ima=numel(coord_files)+1; 612 % est_dist=[0;0;0;0;0]; 613 % est_aspect_ratio=0; 614 % est_fc=[1;1]; 615 % center_optim=0; 616 % path_uvmat=which('uvmat');% check the path detected for source file uvmat 617 % path_UVMAT=fileparts(path_uvmat); %path to UVMAT 618 % run(fullfile(path_UVMAT,'toolbox_calib','go_calib_optim'));% apply fct 'toolbox_calib/go_calib_optim' 619 % if exist('Rc_1','var') 620 % GeometryCalib.CalibrationType='3D_extrinsic'; 621 % GeometryCalib.fx_fy=fc'; 622 % GeometryCalib.Cx_Cy=cc'; 623 % GeometryCalib.kc=kc(1); 624 % GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function 625 % GeometryCalib.Tx_Ty_Tz=Tc_1'; 626 % GeometryCalib.R=Rc_1; 627 % GeometryCalib.R(2,1:3)=-GeometryCalib.R(2,1:3);%inversion of the y image coordinate 628 % GeometryCalib.Tx_Ty_Tz(2)=-GeometryCalib.Tx_Ty_Tz(2);%inversion of the y image coordinate 629 % GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%inversion of the y image coordinate 630 % GeometryCalib.omc=(180/pi)*omc_1;%angles in degrees 631 % GeometryCalib.ErrorRMS=[]; 632 % GeometryCalib.ErrorMax=[]; 633 % else 634 % msgbox_uvmat('ERROR',['calibration function ' fullfile('toolbox_calib','go_calib_optim') ' did not converge: use multiple views or option 3D_extrinsic']) 635 % GeometryCalib=[]; 636 % end 637 638 %------------------------------------------------------------------------ 639 function GeometryCalib=calib_3D(Coord,est_dist,Intrinsic) 628 640 %------------------------------------------------------------------ 629 641 … … 678 690 end 679 691 n_ima=numel(coord_files)+1; 680 est_dist=[1;0;0;0;0];692 %est_dist=[1;0;0;0;0]; 681 693 est_aspect_ratio=1; 682 694 center_optim=0; … … 687 699 GeometryCalib.fx_fy=fc'; 688 700 GeometryCalib.Cx_Cy=cc'; 689 GeometryCalib.kc=kc(1); 701 ind_kc=find(kc); 702 if ~isempty(ind_kc) 703 GeometryCalib.kc=(kc(ind_kc))';%include cases quadr (one value kc(1)) and order_4 (2 values for kc) 704 end 690 705 GeometryCalib.CoordUnit=[];% default value, to be updated by the calling function 691 706 GeometryCalib.Tx_Ty_Tz=Tc_1'; … … 703 718 704 719 %------------------------------------------------------------------------ 705 function GeometryCalib=calib_3D_extrinsic(Coord, Intrinsic)720 function GeometryCalib=calib_3D_extrinsic(Coord,est_dist, Intrinsic) 706 721 %------------------------------------------------------------------ 707 722 path_uvmat=which('geometry_calib');% check the path detected for source file uvmat … … 747 762 addpath(fct_path) 748 763 GeometryCalib.Cx_Cy(2)=ny-GeometryCalib.Cx_Cy(2);%reverse Cx_Cy(2) for calibration (inversion of px ordinate) 764 kc=zeros(1,5); 765 kc(1:numel(GeometryCalib.kc))=GeometryCalib.kc; 749 766 [omc,Tc1,Rc1,H,x,ex,JJ] = compute_extrinsic(x_1,X_1,... 750 (GeometryCalib.fx_fy)',GeometryCalib.Cx_Cy', [GeometryCalib.kc 0 0 0 0]);767 (GeometryCalib.fx_fy)',GeometryCalib.Cx_Cy',kc); 751 768 rmpath(fct_path); 752 GeometryCalib.CoordUnit= [];% default value, to be updated by the calling function769 GeometryCalib.CoordUnit='';% default value, to be updated by the calling function 753 770 GeometryCalib.Tx_Ty_Tz=Tc1'; 754 771 %inversion of z axis … … 1086 1103 Tmod(:,2)=(TIndex(:,2)-1)*Dy+Rangy(1); 1087 1104 %Tmod=T(:,(1:2))+Delta;% 'phys' coordinates of the detected points 1088 [Xpx,Ypx]=px_XYZ(GeometryCalib, Tmod(:,1),Tmod(:,2));% image coordinates of the detected points1105 [Xpx,Ypx]=px_XYZ(GeometryCalib,[],Tmod(:,1),Tmod(:,2));% image coordinates of the detected points 1089 1106 Coord=[T Xpx Ypx zeros(size(T,1),1)]; 1090 1107 set(handles.ListCoord,'Data',Coord) … … 1326 1343 set(handles.Cx,'String',num2str(Cx_Cy(1),'%1.1f')) 1327 1344 set(handles.Cy,'String',num2str(Cx_Cy(2),'%1.1f')) 1328 set(handles.kc,'String',num2str(kc,'%1.4f')) 1345 %set(handles.kc,'String',num2str(kc,'%1.4f')) 1346 set(handles.kc,'String',num2str(kc,4)) 1329 1347 1330 1348 %------------------------------------------------------------------------ -
trunk/src/phys_XYZ.m
r1113 r1115 74 74 Calib.Cx_Cy=[0 0]; 75 75 end 76 if ~isfield(Calib,'kc') 77 Calib.kc=0; 76 kc=[0 0]; 77 if isfield(Calib,'kc') 78 kc(1:numel(Calib.kc))=Calib.kc; 78 79 end 80 % if ~isfield(Calib,'kc2') 81 % Calib.kc2=0; 82 % end 79 83 if isfield(Calib,'R') 80 84 R=(Calib.R)'; 81 % R(3)=-R(3);82 % R(6)=-R(6);83 % R(9)=-R(9);84 85 c=Z0virt; 85 86 cvirt=Z0virt; … … 126 127 Xd=(X-Calib.Cx_Cy(1))/Calib.fx_fy(1); % sensor coordinates 127 128 Yd=(Y-Calib.Cx_Cy(2))/Calib.fx_fy(2); 128 dist_fact=1+ Calib.kc*(Xd.*Xd+Yd.*Yd);% distortion factor, first approximation Xu,Yu=Xd,Yd129 dist_fact=1+kc(1)*(Xd.*Xd+Yd.*Yd);% distortion factor, first approximation Xu,Yu=Xd,Yd 129 130 test=0; 130 131 niter=0; … … 133 134 Xu=Xd./dist_fact;%undistorted sensor coordinates, second iteration 134 135 Yu=Yd./dist_fact; 135 dist_fact=1+Calib.kc*(Xu.*Xu+Yu.*Yu);% distortion factor,next approximation 136 R2=Xu.*Xu+Yu.*Yu; 137 dist_fact=1+kc(1)*R2+kc(2)*R2.*R2;% distortion factor,next approximation 136 138 test=max(max(abs(dist_fact-dist_fact_old)))<0.00001; % reducing the relative error to 10^-5 forthe inversion of the quadraticcorrection 137 139 niter=niter+1; -
trunk/src/proj_field.m
r1114 r1115 1095 1095 end 1096 1096 else 1097 ProjData.ProjObjectAngle=FieldData.PlaneAngle; 1097 ProjData.ProjObjectAngle=FieldData.PlaneAngle;ProjMode 1098 1098 end 1099 1099 end … … 1125 1125 icell_grid=[];% field cell index which defines the grid 1126 1126 icell_scattered=[];% field cell index which defines fields with scattered coordinates 1127 for icell=1:numel(CellInfo)1128 if strcmp(ObjectData.ProjMode,'interp_lin')&& ~strcmp(ProjMode{icell},'interp_tps')1129 errormsg='ProjMode interp_tps needed ';1130 return1131 end1132 end1127 % for icell=1:numel(CellInfo) 1128 % if strcmp(ObjectData.ProjMode,'interp_lin')&& ~strcmp(ProjMode{icell},'interp_tps') 1129 % errormsg='ProjMode interp_tps needed '; 1130 % return 1131 % end 1132 % end 1133 1133 if strcmp(ObjectData.ProjMode,'projection') 1134 1134 %% case of a grid requested by the input field -
trunk/src/px_XYZ.m
r1113 r1115 69 69 if ~isfield(Calib,'kc') 70 70 r2=1; %no quadratic distortion 71 elseif numel(Calib.kc)==1 72 r2=1+Calib.kc*(Xu.*Xu+Yu.*Yu); 71 73 else 72 r2=1+Calib.kc*(Xu.*Xu+Yu.*Yu); 74 R2=Xu.*Xu+Yu.*Yu; 75 r2=1+Calib.kc(1)*R2+Calib.kc(2)*R2.*R2; 73 76 end 74 77 -
trunk/src/series/civ_series.m
r1107 r1115 628 628 ind_good=1:numel(Data.Civ1_X); 629 629 end 630 630 if isempty(ind_good) 631 disp_uvmat('ERROR','all vectors of civ1 are bad, check input parameters' ,checkrun) 632 return 633 end 634 631 635 % perform Patch calculation using the UVMAT fct 'filter_tps' 632 636 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... … … 919 923 else 920 924 ind_good=1:numel(Data.Civ2_X); 925 end 926 if isempty(ind_good) 927 disp_uvmat('ERROR','all vectors of civ2 are bad, check input parameters' ,checkrun) 928 return 921 929 end 922 930 [Data.Civ2_SubRange,Data.Civ2_NbCentres,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures,Vres,tild,FFres]=... -
trunk/src/series/merge_proj.m
r1114 r1115 86 86 return 87 87 end 88 88 if 0==1 89 phys; % used to include phys when compiling is done 90 end 89 91 %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% 90 92 ParamOut=[]; %default output -
trunk/src/series/turb_stat.m
r1107 r1115 204 204 % for i_slice=1:Param.IndexRange.NbSlice 205 205 % i_slice 206 ind_first=Param.IndexRange.first_i 206 ind_first=Param.IndexRange.first_i; 207 207 for index_i=ind_first:Param.IndexRange.NbSlice:Param.IndexRange.last_i 208 208 if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') … … 210 210 break 211 211 end 212 for index_j= Param.IndexRange.first_j:Param.IndexRange.last_j212 for index_j=first_j:last_j 213 213 InputFile=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},index_i,index_i,index_j,index_j); 214 214 [Field,tild,errormsg] = read_field(InputFile,FileType{iview},InputFields{iview}); … … 217 217 218 218 %%%%%%%%%%%% MAIN RUNNING OPERATIONS %%%%%%%%%%%% 219 if index_i==ind_first && index_j== Param.IndexRange.first_j %initiate the output data structure in the first field219 if index_i==ind_first && index_j==first_j %initiate the output data structure in the first field 220 220 [CellInfo,NbDim,errormsg]=find_field_cells(Field); 221 221 YName='coord_y';%default
Note: See TracChangeset
for help on using the changeset viewer.