|
1 |
| -close all; |
2 |
| -clear; |
3 |
| -clc; |
4 | 1 | % -------------------------------------------------------------------------
|
5 | 2 | % Program Introdution:
|
6 | 3 | % This program is a benchmark simulation to verify the 8-point algorithm.
|
7 |
| - |
| 4 | +% |
8 | 5 | % Prgram flow
|
9 | 6 | % Fix the first camera at the origin and randomly generate a relative pose
|
10 | 7 | % for the second camera. Both cameras are assumed as calibrated, where the
|
11 | 8 | % intrinsic matrix is an identify matrix. Then randomly generate 8 points
|
12 | 9 | % in space and project them onto both cameras to obtain matched points in
|
13 | 10 | % two views. 8-point algorithm is then carried out to compute the essential
|
14 | 11 | % matrix and the result is justified.
|
15 |
| - |
| 12 | +% |
16 | 13 | % Key variables
|
17 | 14 | % thetad - rotation angle in degrees
|
18 | 15 | % theta - rotation angle in radians
|
|
26 | 23 | % x2 - coordinates of matched features in the second view
|
27 | 24 | % eMatrix - the ground truth of essential matrix
|
28 | 25 | % eMatrix8 - the essential matrix computed using 8-point algorithm
|
29 |
| - |
| 26 | +% |
30 | 27 | % Author: Frederic Zhang
|
31 | 28 | % Last modified: 15 June 2017
|
32 | 29 | % Version: 2.0
|
33 | 30 | % -------------------------------------------------------------------------
|
34 |
| - |
| 31 | +close all; |
| 32 | +clear; |
| 33 | +clc; |
35 | 34 |
|
36 | 35 | % Intrinsic matrix
|
37 | 36 | K = eye(3);
|
|
77 | 76 | x1 = x1 ./ repmat(x1(3, :), [3, 1]);
|
78 | 77 | x2 = x2 ./ repmat(x2(3, :), [3, 1]);
|
79 | 78 |
|
80 |
| -x1 = x1(1:2, :); |
81 |
| -x2 = x2(1:2, :); |
| 79 | +x1 = transpose(x1(1:2, :)); |
| 80 | +x2 = transpose(x2(1:2, :)); |
82 | 81 |
|
83 | 82 | % Compute essential matrix using 8-point algorithm
|
84 |
| -eMatrix8 = eightPoint(x1', x2', K, K); |
| 83 | +eMatrix8 = eightPoint(x1, x2, K, K); |
85 | 84 | eMatrix8 = eMatrix8 / eMatrix8(3, 3);
|
86 | 85 |
|
87 | 86 | % Varification
|
|
0 commit comments