Changeset 878 for trunk/src/series/civ2vel_3C.m
 Timestamp:
 Feb 23, 2015, 10:17:04 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/civ2vel_3C.m
r864 r878 169 169 %% MAIN LOOP ON FIELDS 170 170 warning off 171 if NbField<2 && length(filecell{:,1})>2171 if NbField<2 172 172 disp_uvmat('ERROR','you need at least 2 images to compute the mean position for the stereo.',checkrun) 173 173 return … … 285 285 end 286 286 ZI=mean(ZItemp,3); %mean between two the two time step 287 Vtest=ZItemp(:,:,2)ZItemp(:,:,1); 287 288 288 289 [Xa,Ya]=px_XYZ(XmlData{1}.GeometryCalib,XI,YI,ZI);% set of image coordinates on view a 289 290 [Xb,Yb]=px_XYZ(XmlData{2}.GeometryCalib,XI,YI,ZI);% set of image coordinates on view b 290 291 291 %trouver z 292 % trouver les coordonnées px sur chaque image. 293 %A= 292 294 293 for iview=1:2 295 294 %% reading input file(s) … … 322 321 Ua=griddata(X1,Y1,U1,Xa,Ya); 323 322 Va=griddata(X1,Y1,V1,Xa,Ya); 324 A=get_coeff(XmlData{1}.GeometryCalib,Xa,Ya,YI,YI,ZI); 325 326 323 324 [Ua,Va,Xa,Ya]=Ud2U(XmlData{1}.GeometryCalib,Xa,Ya,Ua,Va); % convert Xd data to X 325 [A]=get_coeff(XmlData{1}.GeometryCalib,Xa,Ya,XI,YI,ZI); %get coef A~ 326 327 %remove wrong vector 327 328 temp=find(Data{2}.FF==0); 328 329 X2=Data{2}.X(temp); … … 332 333 Ub=griddata(X2,Y2,U2,Xb,Yb); 333 334 Vb=griddata(X2,Y2,V2,Xb,Yb); 334 B=get_coeff(XmlData{2}.GeometryCalib,Xb,Yb,YI,YI,ZI); 335 336 [Ub,Vb,Xb,Yb]=Ud2U(XmlData{2}.GeometryCalib,Xb,Yb,Ub,Vb); % convert Xd data to X 337 [B]=get_coeff(XmlData{2}.GeometryCalib,Xb,Yb,XI,YI,ZI); %get coef B~ 338 339 340 % System to solve 335 341 S=ones(size(XI,1),size(XI,2),3); 336 342 D=ones(size(XI,1),size(XI,2),3,3); 343 337 344 S(:,:,1)=A(:,:,1,1).*Ua+A(:,:,2,1).*Va+B(:,:,1,1).*Ub+B(:,:,2,1).*Vb; 338 345 S(:,:,2)=A(:,:,1,2).*Ua+A(:,:,2,2).*Va+B(:,:,1,2).*Ub+B(:,:,2,2).*Vb; … … 349 356 for indj=1:size(XI,1) 350 357 for indi=1:size(XI,2) 351 dxyz= squeeze(S(indj,indi,:))\squeeze(D(indj,indi,:,:));358 dxyz=(squeeze(D(indj,indi,:,:))*1000)\(squeeze(S(indj,indi,:))*1000); % solving... 352 359 U(indj,indi)=dxyz(1); 353 360 V(indj,indi)=dxyz(2); … … 360 367 Error(:,:,3)=B(:,:,1,1).*U+B(:,:,1,2).*V+B(:,:,1,3).*WUb; 361 368 Error(:,:,4)=B(:,:,2,1).*U+B(:,:,2,2).*V+B(:,:,2,3).*WVb; 369 370 371 362 372 363 373 %% generating the name of the merged field … … 396 406 MergeData.V=V/Dt; 397 407 MergeData.W=W/Dt; 398 MergeData.Error=sqrt(sum(Error.*Error,3)); 408 409 mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2; 410 mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2; 411 MergeData.Error=(sqrt(mfx^2+mfy^2)/4).*sqrt(sum(Error.*Error,3)); 399 412 errormsg=struct2nc(OutputFile,MergeData);%save result file 400 413 if isempty(errormsg) … … 406 419 407 420 408 function A=get_coeff(Calib,X,Y,x,y,z)421 function [A]=get_coeff(Calib,X,Y,x,y,z) % compute A~ coefficients 409 422 R=(Calib.R)';%rotation matrix 410 423 T_z=Calib.Tx_Ty_Tz(3); 411 424 T=R(7)*x+R(8)*y+R(9)*z+T_z; 425 412 426 A(:,:,1,1)=(R(1)R(7)*X)./T; 413 427 A(:,:,1,2)=(R(2)R(8)*X)./T; … … 417 431 A(:,:,2,3)=(R(6)R(9)*Y)./T; 418 432 419 420 421 422 function [z,Xphy,Yphy,error]=shift2z(xmid, ymid, u, v,XmlData) 433 function [U,V,X,Y]=Ud2U(Calib,Xd,Yd,Ud,Vd) % convert Xd to X and Ud to U 434 435 X1d=XdUd/2; 436 X2d=Xd+Ud/2; 437 Y1d=YdVd/2; 438 Y2d=Yd+Vd/2; 439 440 X1=(X1dCalib.Cx_Cy(1))./Calib.fx_fy(1).*(1 + Calib.kc.*Calib.fx_fy(1).^(2).*(X1dCalib.Cx_Cy(1)).^2 + Calib.kc.*Calib.fx_fy(2).^(2).*(Y1dCalib.Cx_Cy(2)).^2 ).^(1); 441 X2=(X2dCalib.Cx_Cy(1))./Calib.fx_fy(1).*(1 + Calib.kc.*Calib.fx_fy(1).^(2).*(X2dCalib.Cx_Cy(1)).^2 + Calib.kc.*Calib.fx_fy(2).^(2).*(Y2dCalib.Cx_Cy(2)).^2 ).^(1); 442 Y1=(Y1dCalib.Cx_Cy(2))./Calib.fx_fy(2).*(1 + Calib.kc.*Calib.fx_fy(1).^(2).*(X1dCalib.Cx_Cy(1)).^2 + Calib.kc.*Calib.fx_fy(2).^(2).*(Y1dCalib.Cx_Cy(2)).^2 ).^(1); 443 Y2=(Y2dCalib.Cx_Cy(2))./Calib.fx_fy(2).*(1 + Calib.kc.*Calib.fx_fy(1).^(2).*(X2dCalib.Cx_Cy(1)).^2 + Calib.kc.*Calib.fx_fy(2).^(2).*(Y2dCalib.Cx_Cy(2)).^2 ).^(1); 444 445 U=X2X1; 446 V=Y2Y1; 447 X=X1+U/2; 448 Y=Y1+V/2; 449 450 451 452 function [z,Xphy,Yphy,error]=shift2z(xmid, ymid, u, v,XmlData) % get H from stereo data 423 453 z=0; 424 454 error=0; … … 429 459 R=(Calib_A.R)'; 430 460 x_a=xmid u/2; 431 y_a=ymid u/2;461 y_a=ymid v/2; 432 462 z_a=R(7)*x_a+R(8)*y_a+Calib_A.Tx_Ty_Tz(1,3); 433 463 Xa=(R(1)*x_a+R(2)*y_a+Calib_A.Tx_Ty_Tz(1,1))./z_a; … … 445 475 446 476 %% second image 477 %loading shift angle 478 447 479 Calib_B=XmlData{2}.GeometryCalib; 448 480 R=(Calib_B.R)'; 481 482 449 483 x_b=xmid+ u/2; 450 484 y_b=ymid+ v/2; … … 464 498 %% result 465 499 Den=(DxbDxa).*(DxbDxa)+(DybDya).*(DybDya); 466 error=((DybDya).*u(DxbDxa).*v)./Den; 500 error=((DybDya).*(u)(DxbDxa).*(v))./Den; 501 % ex=error.*(DybDya); 502 % ey=error.*(DxbDxa); 503 504 % z1=u./(DxbDxa); 505 % z2=v./(DybDya); 506 z=((DxbDxa).*(u)+(DybDya).*(v))./Den; 467 507 468 508 xnew(1,:)=Dxa.*z+x_a; … … 470 510 ynew(1,:)=Dya.*z+y_a; 471 511 ynew(2,:)=Dyb.*z+y_b; 472 473 Xphy=mean(xnew,1); %on moyenne les 2 valeurs474 Yphy=mean(ynew,1); 475 z=((DxbDxa).*u(DybDya).*v)./Den; 476 477 512 Xphy=mean(xnew,1); 513 Yphy=mean(ynew,1); 514 515 516 517
Note: See TracChangeset
for help on using the changeset viewer.