-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3_6.m
More file actions
78 lines (59 loc) · 2.63 KB
/
Copy pathtask3_6.m
File metadata and controls
78 lines (59 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
% part 6: Compute the Fundamental matrix using the eight-point algorithm
% Needs an individual repeat about a version that don't use Hartley preconditioning
image1 = imread('im1corrected.jpg');
image2 = imread('im2corrected.jpg');
mocap_3d = load('mocapPoints3D.mat').pts3D';
addpath("./");
v1_points2d = task3_2('Parameters_V1_1.mat', 'mocapPoints3D.mat', 'im1corrected.jpg', 0);
v2_points2d = task3_2('Parameters_V2_1.mat', 'mocapPoints3D.mat', 'im2corrected.jpg', 0);
selected_indices = [1, 3, 5, 7, 10, 15, 20, 25, 30, 35, 39];
v1_points2d = v1_points2d(:, selected_indices);
v2_points2d = v2_points2d(:, selected_indices);
im = image1;
im2 = image2;
fprintf('Please select ten corresponding points on different planes in both images.\n');
fprintf('These points should represent the same physical locations in both views.\n');
% % Show the image for v1
% figure;
% imshow(image1);
% % Get three points over the image for v1
% v1_points2d = ginput(10)';
% hold on;
% % Keep the image and display the plots
% plot(v1_points2d(1,:), v1_points2d(2,:), 'co');
v1_points2d = [406, 1050, 1004, 1204, 1192, 1138, 1230, 1514, 1008, 704;
718, 952, 622, 308, 562, 262, 222, 226, 446, 738];
figure;
imshow(image1);
hold on;
plot(v1_points2d(1,:), v1_points2d(2,:), 'co');
title('Ten points on multiple planes in camera v1.')
hold off;
% % Show the image for v2
% figure;
% imshow(image2);
% % Get three points over the image for v2
% v2_points2d = ginput(10)';
% hold on;
% % Keep the image and display the plots
% plot(v2_points2d(1,:), v2_points2d(2,:), 'co');
v2_points2d = [960, 1696, 566, 306, 328, 204, 334, 666, 26, 1092;
884, 706, 608, 228, 526, 164, 126, 156, 424, 748];
figure;
imshow(image2);
hold on;
plot(v2_points2d(1,:), v2_points2d(2,:), 'co');
title('Ten points on multiple planes in camera v2.')
hold off;
% subpart 1: eight-point algo with Hartley preconditioning
F = get_F_by_eight_point_algo_with_Hartley_preconditioning(v1_points2d, v2_points2d);
fprintf("F from part 1:\n")
disp(F);
fprintf("\n")
display_epipolar_lines(F, v1_points2d, v2_points2d, image1, image2, "Graph about epipolar lines generated by F matrix, which generated by " + newline +"eight-point algorithm with Hartley preconditioning, ");
% subpart 2: eight-point algo without Hartley preconditioning
F = get_F_by_eight_point_algo_without_Hartley_preconditioning(v1_points2d, v2_points2d);
fprintf("F from part 2:\n")
disp(F);
fprintf("\n")
display_epipolar_lines(F, v1_points2d, v2_points2d, image1, image2, "Graph about epipolar lines generated by F matrix, which generated by " + newline +"eight-point algorithm without Hartley preconditioning, ");