intrinsic and extrinsic physical camera parameters computation

18 ビュー (過去 30 日間)
Sat m
Sat m 2013 年 3 月 10 日
i am trying to do a physical camera parameter computer for intrinsic and extrinsic parameters of camera. i was asked to do it with direct parallel calibrate method but i could not find what it is anywhere. so i am using tsai's algorithm to compute parameters of camera. i am having some problems and error.. this is the code
% CalibTsai - computes the intrinsic and extrinsic parameters with Tsai's method.
%
% Usage:
% [K, R, t] = CalibTsai(x, X, u0, v0)
%
% Input:
% x : 3xn homogeneous image points (n: # of points)
% X : 3xn homogeneous object points (n: # of points)
%
% Output:
% K : Camera Intrinsic Matrix
% R : 3x3 Rotation Matrix
% t : 3x1 Translation Vector
X = imread('3D.bmp');
x = imread('2D.bmp');
%[K, R, t] = CalibTsai(x, X, u0, v0)
x(:,1) = x(:,1);
x(:,2) = x(:,2);
M = [ x(:,1).*X(:,1) x(:,1).*X(:,2) x(:,1).*X(:,3) x(:,1) ...
-x(:,2).*X(:,1) -x(:,2).*X(:,2) -x(:,2).*X(:,3) -x(:,2)];
[~,~,V] = svd(M);
scale = sqrt(V(1,8)^2 + V(2,8)^2 + V(3,8)^2);
alpha = sqrt(V(5,8)^2 + V(6,8)^2 + V(7,8)^2)/scale;
r1(1,1) = V(5,8)/alpha/scale;
r1(1,2) = V(6,8)/alpha/scale;
r1(1,3) = V(7,8)/alpha/scale;
r2(1,1) = V(1,8)/alpha/scale;
r2(1,2) = V(2,8)/scale;
r2(1,3) = V(3,8)/scale;
tx = V(8,8)/scale;
ty = V(4,8)/scale;
if ((x(1,2)+v0)*(r2(1,1)*X(1,1) + r2(1,2)*X(1,2) + r2(1,3)*X(1,3)) < 0)
r1(1,1) = -1*r1(1,1);
r1(1,2) = -1*r1(1,2);
r1(1,3) = -1*r1(1,3);
r2(1,1) = -1*r2(1,1);
r2(1,2) = -1*r2(1,2);
r2(1,3) = -1*r2(1,3);
tx = -tx;
ty = -ty;
end
r3 = cross(r1, r2);
A = [x(:,1) r1(1,1).*X(:,1)+r1(1,2).*X(:,2)+r1(1,3).*X(:,3)+tx];
b = (-x(:,1).*(r3(1,1).*X(:,1)+r3(1,2).*X(:,2)+r3(1,3).*X(:,3)));
Y = pinv(A)*b;
tz = Y(1);
fx = Y(2);
fy = fx/alpha;
K = [fx 0 u0; 0 fy v0; 0 0 1];
R = [r1; r2; r3];
t = [tx; ty; tz];
the error is
Matrix dimensions must agree.
Error in CalibTsai (line 23)
M = [ x(:,1).*X(:,1) x(:,1).*X(:,2) x(:,1).*X(:,3) x(:,1) ...
please let me know how to solve this problem. i need to compute the intrinsic and extrinsic parameters of s camera. also if there is any other way to compute it please let me know.
  2 件のコメント
Matt J
Matt J 2013 年 3 月 11 日
Execute "dbstop if error" at the command line. Then re-run. When it stops, execute
K>> whos x X
and tell us the result.
Sat m
Sat m 2013 年 3 月 11 日
i did it and the result is
>> dbstop if error
>> whos x X
Name Size Bytes Class Attributes
X 768x1024x3 2359296 uint8
x 350x646x3 678300 uint8

サインインしてコメントする。

採用された回答

Matt J
Matt J 2013 年 3 月 11 日
編集済み: Matt J 2013 年 3 月 11 日
It should be obvious to you from the output of WHOS what's gone wrong. The instructions for the code say that both x and X should 3xn. WHOS shows you that they are not of those dimensions.
In fact, it looks like you have passed image values as input to the code, when what the code appears to want are sets of n coordinate points.
  1 件のコメント
Sat m
Sat m 2013 年 3 月 15 日
thank you sir i am correcting it

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Support Package for USB Webcams についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by