Changeset 542 for trunk/src/px_XYZ.m
 Timestamp:
 Sep 15, 2012, 7:04:56 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/px_XYZ.m
r114 r542 11 11 12 12 function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys) 13 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z14 % Zindex=Z;15 % planepos=Calib.PlanePos{Zindex};16 % zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE17 % else18 % zphys=0;19 % end20 13 if ~exist('Zphys','var') 21 14 Zphys=0; … … 27 20 Calib.Tx_Ty_Tz=[0 0 1]; 28 21 end 29 % if ~isfield(Calib,'kappa1')30 % Calib.kappa1=0;31 % end32 % if ~isfield(Calib,'sx')33 % Calib.sx=1;34 % end35 % if ~isfield(Calib,'dpx')36 % Calib.dpx=1;37 % end38 % if ~isfield(Calib,'dpy')39 % Calib.dpy=1;40 % end41 22 42 23 %%%%%%%%%%%%% 24 % general case 43 25 if isfield(Calib,'R') 44 26 R=(Calib.R)'; 27 %correct z for refraction if needed 28 if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex') 29 H=Calib.InterfaceCoord(3); 30 if H>Zphys 31 Zphys=H(HZphys)/Calib.RefractionIndex; %corrected z (virtual object) 32 test_refraction=1; 33 end 34 end 35 45 36 %camera coordinates 46 37 xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1); 47 38 yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2); 48 39 zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3); 49 %undistorted image coordinates 40 41 %undistorted image coordinates 50 42 Xu=xc./zc; 51 43 Yu=yc./zc; 52 %radial quadratic correction factor 44 45 %radial quadratic correction factor 53 46 if ~isfield(Calib,'kc') 54 47 r2=1; %no quadratic distortion … … 56 49 r2=1+Calib.kc*(Xu.*Xu+Yu.*Yu); 57 50 end 58 %pixel coordinates 51 52 %pixel coordinates 59 53 if ~isfield(Calib,'Cx_Cy') 60 54 Calib.Cx_Cy=[0 0];%default value 61 55 end 62 56 X=Calib.fx_fy(1)*Xu.*r2+Calib.Cx_Cy(1); 63 Y=Calib.fx_fy(2)*Yu.*r2+Calib.Cx_Cy(2); 64 %OLD CONVENTION (Wilson)undistorted image coordinates 65 % Xu=Calib.f*xc./zc; 66 % Yu=Calib.f*yc./zc; 67 % %distorted image coordinates 68 % distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR 69 % % distortion=1; 70 % Xd=Xu./distortion; 71 % Yd=Yu./distortion; 72 % %pixel coordinates 73 % X=Xd*Calib.sx/Calib.dpx+Calib.Cx; 74 % Y=Yd/Calib.dpy+Calib.Cy; 75 else %case 'rescale' 57 Y=Calib.fx_fy(2)*Yu.*r2+Calib.Cx_Cy(2); 58 59 %case 'rescale' 60 else 76 61 X=Calib.fx_fy(1)*(Xphys+Calib.Tx_Ty_Tz(1)); 77 62 Y=Calib.fx_fy(2)*(Yphys+Calib.Tx_Ty_Tz(2));
Note: See TracChangeset
for help on using the changeset viewer.