src/tools/lvr2_kaboom/Main.cpp
Go to the documentation of this file.
1 
36 #include "Options.hpp"
37 
38 #include "lvr2/io/ModelFactory.hpp"
40 #include "lvr2/io/IOUtils.hpp"
42 
43 using namespace lvr2;
44 
46 
47 int main(int argc, char** argv) {
48 
49  // Parse command line arguments
51 
53  {
54  std::cout << timestamp << "Warning: Octree reduction and random reduction requested." << std::endl;
55  std::cout << timestamp << "Please chose set either octree voxel size with -v or target " << std::endl;
56  std::cout << timestamp << "size with random reduction using --targetSize." << std::endl;
57  return 0;
58  }
59 
60  if(options.getInputFile() != "")
61  {
62  std::cout << timestamp << "Reading '" << options.getInputFile() << "." << std::endl;
64  if(model)
65  {
66  PointBufferPtr result = model->m_pointCloud;
67  PointBufferPtr buffer = model->m_pointCloud;
68 
69  // Reduce if requested using the specified technique
71  {
72  std::cout << timestamp << "Random sampling " << options.getTargetSize() << " points." << std::endl;
73  result = subSamplePointBuffer(buffer, options.getTargetSize());
74  }
75  else if(options.getVoxelSize())
76  {
77  std::cout << timestamp << "Octree reduction with voxel size " << options.getVoxelSize() << std::endl;
78  OctreeReduction oct(buffer, options.getVoxelSize(), 5);
79  result = oct.getReducedPoints();
80  }
81 
82  // Convert coordinates of result buffer is nessessary
83  if(options.convertToLVR())
84  {
85  std::cout << timestamp << "Converting from SLAM6D to LVR coordinates" << std::endl;
86  slamToLVRInPlace(result);
87  }
88 
89  string targetFileName;
90  if(options.getOutputFile() == "")
91  {
92  targetFileName = "result.ply";
93  }
94  else
95  {
96  targetFileName = options.getOutputFile();
97  }
98 
99  std::cout << timestamp << "Saving '" << targetFileName << "'" << std::endl;
100  ModelFactory::saveModel(ModelPtr(new Model(result)), targetFileName);
101  }
102  else
103  {
104  std::cout << timestamp << "Error: Could not load '"
105  << options.getInputFile() << "'." << std::endl;
106  }
107 
108  }
109  else
110  {
112  parser.setStart(options.getStart());
113  parser.setEnd(options.getEnd());
118  parser.parseDirectory();
119 
120  if(options.getTargetSize())
121  {
123  }
124  else
125  {
127  }
128 
129  }
130 
131 
132  return 0;
133 }
kaboom::Options::getVoxelSize
double getVoxelSize() const
Definition: src/tools/lvr2_kaboom/Options.cpp:149
lvr2::ModelFactory::saveModel
static void saveModel(ModelPtr m, std::string file)
Definition: ModelFactory.cpp:225
lvr2::ScanDirectoryParser
Definition: ScanDirectoryParser.hpp:52
lvr2::slamToLVRInPlace
void slamToLVRInPlace(PointBufferPtr src)
Transforms src, which is assumed to be in slam6Ds left-handed coordinate system into our right-handed...
Definition: IOUtils.cpp:452
kaboom::Options::getPosePrefix
std::string getPosePrefix() const
Definition: src/tools/lvr2_kaboom/Options.hpp:114
lvr2::ScanDirectoryParser::setPosePrefix
void setPosePrefix(const std::string &prefix)
Definition: ScanDirectoryParser.cpp:56
lvr2::ScanDirectoryParser::setEnd
void setEnd(int e)
Definition: ScanDirectoryParser.cpp:69
kaboom::Options::getMinPointsPerVoxel
size_t getMinPointsPerVoxel() const
Definition: src/tools/lvr2_kaboom/Options.cpp:154
Options.hpp
kaboom::Options::getInputDir
string getInputDir() const
Definition: src/tools/lvr2_kaboom/Options.cpp:98
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
kaboom::Options::convertToLVR
bool convertToLVR() const
Definition: src/tools/lvr2_kaboom/Options.cpp:113
IOUtils.hpp
kaboom::Options::getPoseExtension
std::string getPoseExtension() const
Definition: src/tools/lvr2_kaboom/Options.hpp:116
lvr2::Model
Definition: Model.hpp:51
lvr2::ScanDirectoryParser::setPoseExtension
void setPoseExtension(const std::string &extension)
Definition: ScanDirectoryParser.cpp:60
kaboom::Options::getInputFile
string getInputFile() const
Definition: src/tools/lvr2_kaboom/Options.cpp:93
OctreeReduction.hpp
lvr2::ScanDirectoryParser::octreeSubSample
PointBufferPtr octreeSubSample(const double &voxelSize, const size_t &minPoints=5)
Definition: ScanDirectoryParser.cpp:86
kaboom::Options::getEnd
int getEnd() const
Definition: src/tools/lvr2_kaboom/Options.hpp:111
options
const kaboom::Options * options
Definition: src/tools/lvr2_kaboom/Main.cpp:45
lvr2::OctreeReduction
Definition: OctreeReduction.hpp:48
kaboom::Options::getOutputFile
string getOutputFile() const
Definition: src/tools/lvr2_kaboom/Options.cpp:88
lvr2::ScanDirectoryParser::setPointCloudPrefix
void setPointCloudPrefix(const std::string &prefix)
Definition: ScanDirectoryParser.cpp:47
main
int main(int argc, char **argv)
Definition: src/tools/lvr2_kaboom/Main.cpp:47
lvr2::timestamp
static Timestamp timestamp
A global time stamp object for program runtime measurement.
Definition: Timestamp.hpp:116
kaboom::Options::getScanPrefix
std::string getScanPrefix() const
Definition: src/tools/lvr2_kaboom/Options.hpp:113
argc
int argc
Definition: tests_high_five_parallel.cpp:27
lvr2::ScanDirectoryParser::setStart
void setStart(int s)
Definition: ScanDirectoryParser.cpp:65
kaboom::Options::getScanExtension
std::string getScanExtension() const
Definition: src/tools/lvr2_kaboom/Options.hpp:115
kaboom::Options::getTargetSize
int getTargetSize() const
Definition: src/tools/lvr2_kaboom/Options.cpp:144
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::ModelPtr
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
lvr2::ModelFactory::readModel
static ModelPtr readModel(std::string filename)
Definition: ModelFactory.cpp:65
ModelFactory.hpp
lvr2::ScanDirectoryParser::randomSubSample
PointBufferPtr randomSubSample(const size_t &targetSize)
Definition: ScanDirectoryParser.cpp:122
kaboom::Options
A class to parse the program options for the reconstruction executable.
Definition: src/tools/lvr2_kaboom/Options.hpp:61
lvr2::ScanDirectoryParser::parseDirectory
void parseDirectory()
Definition: ScanDirectoryParser.cpp:179
lvr2::ScanDirectoryParser::setPointCloudExtension
void setPointCloudExtension(const std::string &extension)
Definition: ScanDirectoryParser.cpp:51
ScanDirectoryParser.hpp
lvr2::subSamplePointBuffer
PointBufferPtr subSamplePointBuffer(PointBufferPtr src, const size_t &n)
Computes a random sub-sampling of a point buffer by creating a uniform distribution over all point in...
Definition: IOUtils.cpp:405
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28
kaboom::Options::getStart
int getStart() const
Definition: src/tools/lvr2_kaboom/Options.hpp:109
lvr2::OctreeReduction::getReducedPoints
PointBufferPtr getReducedPoints()
Definition: OctreeReduction.cpp:58


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24