00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #define USE_VIGRA
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027
00028 #include <stdio.h>
00029 #include <iostream>
00030 #include <stdlib.h>
00031 #include <math.h>
00032 #include <ctime>
00033 #include <algorithm>
00034
00035 #include <string>
00036 #include "APImage.h"
00037 #include "HessianDetector.h"
00038 #include "Descriptor.h"
00039
00040 #include "getopt.h"
00041
00042 #include <limits>
00043
00044 #ifdef WIN32
00045 #include <getopt.h>
00046 #else
00047 #include <unistd.h>
00048 #endif
00049
00050
00051 using namespace std;
00052
00053 void usage()
00054 {
00055 cout << "MatchPoint: run feature detection and extraction" << endl
00056 << endl
00057 << "Usage: MatchPoint [options] image1.jpg output.key" << endl
00058 << "Options:" << endl
00059
00060
00061
00062
00063 << " -v verbose output" << endl
00064 << " -t generate keypoint file for matlab test suite(file name is generated using formula: image1.jpg.key)" << endl
00065
00066 << "Arguments:" << endl
00067 << " image1.jpg Path to image to be analyzed." << endl
00068 << " output.key Output keypoint file.." << endl
00069 << endl;
00070 }
00071
00072
00073 int main(int argc, char *argv[])
00074 {
00075
00076
00077
00078 const char * optstring = "hvt";
00079 char c;
00080 clock_t start,finish;
00081 double time;
00082
00083 bool verbose = false;
00084 bool testFileOutput = false;
00085 string input1;
00086 string output;
00087
00088
00089 while ((c = getopt (argc, argv, optstring)) != -1)
00090 {
00091 switch(c) {
00092 case 'v':
00093 verbose = true;
00094 break;
00095 case 't':
00096 testFileOutput=true;
00097 break;
00098
00099
00100
00101
00102
00103
00104 case 'h':
00105 usage();
00106
00107 break;
00108 default:
00109 usage();
00110 return 0;
00111 }
00112
00113 }
00114
00115 if (optind+2 != argc) {
00116 usage();
00117 return 1;
00118 }
00119
00120 input1=argv[optind];
00121 output=argv[optind+1];
00122 if (verbose) cerr << "Input image: " <<input1 << "; Output key file: "<<output<<endl;
00123
00124 APImage im1(input1);
00125 if(!im1.open()) {
00126 cerr<< "Error! Image can not be opened"<<"\n";
00127 return 0;
00128 }
00129
00130
00131 im1.integrate();
00132
00133 start = clock();
00134
00135 HessianDetector hd1(&im1,0, HD_BOX_FILTERS,1);
00136 if(!hd1.detect()) {
00137 cerr << "Detection of points failed!";
00138 return 1;
00139 }
00140
00141 finish = clock();
00142
00143 time = (double(finish)-double(start))/CLOCKS_PER_SEC;
00144 cout << "Measured time:"<<time<<"\n";
00145
00146 vector<vector<int> >* interestPoints1=hd1.getPoints();
00147
00148 Descriptor d1(&im1,&hd1);
00149 d1.setPoints(interestPoints1);
00150
00151 d1.createDescriptors();
00152
00153 if(testFileOutput) {
00154
00155 if (verbose) cerr << "Generating output file for matlab test suite: " << output << endl;
00156 d1.printDescriptors(output);
00157 } else {
00158 d1.generateAutopanoXML(output);
00159 }
00160
00161 return EXIT_SUCCESS;
00162 }