⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gettr.m

📁 一个很好用的摄像机标定程序
💻 M
字号:
function [T, R, errs] = getTR( DLT, Fl, u0, v0, b1, b2, Sp )%DEVELOPMENT PHASE%%  function [T, R] = getTR( DLT, Fl, u0, v0, b1, b2, Sp )%%  decomposes the 3x3 CDLT matrix %%returns%  T - translation matrix%  R - rotation matrix  %  errs - difference between the original CDLT matrix and matrix composed of the decomposed parameters%%parametres%  DLT - 3x3 CDLT matrix%  Fl - focal length%  u0, v0 - coordinates of the principal point%  b1, b2 - linear distortion coefficients F = [Fl, 0, 0; 0, Fl, 0; 0, 0, 1]; V = [1, 0, -u0; 0, 1, -v0; 0, 0, 1];B = [1 + b1, b2, 0; b2, 1 - b1, 0; 0, 0, 1];Q = inv( F ) * B * V * DLT;lam1 = vsize( Q(:,1) );lam2 = vsize( Q(:,2) );lambda = (lam1 + lam2) / 2;M1 = Q(:,1);M2 = Q(:,2);% we have the approximataion first two columns of the rotation matrix% but they are not orthogonalM1 = M1 / lam1;M2 = M2 / lam2;% so we have to make the orthogonal - we will rotate them, but they are in 3DMN = cross( M1, M2 );Ro = dir2rot( MN' );% we transform them into 2DR1 = Ro * M1;R2 = Ro * M2;coAng = dot( R1, R2 );roAng = (acos( coAng ) - pi/2) / 2;if( R1(2,1) > R2(2,1) )	if( R1(2,1) < 0 )		a1 = acos(dot( R1, [1,0,0]')) + roAng;			y1 = sin( a1 );		y1 = y1 * -1;	else		a1 = acos(dot( R1, [1,0,0]')) - roAng;			y1 = sin( a1 );	end	x1 = cos( a1 );	if( R2(2,1) < 0 )		a2 = acos(dot( R2, [1,0,0]')) - roAng;			y2 = sin( a2 );		y2 = y2 * -1;	else		a2 = acos(dot( R2, [1,0,0]')) + roAng;			y2 = sin( a2 );	end	x2 = cos( a2 );	R1(1,1) = x1;	R1(2,1) = y1;	R2(1,1) = x2;	R2(2,1) = y2;else	if( R2(2,1) < 0 )		a1 = acos(dot( [1,0,0]', R2)) + roAng;		y1 = sin( a1 );		y1 = y1 * -1;	else		a1 = acos(dot( [1,0,0]', R2)) - roAng;		y1 = sin( a1 );	end	x1 = cos( a1 );		if( R1(2,1) < 0 )		a2 = acos(dot( [1,0,0]', R1)) - roAng;		y2 = sin( a2 );		y2 = y2 * -1;	else		a2 = acos(dot( [1,0,0]', R1)) + roAng;		y2 = sin( a2 );	end	x2 = cos( a2 );		R2(1,1) = x1;	R2(2,1) = y1;	R1(1,1) = x2;	R1(2,1) = y2;endR1 = inv(Ro) * R1;R2 = inv(Ro) * R2;R3 = cross( R1, R2 );R = [R1,R2,R3];Tv = Q(:,3)/lambda;%T3 = ols( Tv, R );T3 = R \ Tv;T = [[1,0,0]',[0,1,0]',T3];% predpoklad - vime kde je kamera....if( T(3,3) < 0 )    %T( :, 3 ) = T( :, 3 ) .* -1;end%errorsnewDLT = inv(V) * inv(B) * F * R * T;%newDLT = newDLT / newDLT(3,3);%newDLT = newDLT .* 123.8newP = newDLT * hext(Sp)';newP = hnorm( newP' );Ip = DLT * hext(Sp)';Ip = hnorm( Ip' );errs1 = vsize( Ip - newP );errs = mean( errs1 );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -