-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support for patched files
- Loading branch information
me
committed
Oct 8, 2011
1 parent
4ec22da
commit be4990c
Showing
5 changed files
with
774 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2008-2010 Noah Snavely (snavely (at) cs.cornell.edu) | ||
* and the University of Washington | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
/* KeyMatch.cpp */ | ||
/* Read in keys, match, write results to a file */ | ||
|
||
#include <time.h> | ||
|
||
#include "keys2a.h" | ||
|
||
int main(int argc, char **argv) { | ||
char *keys1_in; | ||
char *keys2_in; | ||
char *file_out; | ||
double ratio; | ||
|
||
if (argc != 4) { | ||
printf("Usage: %s <keys1.in> <keys2.in> <out.txt>\n", argv[0]); | ||
return -1; | ||
} | ||
|
||
keys1_in = argv[1]; | ||
keys2_in = argv[2]; | ||
ratio = 0.6; // atof(argv[3]); | ||
file_out = argv[3]; | ||
|
||
clock_t start = clock(); | ||
|
||
unsigned char *keys1, *keys2; | ||
|
||
int num1 = ReadKeyFile(keys1_in, &keys1); | ||
int num2 = ReadKeyFile(keys2_in, &keys2); | ||
|
||
|
||
/* Compute likely matches between two sets of keypoints */ | ||
std::vector<KeypointMatch> matches = | ||
MatchKeys(num1, keys1, num2, keys2, ratio); | ||
|
||
#if 0 | ||
std::vector<KeypointMatch> matches_sym = | ||
MatchKeys(num2, keys2, num1, keys1); | ||
#endif | ||
|
||
int num_matches = (int) matches.size(); | ||
// int num_matches_sym = (int) matches_sym.size(); | ||
|
||
// printf("num_matches = %d\n", num_matches); | ||
// printf("num_matches_sym = %d\n", num_matches_sym); | ||
|
||
#if 0 | ||
/* Prune asymmetric matches */ | ||
for (int i = 0; i < num_matches; i++) { | ||
int idx1 = matches[i].m_idx1; | ||
int idx2 = matches[i].m_idx2; | ||
|
||
for (int j = 0; j < num_matches_sym; j++) { | ||
if (matches_sym[j].m_idx1 == idx2) { | ||
if (matches_sym[j].m_idx2 != idx1) { | ||
matches.erase(matches.begin() + i); | ||
i--; | ||
num_matches--; | ||
} | ||
|
||
break; | ||
} | ||
} | ||
} | ||
#endif | ||
|
||
clock_t end = clock(); | ||
|
||
int m = (num1 < num2 ? num1 : num2); | ||
float r = (num_matches * 100 / m); | ||
|
||
|
||
if (num_matches >= 16 && r > 5.0) { | ||
FILE *f = fopen(file_out, "w"); | ||
|
||
/* Write the number of matches */ | ||
fprintf(f, "%d\n", (int) matches.size()); | ||
|
||
for (int i = 0; i < num_matches; i++) { | ||
fprintf(f, "%d %d\n", matches[i].m_idx1, matches[i].m_idx2); | ||
} | ||
|
||
fclose(f); | ||
} | ||
|
||
printf("%8d matches ~ %5.2f%% of %d in %6.3fs for %s\n", | ||
num_matches, | ||
r, | ||
m, | ||
(end - start) / ((double) CLOCKS_PER_SEC), | ||
file_out); | ||
|
||
|
||
/* printf("%8d matches = %5.2f%% %d in %6.3fs in %s\n", | ||
num_matches, | ||
r, | ||
m, | ||
(end - start) / ((double) CLOCKS_PER_SEC), | ||
file_out); | ||
*/ | ||
} |
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,82 @@ | ||
# Makefile for bundler | ||
|
||
CC=gcc | ||
OPTFLAGS=-O3 -Wall | ||
|
||
OS=$(shell uname -o) | ||
|
||
ifeq ($(OS), Cygwin) | ||
BUNDLER=bundler.exe | ||
KEYMATCHFULL=KeyMatchFull.exe | ||
KEYMATCH=KeyMatch.exe | ||
BUNDLE2PMVS=Bundle2PMVS.exe | ||
BUNDLE2VIS=Bundle2Vis.exe | ||
RADIALUNDISTORT=RadialUndistort.exe | ||
else | ||
BUNDLER=bundler | ||
KEYMATCHFULL=KeyMatchFull | ||
KEYMATCH=KeyMatch | ||
BUNDLE2PMVS=Bundle2PMVS | ||
BUNDLE2VIS=Bundle2Vis | ||
RADIALUNDISTORT=RadialUndistort | ||
endif | ||
|
||
INCLUDE_PATH=-I../lib/imagelib -I../lib/sfm-driver -I../lib/matrix \ | ||
-I../lib/5point -I../lib/sba-1.5 -I../lib/ann_1.1_char/include | ||
|
||
LIB_PATH=-L../lib -L../lib/ann_1.1_char/lib | ||
|
||
CPPFLAGS=$(OPTFLAGS) $(OTHERFLAGS) $(INCLUDE_PATH) $(DEFINES) | ||
|
||
BUNDLER_DEFINES=-D__NO_UI__ -D__BUNDLER__ -D__BUNDLER_DISTR__ | ||
|
||
BUNDLER_OBJS=BaseApp.o BundlerApp.o keys.o Register.o Epipolar.o \ | ||
Bundle.o BundleFast.o MatchTracks.o Camera.o Geometry.o \ | ||
ImageData.o SifterUtil.o BaseGeometry.o BundlerGeometry.o \ | ||
BoundingBox.o BundleAdd.o ComputeTracks.o BruteForceSearch.o \ | ||
BundleIO.o ProcessBundle.o BundleTwo.o Decompose.o \ | ||
RelativePose.o Distortion.o TwoFrameModel.o LoadJPEG.o | ||
|
||
BUNDLER_LIBS=-limage -lsfmdrv -lsba.v1.5 -lmatrix -lz -llapack -lblas \ | ||
-lcblas -lminpack -lm -l5point -ljpeg -lANN_char -lgfortran | ||
|
||
|
||
all: $(BUNDLER) $(KEYMATCHFULL) $(KEYMATCH) $(BUNDLE2PMVS) $(BUNDLE2VIS) $(RADIALUNDISTORT) | ||
|
||
%.o : %.cpp | ||
$(CXX) -c -o $@ $(CPPFLAGS) $(WXFLAGS) $(BUNDLER_DEFINES) $< | ||
|
||
$(BUNDLER): $(BUNDLER_OBJS) | ||
$(CXX) -o $@ $(CPPFLAGS) $(LIB_PATH) \ | ||
$(BUNDLER_DEFINES) $(BUNDLER_OBJS) $(BUNDLER_LIBS) | ||
cp $@ ../bin | ||
|
||
$(KEYMATCHFULL): KeyMatchFull.o keys2a.o | ||
$(CXX) -o $@ $(CPPFLAGS) $(LIB_PATH) KeyMatchFull.o keys2a.o \ | ||
-lANN_char -lz | ||
cp $@ ../bin | ||
|
||
$(KEYMATCH): KeyMatch.o keys2a.o | ||
$(CXX) -o $@ $(CPPFLAGS) $(LIB_PATH) KeyMatch.o keys2a.o \ | ||
-lANN_char -lz | ||
cp $@ ../bin | ||
|
||
$(BUNDLE2PMVS): Bundle2PMVS.o LoadJPEG.o | ||
$(CXX) -o $@ $(CPPFLAGS) $(LIB_PATH) Bundle2PMVS.o LoadJPEG.o \ | ||
-limage -lmatrix -llapack -lblas -lcblas -lgfortran \ | ||
-lminpack -ljpeg | ||
cp $@ ../bin | ||
|
||
$(BUNDLE2VIS): Bundle2Vis.o | ||
$(CXX) -o $@ $(CPPFLAGS) $(LIB_PATH) Bundle2Vis.o | ||
cp $@ ../bin | ||
|
||
$(RADIALUNDISTORT): RadialUndistort.o LoadJPEG.o | ||
$(CXX) -o $@ $(CPPFLAGS) $(LIB_PATH) $^ \ | ||
-limage -lmatrix -llapack -lblas -lcblas -lgfortran \ | ||
-lminpack -ljpeg | ||
cp $@ ../bin | ||
|
||
clean: | ||
rm -f *.o *~ $(BUNDLER) $(KEYMATCHFULL) $(KEYMATCH) $(BUNDLE2PMVS) \ | ||
$(BUNDLE2VIS) $(RADIALUNDISTORT) |
Oops, something went wrong.