-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yihui-He
committed
May 7, 2016
1 parent
e6f7b85
commit 6a19e7c
Showing
72 changed files
with
259 additions
and
105 deletions.
There are no files selected for viewing
Binary file not shown.
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
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 was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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,88 @@ | ||
function [sorted_imgs]=imorder(imgs) | ||
Thresh = 5; | ||
confidence = 0.999; | ||
inlierRatio = 0.1; | ||
epsilon = 1.5; | ||
|
||
nImgs = size(imgs, 4); | ||
|
||
T = zeros(3, 3, nImgs); | ||
T(:, :, 1) = eye(3); | ||
imgs_feat{nImgs}={}; | ||
imgs_dist{nImgs}={}; | ||
for i=1: nImgs | ||
[f, d] = getSIFTFeatures(imgs(:, :, :, i), Thresh); | ||
imgs_feat{i}=f; | ||
imgs_dist{i}=d; | ||
end | ||
ifmatch=zeros(nImgs,nImgs); | ||
transforms{nImgs,nImgs}={}; | ||
for i = 1 : nImgs | ||
for j = 1 : nImgs | ||
if j==i | ||
continue | ||
end | ||
[matches, ~] = getMatches(imgs_feat{i}, imgs_dist{i},... | ||
imgs_feat{j}, imgs_dist{j}); | ||
[T,nInliers] = ... | ||
RANSAC(confidence, inlierRatio, 1, matches, epsilon); | ||
if nInliers>5.9+.22*length(matches) | ||
ifmatch(i,j)=1; | ||
transforms{i,j}=T; | ||
end | ||
end | ||
end | ||
sequence=[]; | ||
sequence(1)=1; | ||
%% forward matching | ||
for i=2:nImgs | ||
nextIdx=find(ifmatch(sequence(i-1),:)==1); | ||
if size(nextIdx,2)==0 | ||
break | ||
end | ||
failed=true; | ||
for matched=1:size(nextIdx,2) | ||
if size(find(sequence==nextIdx(matched)),2)==1 | ||
continue | ||
end | ||
real_idx=matched; | ||
failed=false; | ||
break | ||
end | ||
|
||
if failed==false | ||
sequence(i)=nextIdx(real_idx); | ||
else | ||
break | ||
end | ||
end | ||
%% backward matching | ||
for i=2:nImgs | ||
nextIdx=find(ifmatch(sequence(1),:)==1); | ||
if size(nextIdx,2)==0 | ||
break | ||
end | ||
failed=true; | ||
for matched=1:size(nextIdx,2) | ||
if size(find(sequence==nextIdx(matched)),2)==1 | ||
continue | ||
end | ||
real_idx=matched; | ||
failed=false; | ||
break | ||
end | ||
|
||
if failed==false | ||
sequence=[nextIdx(real_idx),sequence]; | ||
else | ||
break | ||
end | ||
end | ||
%% reorder | ||
disp(['using ',int2str(length(sequence)),' of ',int2str(length(imgs(1,1,1,:))),' unordered imgs']); | ||
sorted_imgs=zeros(size(imgs,1),size(imgs,2),size(imgs,3),length(sequence),'like',imgs); | ||
for i=1:length(sequence) | ||
sorted_imgs(:,:,:,i)=imgs(:,:,:,sequence(i)); | ||
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,60 @@ | ||
function [sorted_imgs]=imorder(imgs) | ||
Thresh = 10; | ||
confidence = 0.99; | ||
inlierRatio = 0.3; | ||
epsilon = 1.5; | ||
|
||
nImgs = size(imgs, 4); | ||
|
||
T = zeros(3, 3, nImgs); | ||
T(:, :, 1) = eye(3); | ||
imgs_feat{nImgs}={}; | ||
imgs_dist{nImgs}={}; | ||
for i=1: nImgs | ||
[f, d] = getSIFTFeatures(imgs(:, :, :, i), Thresh); | ||
imgs_feat{i}=f; | ||
imgs_dist{i}=d; | ||
end | ||
ifmatch=zeros(nImgs,nImgs); | ||
transforms{nImgs,nImgs}={}; | ||
for i = 1 : nImgs | ||
for j = 1 : nImgs | ||
if j==i | ||
continue | ||
end | ||
[matches, ~] = getMatches(imgs_feat{i}, imgs_dist{i},... | ||
imgs_feat{j}, imgs_dist{j}); | ||
[T,nInliers] = ... | ||
RANSAC(confidence, inlierRatio, 1, matches, epsilon); | ||
if nInliers>5.9+.22*length(matches) | ||
ifmatch(i,j)=1; | ||
transforms{i,j}=T; | ||
end | ||
end | ||
end | ||
sequence=[]; | ||
sequence(1)=1; | ||
for i=2:nImgs | ||
nextIdx=find(ifmatch(sequence(i-1),:)==1); | ||
if size(nextIdx,2)==0 | ||
break | ||
end | ||
failed=false; | ||
for i=1:size(nextIdx,2) | ||
if size(find(sequence==nextIdx(i)),2)==1 | ||
continue | ||
end | ||
real_idx=i; | ||
|
||
break | ||
|
||
sequence(i)=nextIdx(1); | ||
end | ||
disp(length(imgs(1,1,1,:))) | ||
disp(length(sequence)) | ||
sorted_imgs=zeros(size(imgs,1),size(imgs,2),size(imgs,3),length(sequence),'like',imgs); | ||
for i=1:length(sequence) | ||
sorted_imgs(:,:,:,i)=imgs(:,:,:,sequence(i)); | ||
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 |
---|---|---|
@@ -1,32 +1,41 @@ | ||
clear all | ||
%% params | ||
|
||
k1=-0; | ||
k2=0; | ||
|
||
which=11; | ||
which=8; | ||
path='imgs'; | ||
|
||
%% | ||
% 1 2bad 3 4 5 | ||
% 1 2unorder 3 4 5 | ||
datasets={'ucsb4','family_house','glacier4','yellowstone2','GrandCanyon1',... | ||
'yellowstone5','yellowstone4','west_campus1','redrock','intersection',... | ||
...% 6 7 8 9failed 10failed | ||
...% 6 7 8unorder 9 10 | ||
'GrandCanyon2'}; | ||
% 11 failed | ||
|
||
focus=[595,400,2000,1000,1000,1000,1000,1000,1000,1000,1000]; | ||
Full360=[0,1,0,0,0,0,0,0,1000,1000,1000]; | ||
% 11 | ||
% 1 2 3 4 5 6 7 8 9 10 11 | ||
focus=[595,400,2000,1000,1000,1000,1000,1000,2000,2000,2000]; | ||
Full360=[0,0,0,0,0,0,0,0,0,0,0]; | ||
unordered=[0,1,0,0,0,0,0,1,0,0,0]; | ||
%% | ||
full=Full360(which); | ||
f=focus(which); | ||
run('lib/vlfeat-0.9.20/toolbox/vl_setup'); | ||
|
||
disp(['creating panorama for ',datasets{which}]) | ||
s=imageSet(fullfile(path,datasets{which})); | ||
img=read(s,1); | ||
imgs=zeros(size(img,1),size(img,2),size(img,3),s.Count,'like',img); | ||
for i=1:s.Count | ||
imgs(:,:,:,i)=read(s,i); | ||
end | ||
|
||
|
||
if unordered(which) | ||
t=cputime; | ||
disp('ordering unordered images'); | ||
imgs=imorder(imgs); | ||
disp([int2str(cputime-t),' sec']); | ||
end | ||
|
||
|
||
panorama=create( imgs, f, full); | ||
imwrite(panorama,['./results/',datasets{which},'.jpg']); | ||
imwrite(panorama,['./results/',datasets{which},'.jpg']); | ||
if unordered(which) | ||
imwrite(panorama,['./results/',datasets{which},'from unordered.jpg']); | ||
end |
Oops, something went wrong.