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
50  kaboom::Options options(argc, argv);
51 
52  if (options.getTargetSize() && options.getVoxelSize())
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
70  if(options.getTargetSize())
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  {
111  ScanDirectoryParser parser(options.getInputDir());
112  parser.setStart(options.getStart());
113  parser.setEnd(options.getEnd());
114  parser.setPointCloudPrefix(options.getScanPrefix());
115  parser.setPosePrefix(options.getPosePrefix());
116  parser.setPointCloudExtension(options.getScanExtension());
117  parser.setPoseExtension(options.getPoseExtension());
118  parser.parseDirectory();
119 
120  if(options.getTargetSize())
121  {
122  PointBufferPtr result = parser.randomSubSample(options.getTargetSize());
123  }
124  else
125  {
126  PointBufferPtr result = parser.octreeSubSample(options.getVoxelSize(), options.getMinPointsPerVoxel());
127  }
128 
129  }
130 
131 
132  return 0;
133 }
std::string getPosePrefix() const
const kaboom::Options * options
static Timestamp timestamp
A global time stamp object for program runtime measurement.
Definition: Timestamp.hpp:116
static ModelPtr readModel(std::string filename)
PointBufferPtr getReducedPoints()
std::shared_ptr< PointBuffer > PointBufferPtr
std::string getScanPrefix() const
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
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
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
std::string getPoseExtension() const
int main(int argc, char **argv)
A class to parse the program options for the reconstruction executable.
std::string getScanExtension() const
static void saveModel(ModelPtr m, std::string file)
char ** argv


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 Mon Feb 28 2022 22:46:08