# matlab tsc模块,TSCAI算法 MATLAB 执行中的疑问

0    5    0                                1.73   1

10  7.5  0                                1.73   0

10   5    0                                  0      1

5   10   0                                  0      -1

5    0    0

0      1.0000         0

-0.5018         0       0.8650

0      -1.0000         0

-0.5018         0       0.8650

% 3) Compute the 3D rotation matrix R, or r1, r2,...,r9

r1 = r1p*Ty;

r2 = r2p*Ty;

r4 = r4p*Ty;

r5 = r5p*Ty;

Tx = Txp*Ty;

s = -sign(r1*r4 + r2*r5);

R=[r1, r2, (1-r1^2-r2^2)^(0.5); r4, r5, s*(1-r4^2-r5^2)^(0.5)];

R = [R(1:2,:); cross(R(1,:), R(2,:))];

r7 = R(3,1);

r8 = R(3,2);

r9 = R(3,3);

y = r4*xw+r5*yw+Ty;

w = r7*xw+r8*yw;

z = [y -dy*Y] \ [dy*(w.*Y)];

f = z(1);                                                       由于可能是正值 直接跳过了 IF语句的判断

if f < 0,

R(1,3) = -R(1,3);

R(2,3) = -R(2,3);

R(3,1) = -R(3,1);

R(3,2) = -R(3,2);

end

r3 = R(1,3);

r6 = R(2,3);

r7 = R(3,1);

r8 = R(3,2);

clear s y w z

% 2) Stage 2 --- Compute Effective Focal Length, Distortion Coefficients, and z Position:

% d) Compute an approximation of f and Tz by ignoring lens distortion:

y = r4*xw+r5*yw+Ty;

w = r7*xw+r8*yw;

z = [y -dy*Y] \ [dy*(w.*Y)];

f = z(1);

Tz = z(2);

% Compute the exactly solution for f, Tz, k1:

params_const = [r4 r5 r6 r7 r8 r9 dx dy sx Ty];

params = [f, Tz, 0];  % add initial guess for k1

[x,fval,exitflag,output] = fminsearch( @Tsai_8b, params, [], params_const, xw, yw, zw, X, Y);

f = x(1);

Tz = x(2);

k1 = x(3);

T=[Tx, Ty, Tz]';

zz=r7*xw+r8*yw+Tz

% fval the value of the objective function fun at the solution x.

fval

% exitflag that describes the exit condition of fminsearch

% >0 Indicates that the function converged to a solution x.

% 0  Indicates that the maximum number of function evaluations was exceeded.

% <0 Indicates that the function did not converge to a solution.

exitflag

% output that contains information about the optimization

% output.algorithmThe algorithm used

% output.funcCountThe number of function evaluations

% output.iterationsThe number of iterations taken

output

• 0
点赞
• 0
收藏
觉得还不错? 一键收藏
• 0
评论
03-25
08-12 3193
06-25 1165
02-06 847
05-24
05-24

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。