Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
y
z
Typedefs
a
b
c
d
f
g
i
l
m
n
r
s
t
u
w
Enumerations
Enumerator
a
b
c
d
e
f
g
h
k
l
n
o
r
s
t
u
v
y
Classes
Class List
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
Enumerations
Enumerator
a
b
c
d
f
g
h
i
k
l
m
n
p
r
s
t
u
v
w
Related Functions
:
_
a
g
i
l
n
o
p
r
s
t
u
Files
File List
File Members
All
_
a
b
c
d
e
f
g
i
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Functions
_
a
b
c
d
e
g
i
l
m
n
o
p
r
s
t
u
v
Variables
_
a
c
d
g
i
m
n
r
s
t
v
w
Typedefs
b
c
d
i
m
n
o
p
q
s
t
v
Macros
_
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
y
z
apps
mm-georef
apps/mm-georef/main.cpp
Go to the documentation of this file.
1
/* -------------------------------------------------------------------------
2
* A repertory of multi primitive-to-primitive (MP2P) ICP algorithms in C++
3
* Copyright (C) 2018-2024 Jose Luis Blanco, University of Almeria
4
* See LICENSE for license information.
5
* ------------------------------------------------------------------------- */
6
14
#include <
mp2p_icp/metricmap.h
>
15
#include <mrpt/3rdparty/tclap/CmdLine.h>
16
#include <mrpt/containers/yaml.h>
17
#include <mrpt/io/CFileGZInputStream.h>
18
#include <mrpt/io/CFileGZOutputStream.h>
19
#include <mrpt/serialization/CArchive.h>
20
#include <mrpt/system/filesystem.h>
21
#include <mrpt/system/os.h>
22
23
namespace
24
{
25
26
// CLI flags:
27
struct
Cli
28
{
29
TCLAP::CmdLine
cmd
{
"mm-georef"
};
30
31
TCLAP::ValueArg<std::string> argMap{
32
"m"
,
"mao"
,
"Input/Output .mm file to operate on"
,
33
true
,
"theMap.mm"
,
"theMap.mm"
,
34
cmd
};
35
36
TCLAP::ValueArg<std::string> argGeoRef{
37
"g"
,
38
"georef"
,
39
"Input/Output binary `.georef` file with geo-referencing metadata"
,
40
true
,
41
"myMap.georef"
,
42
"myMap.georef"
,
43
cmd
};
44
45
TCLAP::SwitchArg argExtract{
46
""
,
"extract-from-map"
,
47
"Reads the geo-referencing data from the map and saves it to a .georef "
48
"file"
,
49
cmd
};
50
51
TCLAP::SwitchArg argInject{
52
""
,
"inject-to-map"
,
53
"Reads the geo-referencing data from an input file and stores it into "
54
"the existing map file."
55
"file"
,
56
cmd
};
57
58
TCLAP::ValueArg<std::string>
arg_plugins
{
59
"l"
,
60
"load-plugins"
,
61
"One or more (comma separated) *.so files to load as plugins"
,
62
false
,
63
"foobar.so"
,
64
"foobar.so"
,
65
cmd
};
66
};
67
68
void
run_mm_extract(Cli&
cli
)
69
{
70
const
auto
& filInput =
cli
.argMap.getValue();
71
72
std::cout <<
"[mm-georef] Reading input map from: '"
<< filInput <<
"'..."
73
<< std::endl;
74
75
mp2p_icp::metric_map_t
mm;
76
mm.
load_from_file
(filInput);
77
78
std::cout <<
"[mm-georef] Done read map:"
<< mm.
contents_summary
()
79
<< std::endl;
80
ASSERT_(!mm.
empty
());
81
82
std::cout <<
"[mm-georef] Done. Output map: "
<< mm.
contents_summary
()
83
<< std::endl;
84
85
// Save as .georef file:
86
const
auto
filOut =
cli
.argGeoRef.getValue();
87
std::cout <<
"[mm-georef] Writing geo-referencing metamap to: '"
<< filOut
88
<<
"'..."
<< std::endl;
89
90
mrpt::io::CFileGZOutputStream
f
(filOut);
91
auto
arch = mrpt::serialization::archiveFrom(
f
);
92
arch << mm.
georeferencing
;
93
}
94
95
void
run_mm_inject(Cli&
cli
)
96
{
97
// Load .georef file:
98
const
auto
filIn =
cli
.argGeoRef.getValue();
99
std::cout <<
"[mm-georef] Reading geo-referencing metamap from: '"
<< filIn
100
<<
"'..."
<< std::endl;
101
102
mrpt::io::CFileGZInputStream
f
(filIn);
103
auto
arch = mrpt::serialization::archiveFrom(
f
);
104
105
std::optional<mp2p_icp::metric_map_t::Georeferencing> g;
106
arch >> g;
107
108
const
auto
& filMap =
cli
.argMap.getValue();
109
110
std::cout <<
"[mm-georef] Reading input map from: '"
<< filMap <<
"'..."
111
<< std::endl;
112
113
mp2p_icp::metric_map_t
mm;
114
mm.
load_from_file
(filMap);
115
116
std::cout <<
"[mm-georef] Done read map: "
<< mm.
contents_summary
()
117
<< std::endl;
118
119
// Set geo-ref data:
120
mm.
georeferencing
= g;
121
122
std::cout <<
"[mm-georef] Set georeferencing data. Updated map data: "
123
<< mm.
contents_summary
() << std::endl;
124
125
std::cout <<
"[mm-georef] Saving updated map to: '"
<< filMap <<
"'..."
126
<< std::endl;
127
128
mm.
save_to_file
(filMap);
129
}
130
131
void
run_mm_georef(Cli&
cli
)
132
{
133
// Load plugins:
134
if
(
cli
.arg_plugins.isSet())
135
{
136
std::string
errMsg;
137
const
auto
plugins =
cli
.arg_plugins.getValue();
138
std::cout <<
"Loading plugin(s): "
<< plugins << std::endl;
139
if
(!mrpt::system::loadPluginModules(plugins, errMsg))
140
throw
std::runtime_error(errMsg);
141
}
142
143
if
(
cli
.argExtract.isSet()) {
return
run_mm_extract(
cli
); }
144
else
if
(
cli
.argInject.isSet()) {
return
run_mm_inject(
cli
); }
145
146
THROW_EXCEPTION(
147
"One of either '--extract-from-map' or '--inject-to-map' flags must be "
148
"provided."
);
149
}
150
}
// namespace
151
152
int
main
(
int
argc,
char
** argv)
153
{
154
try
155
{
156
Cli
cli
;
157
158
// Parse arguments:
159
if
(!
cli
.cmd.parse(argc, argv))
return
1;
// should exit.
160
161
run_mm_georef(
cli
);
162
}
163
catch
(
const
std::exception& e)
164
{
165
std::cerr << e.what();
166
return
1;
167
}
168
return
0;
169
}
cli
std::unique_ptr< cli_flags > cli
Definition:
sm-cli-main.cpp:29
mp2p_icp::metric_map_t::empty
virtual bool empty() const
Definition:
metricmap.cpp:362
arg_plugins
static TCLAP::ValueArg< std::string > arg_plugins("l", "load-plugins", "One or more (comma separated) *.so files to load as plugins", false, "foobar.so", "foobar.so", cmd)
kitti-run-seq.f
string f
Definition:
kitti-run-seq.py:12
mp2p_icp::metric_map_t::save_to_file
bool save_to_file(const std::string &fileName) const
Definition:
metricmap.cpp:572
kitti-run-seq.cmd
string cmd
Definition:
kitti-run-seq.py:14
testing::internal::string
::std::string string
Definition:
gtest.h:1979
main
int main(int argc, char **argv)
Definition:
apps/mm-georef/main.cpp:152
mp2p_icp::metric_map_t::contents_summary
virtual std::string contents_summary() const
Definition:
metricmap.cpp:500
mp2p_icp::metric_map_t::load_from_file
bool load_from_file(const std::string &fileName)
Definition:
metricmap.cpp:583
metricmap.h
Generic representation of pointcloud(s) and/or extracted features.
mp2p_icp::metric_map_t
Generic container of pointcloud(s), extracted features and other maps.
Definition:
metricmap.h:49
mp2p_icp::metric_map_t::georeferencing
std::optional< Georeferencing > georeferencing
Definition:
metricmap.h:117
mp2p_icp
Author(s):
autogenerated on Wed Feb 26 2025 03:45:47