레이블이 computer vision인 게시물을 표시합니다. 모든 게시물 표시
레이블이 computer vision인 게시물을 표시합니다. 모든 게시물 표시

2009년 1월 13일 화요일

Cholesky decomposition을 이용한 카메라 행렬 분해

카메라보정(camera calibration) 또는 Self-calibration에서 카메라의 내부(intrinsic)/외부(extrinsic)

파라미터를 계산하는 것이 중요한데 그중에서 cholesky decomposition을 이용하는 방법에 대해

쓰고자 한다.

Cholesky decompostion을 이용하여 카메라 행렬을 분해하는 방법은 아래 박사학위 논문에 언급되어있다.

T.Melen, "Geometrical modelling and calibration of video cameras for underwater navigation," doctoral dissertation, Norwegian Univ. of Science and Technology, Trondheim, Norway, 1994.

이 내용을 정리하면 아래와 같다.

---------------------------------------------------------------------------

계산된 카메라 행렬 P를 QR 분해하여 6개의 내부파라미터(K)와 6개의 외부파라미터(R, t)를 계산할 수 있다.
3x4 크기의 카메라 행렬 P에서 왼쪽 3x3 행렬을 A라고 할 때 A = KR이 된다. 여기서 A-1을 QR 분해하면 식 (1)과 같다.

A-1 = QL (1)

여기서 Q는 직교(orthogonal)하고 L은 상삼각(upper triangular)행렬이다. 식 (1)의 역행렬을 계산하면 식 (2)와 같다.

A = L-1Q-1 = L-1Qt (2)

여기서 K = L-1이고 R = Qt가 된다.

-------------------------------------------------------------------------

이렇게 하여 카메라 내부파라미터 K와 회전행렬 R을 계산할 수 있다. 이동행렬 t는 카메라

행렬 P = [KR -KRt]로 구성되어 있기 때문에 카메라 행렬 P와 내부파라미터 K, 회전행렬

R을 알면 쉽게 계산할 수 있다.

blog.naver.com/sh1nk1y



2009년 1월 12일 월요일

IPIU2009 & ICCV2009

- IPIU2009 (Workship on Image Processing and Image Understanding) 에 논문을 제출했다.


분야는 다중카메라 보정.... 2월 18일 제주도에 가겠군... 지금까지 다른 주제로 다른 학회에는 참석해봤지만 이쪽분야로는 첫 발표이다. 데뷔전...


- ICCV2009 (The Twelth IEEE International Conference on Computer Vision in Kyoto)

초록 제출기한 : 3월 1일

논문 제출기한 : 3월 10일

컴퓨터비전분야에서 세계적인 학회로 알고있다. 그리고 꼭 만나보고 싶은 Peter Sturm 이라는 분도

Tutorial chairs로 오신다고 한다.


ICCV에 참석하는 것이 올해의 목표!

2009년 1월 7일 수요일

Homography

카메라 3대에서 다음과 같은 특징점(frame_data.txt)을 추출하였다면

cam1 cam2 cam3

191 426 243 442 263 453
422 457 467 419 430 394
183 363 233 376 263 388
422 388 469 355 434 338
173 292 228 305 259 317
422 311 473 284 440 275
161 207 220 213 261 234
422 215 477 198 447 205
148 117 214 127 263 150
422 117 479 113 451 136
136 27 206 33 263 63
422 13 484 19 457 63


Matlab 코드는 아래와 같다.

-----------------------------------------------------------------------

load frame_data.txt



fcam1 = [frame_data(:,1) frame_data(:,2) ones(length(frame_data),1)]';
fcam2 = [frame_data(:,3) frame_data(:,4) ones(length(frame_data),1)]';
fcam3 = [frame_data(:,5) frame_data(:,6) ones(length(frame_data),1)]';


Homo12 = HomographyDLT(fcam2, fcam1);
Homo13 = HomographyDLT(fcam3, fcam1);


위과 같이 호모그래피를 계산하는 함수를 이용하면 된다.



호모그래피 계산 함수는 아래와 같다. Marco Zuliani 라는 분이 만든 코드로 좌표에 대한 정규화까지 수행하여 호모그래피를 계산한다. 조금더 정확한 결과를 얻고자 한다면 최적화까지 수행하여야 한다.



function [H, A] = HomographyDLT(X1, X2, mode, normalization)

% [H A] = HomographyDLT(X1, X2, mode)
%
% DESC:
% computes the homography between the point pairs X1, X2
%
% AUTHOR
% Marco Zuliani - zuliani@ece.ucsb.edu
%
% VERSION:
% 1.0.0
%
% INPUT:
% X1, X2 = point matches (cartesian coordinates)
% mode = 0 -> Hartley Zisserman formulation
% 1 -> Zuliani formulation (default)
% normalization = true (default) or false to enable/disable point
% normalzation
%
% OUTPUT:
% H = homography
% A = homogenous linear system matrix

if (nargin < 3)
mode = 'MZ';
end;

if (nargin < 4)
normalization = true;
end;

N = size(X1, 2);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% checks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (size(X2, 2) ~= N)
error('The set of input points should have the same cardinality')
end;
if N < 4
error('At least 4 point correspondences are needed')
end;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% normalize the input
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if normalization
% fprintf('\nNormalizing...')
[X1, T1] = normalize_points(X1);
[X2, T2] = normalize_points(X2);
end;

% compute h
switch mode
case 'HZ'
A = get_A_HZ(X1, X2);
case 'MZ'
A = get_A_MZ(X1, X2);
end;
[U S V] = svd(A);
h = V(:, 9);

% reshape the output
switch mode
case 'HZ'
H = [h(1:3)'; h(4:6)'; h(7:9)'];
case 'MZ'
H = reshape(h, 3, 3);
end;

% and denormalize
if normalization
H = inv(T2)*H*T1;
end;

return

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matrix construction routine
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Hartley Zisserman formulation
function A = get_A_HZ(X1, X2)

X1 = cart2homo(X1);
X2 = cart2homo(X2);

N = size(X1, 2);

A = zeros(2*N, 9);
zero = [0; 0; 0];

row = 1;
for h = 1:N

a = X2(3,h)*X1(:,h)';
b = X2(2,h)*X1(:,h)';
c = X2(1,h)*X1(:,h)';
A(row, :) = [zero' -a b];
A(row+1, :) = [a zero' -c];

row = row + 2;

end;

% Zuliani's formulation
function A = get_A_MZ(X1, X2)

N = size(X1, 2);

A = zeros(2*N, 9);

row = 1;
for h = 1:N

A(row, :) = [X1(1,h) 0 -X1(1,h)*X2(1,h) X1(2,h) 0 -X1(2,h)*X2(1,h) 1 0 -X2(1,h)];
A(row+1, :) = [0 X1(1,h) -X1(1,h)*X2(2,h) 0 X1(2,h) -X1(2,h)*X2(2,h) 0 1 -X2(2,h)];

row = row + 2;

end;

return



데이터 정규화를 위한 코드(normalize_points.m)는 아래와 같다.



function [xn, T] = normalize_points(x)

% [xn, T] = normalize_points(x)
%
% DESC:
% normalize a set of points using the procedure described in the book by
% Hartley and Zisserman
%
% AUTHOR
% Marco Zuliani - zuliani@ece.ucsb.edu
%
% VERSION:
% 1.0.0
%
% INPUT:
% x = points to be normalized
%
% OUTPUT:
% Xn = normalized set of points
% T = transformation matrix such that Xn = T * X

% HISTORY
% 1.0.0 - ??/??/05 - Initial version

% compute the translation
x_bar = mean(x, 2);

% center the points
% faster than xc = x - repmat(x_bar, 1, size(x, 2));
xc(1, :) = x(1, :) - x_bar(1);
xc(2, :) = x(2, :) - x_bar(2);

% compute the average point distance
rho = sqrt(sum(xc.^2, 1));
rho_bar = mean(rho);

% compute the scale factor
s = sqrt(2)/rho_bar;

% scale the points
xn = s*xc;

% compute the transformation matrix
T = [s 0 -s*x_bar(1); 0 s -s*x_bar(2); 0 0 1];

return

RANSAC(RANdom SAmple Consensus) 알고리즘

self-calibration을 하려다보니 제일 먼저 공부해야하는 것이 RANSAC(RANdom SAmple Consensus)이다.

matlab 코드를 다운로드 받을 수 있는 곳.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=18555&objectType=file

호모그래피를 계산할때나 포인트매칭을 할 때 유용한 방법이다. 어떻게보면 별거아닌 아이디어지만

참 실용적이다. 이런 연구를 해야할텐데..

위 사이트보다는

http://www.csse.uwa.edu.au/~pk/research/matlabfns/

이 사이트가 더 유용할것 같다. 정말이지 영상처리하는 사람에게 필요한 코드가 많은 곳이다.

Camera calibration toolbox for Matlab

Camera calibration toolbox for Matlab
Modern CCD cameras are usually capable of a spatial accuracy greater than 1/50 of the pixel size. However, such accuracy is not easily attained due to various error sources that can affect the image formation process. Current calibration methods typically assume that the observations are unbiased, the only error is the zero-mean independent and identically distributed random noise in the observed image coordinates, and the camera model completely explains the mapping between the 3D coordinates and the image coordinates. In general, these conditions are not met, causing the calibration results to be less accurate than expected.


위 내용은 http://www.ee.oulu.fi/~jth/calibr/에서 퍼온 내용중 일부이다.

이 사이트에 들어가시면 matlab 소스 코드까지 받을 수 있다.

참고로 난 아직 안 써봤음..

[Paper review] Calibration of 3D kinematic systems using orthogonality constraints

Tomislav Pribanic, Peter Sturm, Mario Cifrek, "Calibration of 3D kinematic systems using orthogonality constraints", Machine vision and applications (2007) 18:367-381.

동작분석기를 위한 다중 카메라 보정방법에 대한 따끈따근한 논문이다. 봉을 이용한 캘리브레이션
논문이 흔하지 않은데 찾다보니 Peter strum의 인턴으로 있던 사람이 쓴 논문이다.
카메라 보정을 위해 3축이 있는 보정틀과 마커가 3개 붙어있는 보정봉을 이용하였다.
논문은 첨부파일에... abstract 부분 번역 내용은 아래와 같다.

----------------------------------------------------------------------------


Abstract.

다중카메라시스템에 의해 획득된 영상을 처리하는 것은 오늘날 3차원복원 수행의 효과적이고 편리한 방법이다. 점의 3차원 위치와 같은 기본적인 값을 통해 속도와 가속도 같은 추가적인 운동학적 데이터에 대한 정보를 얻을 수 있다. 그러므로 많은 복원 시스템은 3차원 운동학적 시스템 같은 것을 이용하고 동작분석을 위해 폭넓게 이용되고 있다. 점들의 실제좌표 복원을 위해 선행되어야 할 것은 다중카메라 시스템의 보정이다. 현재 많은 유명한 3차원 운동학적인 시스템은 마커를 붙인 막대기를 이용하는 막대보정(wand calibration)이라고 부르는 방법을 제공한다. 이 막대 보정은 많은 엔드유저의 관점에서 많은 전통적인 방법을 넘어 선호되는 방법이다. 이 연구에서 다른 보정 방법에 대한 간단한 비평과 3차원 운동학적인 시스템을 위한 전통적인 보정방법이 설명된다. 게다가 특히 카메라 보정의 초기화 단계에 적용될 수 있는 다른 방법이 제안된다. 특별히 제안된 방법은 마커사이 거리의 고정 뿐만 아니라 두 개 또는 세 개의 연결된 막대기의 직교성에 의존한다. 또한 제안된 아이디어는 현재 일반적으로 존재하는 보정도구를 그대로 이용하고 전형적인 보정과정을 단축할 수 있다. 계산된 복원 정확도는 상업적인 3차원 운동학적인 시스템에서 계산한 것과 비교하였다.

[Paper review] Calibration of 3D kinematic systems using orthogonality constraints

Tomislav Pribanic, Peter Sturm, Mario Cifrek, "Calibration of 3D kinematic systems using orthogonality constraints", Machine vision and applications (2007) 18:367-381.

동작분석기를 위한 다중 카메라 보정방법에 대한 따끈따근한 논문이다. 봉을 이용한 캘리브레이션
논문이 흔하지 않은데 찾다보니 Peter strum의 인턴으로 있던 사람이 쓴 논문이다.
카메라 보정을 위해 3축이 있는 보정틀과 마커가 3개 붙어있는 보정봉을 이용하였다.
논문은 첨부파일에... abstract 부분 번역 내용은 아래와 같다.

----------------------------------------------------------------------------


Abstract.

다중카메라시스템에 의해 획득된 영상을 처리하는 것은 오늘날 3차원복원 수행의 효과적이고 편리한 방법이다. 점의 3차원 위치와 같은 기본적인 값을 통해 속도와 가속도 같은 추가적인 운동학적 데이터에 대한 정보를 얻을 수 있다. 그러므로 많은 복원 시스템은 3차원 운동학적 시스템 같은 것을 이용하고 동작분석을 위해 폭넓게 이용되고 있다. 점들의 실제좌표 복원을 위해 선행되어야 할 것은 다중카메라 시스템의 보정이다. 현재 많은 유명한 3차원 운동학적인 시스템은 마커를 붙인 막대기를 이용하는 막대보정(wand calibration)이라고 부르는 방법을 제공한다. 이 막대 보정은 많은 엔드유저의 관점에서 많은 전통적인 방법을 넘어 선호되는 방법이다. 이 연구에서 다른 보정 방법에 대한 간단한 비평과 3차원 운동학적인 시스템을 위한 전통적인 보정방법이 설명된다. 게다가 특히 카메라 보정의 초기화 단계에 적용될 수 있는 다른 방법이 제안된다. 특별히 제안된 방법은 마커사이 거리의 고정 뿐만 아니라 두 개 또는 세 개의 연결된 막대기의 직교성에 의존한다. 또한 제안된 아이디어는 현재 일반적으로 존재하는 보정도구를 그대로 이용하고 전형적인 보정과정을 단축할 수 있다. 계산된 복원 정확도는 상업적인 3차원 운동학적인 시스템에서 계산한 것과 비교하였다.

Multi-Camera Wand Calibration

http://www.ee.surrey.ac.uk/CVSSP/VMRG/WandCalibration/에 있는 내용중 일부입니다.

Multi-Camera Wand Calibration
The use of multiple CCD cameras for generating three-dimensional data of visual scenes is becoming more and more widespread. Once such example is the Prometheus Project, using multiple cameras to generate 3D television content. As part of the project, a fast wand-based method was developed to calibrate the cameras so they can be used for accurate 3D reconstruction. As an aid to researchers working in this area, this site contains linux binaries, a full C++ implementation of the calibration technique, and details of the method.

Calibration Wand
The calibration wand used in this work is shown on the right. Its purpose is to provide two spheres separated by a known distance and easily distinguishable by their colour. We used two standard tennis balls, spray-painted bright red and bright green. The balls are held a fixed distance apart by a piece of wooden dowel passing through them both. This can be done simply by puncturing each ball using a bradawl.

This wand must be waved throughout the capture volume for several seconds whilst video is recorded simultaneously from all cameras. The digitised frames of video can then be fed to the software for processing. The method is robust to clutter provided the colour of objects in the scene is different from the colours chosen for the balls. It does work best, however, when the background is plain since this provides consistently good contrast with the wand.

Tests were performed using PAL cameras, an analog-to-SDI interface, and SDI frame grabbers. It would be interesting to hear from anyone using the method, especially with other camera systems. Please send feedback, comments and suggestions to joel@codamotion.com .


--------------------------------------------------------------------------

위 사이트에 들어가시면 C언어로 되어 있는 소스코드를 다운로드 받을 수 있습니다.

[Paper review]A convenient multi-camera self-calibration for virtual environments

Tomáš Svoboda, Daniel Martinee and Tomáš Pajdla, "A convenient multi-camera self-calibration for virtual environments," Teleoperators and virtual environments(2005), 14(4):407-422.


2005년에 나온 레이저포인터를 이용한 다중 카메라 보정 논문이다.

논문중에 abstract만 번역한 내용.
--------------------------------------------------------------------------

Abstract.

가상몰입환경(virtual immersive environments) 또는 원격존재구조(telepresence setups)는 보정되어야하는 다중카메라로 구성되어있다. 이 연구에서는 카메라 보정을 위한 편리한 방법을 소개한다. 이 알고리즘에 적용하기 위한 최소의 카메라대수는 3대이며 최대는 제한이 없다. 이 방법은 완전히 자동이며 자유롭게 움직이는 밝은 점이 카메라 보정 물체로 사용된다. 가상 3차원 점들은 측정하고자하는 범위에서 밝은 점을 움직이는 것에 의해 계산된다. 그 점의 투영은 서브픽셀 정확도를 가지며 강건한 RANSAC 분석에 의해 검증된다. 카메라들은 모든 점들을 볼 수 없다. 실질적으로 카메라사이의 겹침으로 인해 보이는 마커만을 묶은 서브그룹이 필요하다. 사영 구조(projective structures)는 rank-4 인수분해를 통해 계산되고 기하학적인 구속조건에 의해 유클라디안 공간으로 변환된다. 이러한 선형계산에 의한 값은 완전히 자동적인 비선형외곡의 계산을 위한 초기해로 사용된다. 본 연구에서는 카메라 보정 물체로써 아주 일반적인 레이저 포인터를 어떻게 사용할 수 있는지 제안한다. 16대의 카메라가 있는 가상몰입환경에서 30분 이내에 재투영에러(reprojection error)가 약 1/5 픽셀에 도달하는 것이 가능함을 보인다. 이 방법은 많은 다중카메라 환경에서 성공적으로 테스트되었다.