00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <videosource.h>
00021 #include <iostream>
00022 #include <iniparser.h>
00023 #include <qapplication.h>
00024 #include <fstream>
00025 #include "glbox.h"
00026 #include "vsview.h"
00027
00028 using namespace std;
00029
00030 int main(int argc, char **argv) {
00031 QApplication a( argc, argv );
00032
00033
00034 IniParser parser(0);
00035
00036
00037
00038
00039
00040 VideoSourceFactory factory;
00041 factory.registerParameters(&parser);
00042
00043 const char *vs_ini = "videosource.ini";
00044
00045 for (int i=1; i<argc-1; ++i) {
00046 if (strcmp(argv[i],"-vs")==0) {
00047 vs_ini = argv[++i];
00048 }
00049 }
00050
00051 if (!parser.parse(vs_ini)) {
00052 cerr << "warning: unable to read " << vs_ini << ", generating an example one.\n";
00053 parser.dumpExampleFile(const_cast<char *>(vs_ini));
00054 }
00055
00056
00057 VideoSource *vs = factory.construct();
00058
00059 if (vs==0) {
00060 cerr << "Unable to open video source!\n";
00061 return 2;
00062 }
00063
00064 VSView *glbox = new VSView(0, "GLBox", vs);
00065
00066 for (int i=1; i<argc; i++) {
00067 if (i<argc-1) {
00068 if (strcmp(argv[i],"-t")==0) {
00069 glbox->tree_fn = argv[++i];
00070 continue;
00071 } else if (strcmp(argv[i],"-d")==0) {
00072 glbox->descriptors_fn = argv[++i];
00073 continue;
00074 } else if (strcmp(argv[i],"-v")==0) {
00075 glbox->visual_db_fn = argv[++i];
00076 continue;
00077 } else if (strcmp(argv[i],"-s")==0) {
00078 if (!glbox->load_script(argv[++i]))
00079 cerr << argv[i] << ": failed to load script\n";
00080 continue;
00081 } else if (strcmp(argv[i],"-vs")==0) {
00082 ++i;
00083 continue;
00084 } else if (strcmp(argv[i],"-c")==0) {
00085 glbox->clusters_fn = argv[++i];
00086 continue;
00087 }
00088 }
00089 if (strcmp("-rt",argv[i])==0) {
00090 glbox->record = true;
00091 glbox->record_pts = false;
00092 } else if (strcmp("-B",argv[i])==0) {
00093 glbox->query_flags |= id_cluster_collection::QUERY_BIN_FREQ;
00094 } else if (strcmp("-M",argv[i])==0) {
00095 glbox->query_flags |= id_cluster_collection::QUERY_MIN_FREQ;
00096 } else if (strcmp("-p", argv[i])==0) {
00097 glbox->use_pipeline = true;
00098 } else if (strcmp("-rp",argv[i])==0) {
00099 glbox->record = false;
00100 glbox->record_pts = true;
00101 } else {
00102 cout << "Unknown command line parameter: " << argv[i] << endl;
00103 cout << "Available options are:\n"
00104 " -t <tree file>\n"
00105 " -d <output descriptor file>\n"
00106 " -v <visual database file>\n"
00107 " -c <clusters file>\n"
00108 " -rt : record tracks\n"
00109 " -rp : recort point descriptors\n"
00110 " -s <script>\n"
00111 " -B : binary tf-idf\n"
00112 " -M : min tf-idf\n";
00113 }
00114 }
00115
00116
00117 glbox->show();
00118
00119 a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
00120 int r= a.exec();
00121 cout << "bye bye\n";
00122 delete glbox;
00123 return r;
00124 }
00125