g2o_viewer.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 #include "main_window.h"
00004 #include "stream_redirect.h"
00005 
00006 #include "gui_hyper_graph_action.h"
00007 
00008 #include "g2o/core/graph_optimizer_sparse.h"
00009 #include "g2o/apps/g2o_cli/g2o_common.h"
00010 #include "g2o/apps/g2o_cli/dl_wrapper.h"
00011 
00012 #include "g2o/stuff/command_args.h"
00013 
00014 #include <QApplication>
00015 using namespace std;
00016 using namespace g2o;
00017 
00018 int main(int argc, char** argv)
00019 {
00020   QApplication qapp(argc, argv);
00021 
00022   string dummy;
00023   string inputFilename;
00024   CommandArgs arg;
00025   arg.param("solverlib", dummy, "", "specify a solver library which will be loaded");
00026   arg.param("typeslib", dummy, "", "specify a types library which will be loaded");
00027   arg.paramLeftOver("graph-input", inputFilename, "", "graph file which will be processed", true);
00028 
00029   arg.parseArgs(argc, argv);
00030 
00031   // loading the standard solver /  types
00032   DlWrapper dlTypesWrapper;
00033   loadStandardTypes(dlTypesWrapper, argc, argv);
00034 
00035   // register all the solvers
00036   DlWrapper dlSolverWrapper;
00037   loadStandardSolver(dlSolverWrapper, argc, argv);
00038 
00039   MainWindow mw;
00040   mw.updateDisplayedSolvers();
00041   mw.show();
00042 
00043   // redirect the output that normally goes to cerr to the textedit in the viewer
00044   StreamRedirect redirect(cerr, mw.plainTextEdit);
00045 
00046   // setting up the optimizer
00047   SparseOptimizer* optimizer = new SparseOptimizer();
00048   mw.viewer->graph = optimizer;
00049 
00050   // set up the GUI action
00051   GuiHyperGraphAction guiHyperGraphAction;
00052   guiHyperGraphAction.viewer = mw.viewer;
00053   optimizer->addPostIterationAction(&guiHyperGraphAction);
00054 
00055   if (inputFilename.size() > 0) {
00056     mw.loadFromFile(QString::fromStdString(inputFilename));
00057   }
00058 
00059   while (mw.isVisible()) {
00060     guiHyperGraphAction.dumpScreenshots = mw.actionDump_Images->isChecked();
00061     qapp.processEvents();
00062     usleep(10000);
00063   }
00064 
00065   delete optimizer;
00066   return 0;
00067 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:13