-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
got the panorama working. the error was in the normalization step in …
…which i was overcomplicating the math and mixing up the order of frames that i was viewing the points in in order to do the following operation
- Loading branch information
Showing
6 changed files
with
210 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function v = homography_solve(p1, p2) | ||
% HOMOGRAPHY_SOLVE finds a homography from point pairs | ||
% V = HOMOGRAPHY_SOLVE(PIN, POUT) takes a 2xN matrix of input vectors and | ||
% a 2xN matrix of output vectors, and returns the homogeneous | ||
% transformation matrix that maps the inputs to the outputs, to some | ||
% approximation if there is noise. | ||
% | ||
% This uses the SVD method of | ||
% http://www.robots.ox.ac.uk/%7Evgg/presentations/bmvc97/criminispaper/node3.html | ||
% David Young, University of Sussex, February 2008 | ||
if ~isequal(size(p1), size(p2)) | ||
error('Points matrices different sizes'); | ||
end | ||
if size(p1, 1) ~= 2 | ||
error('Points matrices must have two rows'); | ||
end | ||
n = size(p1, 2); | ||
if n < 4 | ||
error('Need at least 4 matching points'); | ||
end | ||
% Solve equations using SVD | ||
x = p2(1, :); y = p2(2,:); X = p1(1,:); Y = p1(2,:); | ||
rows0 = zeros(3, n); | ||
rowsXY = -[X; Y; ones(1,n)]; | ||
hx = [rowsXY; rows0; x.*X; x.*Y; x]; | ||
hy = [rows0; rowsXY; y.*X; y.*Y; y]; | ||
h = [hx hy]; | ||
if n == 4 | ||
[U, ~, ~] = svd(h); | ||
else | ||
[U, ~, ~] = svd(h, 'econ'); | ||
end | ||
v = (reshape(U(:,9), 3, 3)).'; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
% Benjamin Shih | ||
% Section 5.1 Sensitivity to Normalization | ||
|
||
function [ normP ] = normBS( p ) | ||
% Input: p is 3xN set of points in 2d, where N is the number of points | ||
% Output: normP is a 3xN set of points in 2d, where N is the number of | ||
% points, but normalized. | ||
|
||
% % Translate the centroid of the points to the origin. | ||
% mux = mean(p(1,:)); | ||
% muy = mean(p(2,:)); | ||
% transx = p(1,:) - mux; | ||
% transy = p(2,:) - muy; | ||
% | ||
% % Scale the points so that the average distance from the origin is sqrt(2). | ||
% avgDist = mean(sqrt(transx.^2 + transy.^2)); | ||
% scale = sqrt(2)/avgDist; | ||
% | ||
% sim = [scale 0 -scale*mux; | ||
% 0 scale -scale*muy; | ||
% 0 0 1]; | ||
% | ||
% normP = sim*p; | ||
|
||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters