Finding Global motion estimation for 2 images.
Using SIFT, Much more point correspondences. Faster than RANSAC. can be used in real time videos.
Sift Code used is from Lowe's implementation.
Source: http://www.cs.ubc.ca/~lowe/keypoints/
TO DO:
use Video Clip for Matches
Pure Matlab Code:
function num = match(image1, image2)
% Find SIFT keypoints for each image
[im1, des1, loc1] = sift(image1);
[im2, des2, loc2] = sift(image2);
% For efficiency in Matlab, it is cheaper to compute dot products between
% unit vectors rather than Euclidean distances. Note that the ratio of
% angles (acos of dot products of unit vectors) is a close approximation
% to the ratio of Euclidean distances for small angles.
%
% distRatio: Only keep matches in which the ratio of vector angles from the
% nearest to second nearest neighbor is less than distRatio.
distRatio = 0.6;
% For each descriptor in the first image, select its match to second image.
des2t = des2'; % Precompute matrix transpose
for i = 1 : size(des1,1)
dotprods = des1(i,:) * des2t; % Computes vector of dot products
[vals,indx] = sort(acos(dotprods)); % Take inverse cosine and sort results
% Check if nearest neighbor has angle less than distRatio times 2nd.
if (vals(1) < im3 =" appendimages(im1,im2);" cols1 =" size(im1,2);" i =" 1:"> 0)
line([loc1(i,2) loc2(match(i),2)+cols1], ...
[loc1(i,1) loc2(match(i),1)], 'Color', 'c');
end
end
hold off;
num = sum(match > 0);
fprintf('Found %d matches.\n', num);
I tried this file in Matlab with two random images slightly different from each other, because of movement, but it does not seem to work. Where do you use distRatio = 0.6? (It is unused. What is this statement doing "if (vals(1) < im3 =" appendimages(im1,im2);" cols1 =" size(im1,2);" i =" 1:"> 0) line([loc1(i,2) loc2(match(i),2)+cols1], ..." A fatal error is in this line. So whats up, thanks!
ReplyDeleteAll codes about homography available on the internet just don´t work! What´s the problem? Such process is really difficult to implement and the authors are hiding some secret?
ReplyDeletePlease, I claim for a helpful soul that could indicate me a code that really works!!
Rafael.
Olá Rafael, você conseguiu algum retorno quanto a decomposição da homografia em rotação e translação?
Delete