g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
apps
g2o_viewer
run_g2o_viewer.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3
//
4
// This file is part of g2o.
5
//
6
// g2o is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// g2o is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with g2o. If not, see <http://www.gnu.org/licenses/>.
18
19
#include "
run_g2o_viewer.h
"
20
21
#include <QApplication>
22
#include <QThread>
23
24
#include "
g2o/apps/g2o_cli/dl_wrapper.h
"
25
#include "g2o/config.h"
26
#include "
g2o/core/factory.h
"
27
#include "
g2o/core/hyper_graph_action.h
"
28
#include "
g2o/core/optimization_algorithm_factory.h
"
29
#include "
g2o/core/sparse_optimizer.h
"
30
#include "
g2o/stuff/command_args.h
"
31
#include "
g2o/stuff/opengl_wrapper.h
"
32
#include "
gui_hyper_graph_action.h
"
33
#include "
main_window.h
"
34
#include "
stream_redirect.h
"
35
36
namespace
g2o
{
37
41
class
SleepThread
:
public
QThread {
42
public
:
// make the protected methods publicly available
43
using
QThread::msleep;
44
using
QThread::usleep;
45
};
46
47
int
RunG2OViewer::run
(
int
argc,
char
** argv,
CommandArgs
& arg) {
48
std::string inputFilename;
49
std::string loadLookup;
50
arg.
param
(
"renameTypes"
, loadLookup,
""
,
51
"create a lookup for loading types into other types,\n\t "
52
"TAG_IN_FILE=INTERNAL_TAG_FOR_TYPE,TAG2=INTERNAL2\n\t e.g., "
53
"VERTEX_CAM=VERTEX_SE3:EXPMAP"
);
54
arg.
paramLeftOver
(
"graph-input"
, inputFilename,
""
,
55
"graph file which will be processed"
,
true
);
56
arg.
parseArgs
(argc, argv);
57
58
MainWindow
mw;
59
mw.
updateDisplayedSolvers
();
60
mw.
updateRobustKernels
();
61
mw.show();
62
63
// redirect the output that normally goes to cerr to the textedit in the
64
// viewer
65
StreamRedirect
redirect(std::cerr, mw.plainTextEdit);
66
67
// setting up the optimizer
68
SparseOptimizer
* optimizer =
new
SparseOptimizer
();
69
// Loading the input data
70
if
(loadLookup.size() > 0) {
71
optimizer->
setRenamedTypesFromString
(loadLookup);
72
}
73
mw.viewer->graph = optimizer;
74
75
// set up the GUI action
76
GuiHyperGraphAction
guiHyperGraphAction;
77
guiHyperGraphAction.
viewer
= mw.viewer;
78
// optimizer->addPostIterationAction(&guiHyperGraphAction);
79
optimizer->
addPreIterationAction
(&guiHyperGraphAction);
80
81
if
(inputFilename.size() > 0) {
82
mw.
loadFromFile
(QString::fromStdString(inputFilename));
83
}
84
85
QCoreApplication* myapp = QApplication::instance();
86
while
(mw.isVisible()) {
87
guiHyperGraphAction.
dumpScreenshots
= mw.actionDump_Images->isChecked();
88
if
(myapp) myapp->processEvents();
89
SleepThread::msleep(10);
90
}
91
92
delete
optimizer;
93
return
0;
94
}
95
96
}
// namespace g2o
main_window.h
MainWindow
main window of the g2o viewer
Definition
main_window.h:40
MainWindow::updateDisplayedSolvers
void updateDisplayedSolvers()
Definition
main_window.cpp:186
MainWindow::loadFromFile
bool loadFromFile(const QString &filename)
Definition
main_window.cpp:380
MainWindow::updateRobustKernels
void updateRobustKernels()
Definition
main_window.cpp:483
StreamRedirect
redirect a stream to a QPlainTextEdit
Definition
stream_redirect.h:42
g2o::CommandArgs
Command line parsing of argc and argv.
Definition
command_args.h:45
g2o::CommandArgs::parseArgs
bool parseArgs(int argc, char **argv, bool exitOnError=true)
Definition
command_args.cpp:106
g2o::CommandArgs::paramLeftOver
void paramLeftOver(const std::string &name, std::string &p, const std::string &defValue, const std::string &desc, bool optional=false)
Definition
command_args.cpp:331
g2o::CommandArgs::param
void param(const std::string &name, bool &p, bool defValue, const std::string &desc)
Definition
command_args.cpp:188
g2o::GuiHyperGraphAction
action which calls an GUI update after each iteration
Definition
gui_hyper_graph_action.h:32
g2o::GuiHyperGraphAction::viewer
G2oQGLViewer * viewer
the viewer which visualizes the graph
Definition
gui_hyper_graph_action.h:44
g2o::GuiHyperGraphAction::dumpScreenshots
bool dumpScreenshots
Definition
gui_hyper_graph_action.h:45
g2o::RunG2OViewer::run
static int run(int argc, char **argv, CommandArgs &arg)
Definition
run_g2o_viewer.cpp:47
g2o::SleepThread
helper for calling usleep on any system using Qt
Definition
run_g2o_viewer.cpp:41
g2o::SparseOptimizer
Definition
sparse_optimizer.h:42
command_args.h
dl_wrapper.h
factory.h
gui_hyper_graph_action.h
hyper_graph_action.h
g2o
Definition
dl_wrapper.cpp:55
opengl_wrapper.h
optimization_algorithm_factory.h
run_g2o_viewer.h
sparse_optimizer.h
stream_redirect.h
g2o::OptimizableGraph::addPreIterationAction
bool addPreIterationAction(HyperGraphAction *action)
add an action to be executed before each iteration
Definition
optimizable_graph.cpp:717
g2o::OptimizableGraph::setRenamedTypesFromString
void setRenamedTypesFromString(const std::string &types)
Definition
optimizable_graph.cpp:628
Generated on
for g2o by
1.17.0