00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <vector>
00021 #include <iostream>
00022 #include <fstream>
00023 #include <string>
00024 #include <highgui.h>
00025 #include "pic_randomizer.h"
00026
00027
00028 using namespace std;
00029
00030 void usage(const char *name)
00031 {
00032 printf( "Usage: %s <options> [-] [<image1> <image2> ... ]\n"
00033 " -n <number of views>\n"
00034 " -r <min view rate>\n"
00035 " -C <output file> file to write quantized descriptors to.\n"
00036 " -D <file> write descriptors without quantization to <file>\n"
00037 " -v <database> database to load the tree from.\n"
00038 " -t <tree file> load tree from file\n"
00039 "If %s is invoked with the argument '-', file names are read from stdin, one per line.\n"
00040 , name, name);
00041 }
00042
00043 int main(int argc, char **argv)
00044 {
00045 pic_randomizer generator;
00046
00047 vector<string> files;
00048
00049 bool read_stdin=false;
00050
00051 for (int i=1; i<argc; i++) {
00052 if (i<argc-1) {
00053 if (strcmp(argv[i], "-n")==0) {
00054 generator.nb_views = atoi(argv[++i]);
00055 continue;
00056 } else if (strcmp(argv[i], "-D")==0) {
00057 generator.output_fn = argv[++i];
00058 generator.save_descriptors_only=true;
00059 continue;
00060 } else if (strcmp(argv[i], "-C")==0) {
00061 generator.output_fn = argv[++i];
00062 continue;
00063 } else if (strcmp(argv[i], "-v")==0) {
00064 generator.visualdb_fn = argv[++i];
00065 continue;
00066 } else if (strcmp(argv[i], "-t")==0) {
00067 generator.tree_fn = argv[++i];
00068 continue;
00069 } else if (strcmp(argv[i], "-r")==0) {
00070 generator.min_view_rate = atof(argv[++i]);
00071 continue;
00072 }
00073 }
00074
00075 if (strcmp(argv[i], "-")==0) {
00076 read_stdin = true;
00077 } else if (argv[i][0] == '-') {
00078 usage(argv[0]);
00079 return -1;
00080 } else {
00081 files.push_back(string(argv[i]));
00082 }
00083 }
00084
00085 if (!generator.output_fn) {
00086 printf("Please specify either -C <output file> or -D <output file>.\n");
00087 usage(argv[0]);
00088 return -1;
00089 }
00090
00091 while(read_stdin && cin.good()) {
00092 string s;
00093 getline(cin, s);
00094 if (s.length()==0) break;
00095 files.push_back(s);
00096 }
00097
00098
00099 int n = files.size();
00100
00101 pic_randomizer gen(generator);
00102 for (int i=0; i<n; i++)
00103 {
00104
00105 if (gen.load_image(files[i].c_str())) {
00106 cout << files[i] << endl;
00107 gen.run();
00108 }
00109 }
00110 }
00111