apps/kitti2mm/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/maps/CSimplePointsMap.h>
17 #include <mrpt/obs/CObservationPointCloud.h>
18 #include <mrpt/system/filesystem.h>
19 
20 // CLI flags:
21 static TCLAP::CmdLine cmd("kitti2mm");
22 
23 static TCLAP::ValueArg<std::string> argInput(
24  "i", "input", "KITTI .bin pointcloud file.", true, "kitti-00.bin", "kitti-00.bin", cmd);
25 
26 static TCLAP::ValueArg<std::string> argOutput(
27  "o", "output", "Output file to write to.", true, "out.mm", "out.mm", cmd);
28 
29 static TCLAP::ValueArg<std::string> argLayer(
30  "l", "layer", "Target layer name (Default: \"raw\").", false, "raw", "raw", cmd);
31 
32 static TCLAP::ValueArg<uint64_t> argID(
33  "", "id", "Metric map numeric ID (Default: none).", false, 0, "[ID]", cmd);
34 
35 static TCLAP::ValueArg<std::string> argLabel(
36  "", "label", "Metric map label string (Default: none).", false, "label", "[label]", cmd);
37 
38 int main(int argc, char** argv)
39 {
40  try
41  {
42  // Parse arguments:
43  if (!cmd.parse(argc, argv)) return 1; // should exit.
44 
45  const auto& f = argInput.getValue();
46 
47  auto obs = mrpt::obs::CObservationPointCloud::Create();
48  obs->setAsExternalStorage(
49  f, mrpt::obs::CObservationPointCloud::ExternalStorageFormat::KittiBinFile);
50  obs->load(); // force loading now from disk
51  ASSERTMSG_(obs->pointcloud, mrpt::format("Error loading kitti scan file: '%s'", f.c_str()));
52 
53  // Save as mm file:
55  mm.layers["raw"] = std::move(obs->pointcloud);
56 
57  if (argID.isSet()) mm.id = argID.getValue();
58  if (argLabel.isSet()) mm.label = argLabel.getValue();
59 
60  if (!mm.save_to_file(argOutput.getValue()))
61  THROW_EXCEPTION_FMT("Error writing to target file '%s'", argOutput.getValue().c_str());
62  }
63  catch (const std::exception& e)
64  {
65  std::cerr << mrpt::exception_to_str(e);
66  return 1;
67  }
68  return 0;
69 }
argLayer
static TCLAP::ValueArg< std::string > argLayer("l", "layer", "Target layer name (Default: \"raw\").", false, "raw", "raw", 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:545
argInput
static TCLAP::ValueArg< std::string > argInput("i", "input", "KITTI .bin pointcloud file.", true, "kitti-00.bin", "kitti-00.bin", cmd)
mp2p_icp::metric_map_t::label
std::optional< std::string > label
Definition: metricmap.h:101
cmd
static TCLAP::CmdLine cmd("kitti2mm")
argOutput
static TCLAP::ValueArg< std::string > argOutput("o", "output", "Output file to write to.", true, "out.mm", "out.mm", cmd)
argID
static TCLAP::ValueArg< uint64_t > argID("", "id", "Metric map numeric ID (Default: none).", false, 0, "[ID]", cmd)
main
int main(int argc, char **argv)
Definition: apps/kitti2mm/main.cpp:38
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:55
mp2p_icp::metric_map_t::id
std::optional< uint64_t > id
Definition: metricmap.h:94
argLabel
static TCLAP::ValueArg< std::string > argLabel("", "label", "Metric map label string (Default: none).", false, "label", "[label]", cmd)
mp2p_icp::metric_map_t::layers
std::map< layer_name_t, mrpt::maps::CMetricMap::Ptr > layers
Definition: metricmap.h:82


mp2p_icp
Author(s):
autogenerated on Mon May 26 2025 02:45:49