www.pudn.com > calibr8.zip > minParams.m


function [T, R, Int, errs] = minParams( IInt, PC1, PC2, PC3, PC4, PC5, PC6 )
% DEVELOPMENT PHASE
%
% [T, R, Int, errs] = minParams2( Sp, Int, Ip1, Ip2, Ip3 )
%
% computes the camera parameters using iterative proces of 
% decompositions and recompositions of CDLT/DLT matrix
% input is taken from global variables
%
% returns:
% T - translation matrix
% R - rotation matrix
% Int - internal parameters
% IInt - initial guess of internal parameters
% fl - focal lenght
% u0, v0 - position of the centre of the image plane
% b1, b2 - linear distorion coefficients
% errs - errors in each step + for all the planes

clear G*;

global Gfl;
global Gu0;
global Gv0;
global Gb1;
global Gb2;
global GoldP;
global GSp;
global GA;
global GIpts;
global GHSp;
global Gno_views;
global count;

Gno_views = nargin - 3;

for i = 1:Gno_views
	eval( ['GIpts{' num2str(i) '} = PC' num2str(i) '(:,4:5);'] );
	eval( ['GHSp{' num2str(i) '} = PC' num2str(i) '(:,1:3);'] );
	eval( ['Pc' num2str(i) ' = PC' num2str(i) '(:,1:2);'] );
	eval( ['Pc' num2str(i) '(:,3:4) = PC' num2str(i) '(:,4:5);'] );
	eval( ['GA{' num2str(i) '} = estiCDLT( Pc' num2str(i) ');'] );
end

X0(1,1) = IInt(1,1);
X0(1,2) = IInt(1,2);
X0(1,3) = IInt(1,3);
X0(1,4) = IInt(1,4);
X0(1,5) = IInt(1,5);
%Gb2 = 0;

count = 1;
errs = initErrs;

X0 = solvopt( X0, 'minParams_fun');

Int = X0;
%errs = gerrs;
Gfl = X0(1,1);
Gu0 = X0(1,2);
Gv0 = X0(1,3);
Gb1 = X0(1,4);
Gb2 = X0(1,5);

[T, R, fl, u0, v0, b1, b2, GPC, errstat] = iterateThem;

%plot( errs(1,:) );
%hold on
%plot( errs(2,:), ':' );
%plot( errs(3,:), '-.' );
%plot( errs(4,:), '--' );
%grid on;
%zoom on;
%legend('Error in 3D', 'Error in 1st plane', 'Error in 2nd plane', 'Error in 3th plane' );

%figure
T3D = eye(3);
T3D(:,4) = T(:,3);
AE = createDLT( fl, b1, b2, u0, v0, T3D, R );
TT = AE * hext( GPC(:,1:3) )';
TT = hnorm( TT' );
VV = GPC(:,4:5) - TT;
quiver( GPC(:,4), GPC(:,5), VV(:,1), VV(:,2), 0.5 );