BorderWatchGui.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "QtUtil/Util.H"
00039 #include "Apps/BorderWatch/BorderWatchQt.qt.H"
00040 #include "Apps/BorderWatch/BorderWatchData.H"
00041 #include "Component/ModelManager.H"
00042 #include "Component/ModelOptionDef.H"
00043 #include "Image/Image.H"
00044 #include "Media/FrameSeries.H"
00045 #include "Raster/GenericFrame.H"
00046
00047 #include <QtGui/QApplication>
00048 #include <fstream>
00049
00050 const ModelOptionCateg MOC_BORDERWATCH = {
00051 MOC_SORTPRI_3, "BorderWatch-Related Options" };
00052
00053 const ModelOptionDef OPT_LogFile =
00054 { MODOPT_ARG_STRING, "LogFile", &MOC_BORDERWATCH, OPTEXP_CORE,
00055 "File name of the log file generated by BorderWatch application",
00056 "logfile", '\0', "<file.log>", "" };
00057
00058
00059 int main(int argc, const char **argv)
00060 {
00061
00062 ModelManager manager("Attention Model");
00063
00064 nub::ref<InputFrameSeries> ifs(new InputFrameSeries(manager));
00065 manager.addSubComponent(ifs);
00066
00067 OModelParam<std::string> optLogFile(&OPT_LogFile, &manager);
00068
00069 manager.exportOptions(MC_RECURSE);
00070
00071
00072 if (manager.parseCommandLine(argc, argv, "", 0, 0) == false) return 1;
00073
00074 if (optLogFile.getVal().empty()) LFATAL("You need to provide a log file with --logfile=<file.log>");
00075
00076
00077 manager.start();
00078
00079
00080 LINFO("Loading logfile data from %s", optLogFile.getVal().c_str());
00081 std::vector<BorderWatchData> logdata;
00082 std::ifstream inlog(optLogFile.getVal().c_str());
00083 if (inlog.is_open() == false) LFATAL("Cannot open %s for reading", optLogFile.getVal().c_str());
00084 BorderWatchData d;
00085 while (true) { inlog >> d; if (inlog.eof()) break; else logdata.push_back(d); }
00086 inlog.close();
00087 LINFO(" %"ZU" log entries.", logdata.size());
00088
00089
00090 LINFO("Loading movie frames...");
00091 std::vector<GenericFrame> frames;
00092 while (true) {
00093
00094 ifs->updateNext();
00095 GenericFrame input = ifs->readFrame(); if (input.initialized() == false) break;
00096 frames.push_back(input);
00097 if ((ifs->frame() % 5000) == 0) LINFO(" frame %06u", ifs->frame());
00098 }
00099 LINFO(" %"ZU" frames.", frames.size());
00100
00101
00102 manager.stop();
00103
00104
00105 LINFO("Starting GUI...");
00106 int qtargc = 1; const char* qtargv[1] = { "BorderWatchGUI" };
00107 QApplication a(qtargc, argv2qt(qtargc, qtargv));
00108
00109
00110 BorderWatchQt b(frames, logdata);
00111 b.setWindowTitle("iLab USC -- BorderWatch Review GUI");
00112 b.show();
00113
00114
00115 const int ret = a.exec();
00116
00117
00118 return ret;
00119 }