SourceForge has been redesigned. Learn more.
Close

[533c8a]: / src / matchpoint / MatchPoint.cpp  Maximize  Restore  History

Download this file

163 lines (133 with data), 4.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/***************************************************************************
* Copyright (C) 2007 by Zoran Mesec *
* zoran.mesec@gmail.com *
* *
* 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
//#define USE_OPENCV
//#define USE_QT
#define USE_VIGRA
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <ctime>
#include <algorithm>
#include <string>
#include "APImage.h"
#include "HessianDetector.h"
#include "Descriptor.h"
#include "getopt.h"
#include <limits>
#ifdef WIN32
#include <getopt.h>
#else
#include <unistd.h>
#endif
using namespace std;
void usage()
{
cout << "MatchPoint: run feature detection and extraction" << endl
<< endl
<< "Usage: MatchPoint [options] image1.jpg output.key" << endl
<< "Options:" << endl
/* // << " -x generate xml suitable for Autopano-SIFT feature matcher" << endl
<< " -o file generate XML file with interest points and descriptors(image1.jpg.xml, image2.jpg.xml)" << endl
<< " -n num extract num interest points an descriptors" << endl*/
<< " -v verbose output" << endl
<< " -t generate keypoint file for matlab test suite(file name is generated using formula: image1.jpg.key)" << endl
//<< " TODO: replace with threshold, default 1000" << endl
<< "Arguments:" << endl
<< " image1.jpg Path to image to be analyzed." << endl
<< " output.key Output keypoint file.." << endl
<< endl;
}
int main(int argc, char *argv[])
{
const char * optstring = "hvt";
char c;
clock_t start,finish;
double time;
bool verbose = false;
bool testFileOutput = false;
string input1;
string output;
// parse arguments
while ((c = getopt (argc, argv, optstring)) != -1)
{
switch(c) {
case 'v':
verbose = true;
break;
case 't':
testFileOutput=true;
break;
/*case 'o':
output = optarg;
break;
case 'n':
nrPoints = atoi(optarg);
break;*/
case 'h':
usage();
//return 0;
break;
default:
usage();
return 0;
}
//optind++;
}
if (optind+2 != argc) {
usage();
return 1;
}
input1=argv[optind];
output=argv[optind+1];
if (verbose) cerr << "Input image: " <<input1 << "; Output key file: "<<output<<endl;
APImage im1(input1);
if(!im1.open()) {
cerr<< "Error! Image can not be opened"<<"\n";
return 0;
}
//need to integrate the image before the detection process(only if using box filter approximation)
im1.integrate();
start = clock();
HessianDetector hd1(&im1,0, HD_BOX_FILTERS,1);
if(!hd1.detect()) {
cerr << "Detection of points failed!";
return 1;
}
finish = clock();
time = (double(finish)-double(start))/CLOCKS_PER_SEC;
cout << "Measured time:"<<time<<"\n";
vector<vector<int> >* interestPoints1=hd1.getPoints();
Descriptor d1(&im1,&hd1);
d1.setPoints(interestPoints1);
//d.orientate();
d1.createDescriptors();
if(testFileOutput) {
// string testOutputPath = input1.append(".key");
if (verbose) cerr << "Generating output file for matlab test suite: " << output << endl;
d1.printDescriptors(output); //for matlab test suite
} else {
d1.generateAutopanoXML(output);
}
return EXIT_SUCCESS;
}