Skip to content

Commit

Permalink
* parameters for matcher added
Browse files Browse the repository at this point in the history
* working!
  • Loading branch information
Daniel committed Oct 9, 2011
1 parent 57d1ac5 commit e0e4282
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 93 deletions.
38 changes: 23 additions & 15 deletions convert_vlsift_to_lowesift.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

$write_binary = 1;

$filename_src = $filename_base.".key.sift";
$filename_dest = $filename_base.($write_binary ? ".key.bin" : ".key");
$filename_image = $filename_base.".jpg";
$filename_src = $filename_base.".key.sift";
$filename_dest_bin = $filename_base.".key.bin";
$filename_dest_key = $filename_base.".key";
$filename_image = $filename_base.".jpg";

open (DEST_BIN, ">$filename_dest_bin");
open (DEST_KEY, ">$filename_dest_key");

open (DEST, ">$filename_dest");
open (SRC, "$filename_src");

$resolution_line = `jhead $filename_image | grep "Resolution"`;
Expand All @@ -17,11 +20,12 @@
$linecount = 0;
$linecount += tr/\n/\n/ while sysread(SRC, $_, 2 ** 16);

seek(SRC, 0, 0);

printf ("found %d features in %s (%d x %d)\n", $linecount, $filename_image, $res_x, $res_y);
if($write_binary){
print DEST pack("L", $linecount);
seek(SRC, 0, 0);

print DEST_BIN pack("L", $linecount);

while ($record = <SRC>) {
@parts = split(/ /, $record);
Expand Down Expand Up @@ -50,10 +54,13 @@
@parts[$count+5] = @tmp;
}

print DEST pack("f4 C128", @parts);
print DEST_BIN pack("f4 C128", @parts);
}
} else {
print DEST $linecount, " 128\n";
}

seek(SRC, 0, 0);

print DEST_KEY $linecount, " 128\n";

while ($record = <SRC>) {
@parts = split(/ /, $record);
Expand All @@ -66,7 +73,7 @@

@parts[3] *= -1;

printf (DEST "%.3f %.3f %.3f %.3f", @parts[1], @parts[0], @parts[2], @parts[3]);
printf (DEST_KEY "%.3f %.3f %.3f %.3f", @parts[1], @parts[0], @parts[2], @parts[3]);

shift(@parts);
shift(@parts);
Expand All @@ -89,19 +96,20 @@

foreach (@parts) {
if((($counter) % 20) == 0) {
print DEST "\n ";
print DEST_KEY "\n ";
} else {
if($counter != 0){
print DEST " ";
print DEST_KEY " ";
}
}

print DEST $_;
print DEST_KEY $_;

$counter++;
}
}
}

close(DEST);

close(DEST_BIN);
close(DEST_KEY);
close(SRC);
27 changes: 17 additions & 10 deletions patched_files/src/bundler/src/KeyMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,29 @@
/* Read in keys, match, write results to a file */

#include <time.h>
#include <stdio.h>
#include <stdlib.h>

#include "keys2a.h"

int main(int argc, char **argv) {
char *keys1_in;
char *keys2_in;
char *file_out;
double ratio;
double ratio, threshold;

if (argc != 4) {
printf("Usage: %s <keys1.in> <keys2.in> <out.txt>\n", argv[0]);
return -1;
if (argc != 6) {
printf("Usage: %s <keys1.in> <keys2.in> <out.txt> <ratio> <threshold>\n", argv[0]);
return -1;
}

keys1_in = argv[1];
keys2_in = argv[2];
ratio = 0.6; // atof(argv[3]);
file_out = argv[3];

ratio = atof(argv[4]);
threshold = atof(argv[5]);

clock_t start = clock();

unsigned char *keys1, *keys2;
Expand Down Expand Up @@ -83,10 +87,13 @@ int main(int argc, char **argv) {
clock_t end = clock();

int m = (num1 < num2 ? num1 : num2);
float r = (num_matches * 100 / m);
float r = ((float)num_matches * 100 / m);


if (num_matches >= 16 && r > 5.0) {
bool used = false;

if (num_matches >= 16 && r > threshold) {
used = true;

FILE *f = fopen(file_out, "w");

/* Write the number of matches */
Expand All @@ -99,10 +106,10 @@ int main(int argc, char **argv) {
fclose(f);
}

printf("%8d matches ~ %5.2f%% of %d in %6.3fs for %s\n",

if(used) printf("\n%8d matches (%4.1f%%) took %5.2fs for %s\t",
num_matches,
r,
m,
(end - start) / ((double) CLOCKS_PER_SEC),
file_out);

Expand Down
Loading

0 comments on commit e0e4282

Please sign in to comment.