src/tools/lvr2_reconstruct/Options.cpp
Go to the documentation of this file.
1 
28  /*
29  * Options.cpp
30  *
31  * Created on: Nov 21, 2010
32  * Author: Thomas Wiemann
33  */
34 
35 #include "Options.hpp"
37 
38 #include <iostream>
39 #include <fstream>
40 
41 namespace std
42 {
43  std::ostream& operator<<(std::ostream &os, const std::vector<std::string> &vec)
44  {
45  for (auto item : vec)
46  {
47  os << item << " ";
48  }
49  return os;
50  }
51 }
52 
53 namespace reconstruct{
54 
55 using namespace boost::program_options;
56 
57 Options::Options(int argc, char** argv)
58  : BaseOption(argc, argv)
59 {
60  // Create option descriptions
61  m_descr.add_options()
62  ("help", "Produce help message")
63  ("inputFile", value< vector<string> >(), "Input file name. Supported formats are ASCII (.pts, .xyz) and .ply")
64  ("outputFile", value< vector<string> >()->multitoken()->default_value(vector<string>{"triangle_mesh.ply", "triangle_mesh.obj"}), "Output file name. Supported formats are ASCII (.pts, .xyz) and .ply")
65  ("voxelsize,v", value<float>(&m_voxelsize)->default_value(10), "Voxelsize of grid used for reconstruction.")
66  ("noExtrusion", "Do not extend grid. Can be used to avoid artefacts in dense data sets but. Disabling will possibly create additional holes in sparse data sets.")
67  ("intersections,i", value<int>(&m_intersections)->default_value(-1), "Number of intersections used for reconstruction. If other than -1, voxelsize will calculated automatically.")
68  ("pcm,p", value<string>(&m_pcm)->default_value("FLANN"), "Point cloud manager used for point handling and normal estimation. Choose from {STANN, PCL, NABO}.")
69  ("ransac", "Set this flag for RANSAC based normal estimation.")
70  ("decomposition,d", value<string>(&m_pcm)->default_value("PMC"), "Defines the type of decomposition that is used for the voxels (Standard Marching Cubes (MC), Planar Marching Cubes (PMC), Standard Marching Cubes with sharp feature detection (SF), Dual Marching Cubes with an adaptive Octree (DMC) or Tetraeder (MT) decomposition. Choose from {MC, PMC, MT, SF}")
71  ("optimizePlanes,o", "Shift all triangle vertices of a cluster onto their shared plane")
72  ("clusterPlanes,c", "Cluster planar regions based on normal threshold, do not shift vertices into regression plane.")
73  ("cleanContours", value<int>(&m_cleanContourIterations)->default_value(0), "Remove noise artifacts from contours. Same values are between 2 and 4")
74  ("planeIterations", value<int>(&m_planeIterations)->default_value(3), "Number of iterations for plane optimization")
75  ("fillHoles,f", value<int>(&m_fillHoles)->default_value(0), "Maximum size for hole filling")
76  ("rda", value<int>(&m_rda)->default_value(0), "Remove dangling artifacts, i.e. remove the n smallest not connected surfaces")
77  ("pnt", value<float>(&m_planeNormalThreshold)->default_value(0.85), "(Plane Normal Threshold) Normal threshold for plane optimization. Default 0.85 equals about 3 degrees.")
78  ("smallRegionThreshold", value<int>(&m_smallRegionThreshold)->default_value(10), "Threshold for small region removal. If 0 nothing will be deleted.")
79  ("writeClassificationResult,w", "Write classification results to file 'clusters.clu'")
80  ("exportPointNormals,e", "Exports original point cloud data together with normals into a single file called 'pointnormals.ply'")
81  ("saveGrid,g", "Writes the generated grid to a file called 'fastgrid.grid. The result can be rendered with qviewer.")
82  ("saveOriginalData,s", "Save the original points and the estimated normals together with the reconstruction into one file ('triangle_mesh.ply')")
83  ("scanPoseFile", value<string>()->default_value(""), "ASCII file containing scan positions that can be used to flip normals")
84  ("kd", value<int>(&m_kd)->default_value(5), "Number of normals used for distance function evaluation")
85  ("ki", value<int>(&m_ki)->default_value(10), "Number of normals used in the normal interpolation process")
86  ("kn", value<int>(&m_kn)->default_value(10), "Size of k-neighborhood used for normal estimation")
87  ("mp", value<int>(&m_minPlaneSize)->default_value(7), "Minimum value for plane optimzation")
88  ("retesselate,t", "Retesselate regions that are in a regression plane. Implies --optimizePlanes.")
89  ("lft", value<float>(&m_lineFusionThreshold)->default_value(0.01), "(Line Fusion Threshold) Threshold for fusing line segments while tesselating.")
90  ("generateTextures", "Generate textures during finalization.")
91  ("texMinClusterSize", value<int>(&m_texMinClusterSize)->default_value(100), "Minimum number of faces of a cluster to create a texture from")
92  ("texMaxClusterSize", value<int>(&m_texMaxClusterSize)->default_value(0), "Maximum number of faces of a cluster to create a texture from (0 = no limit)")
93  ("textureAnalysis", "Enable texture analysis features for texture matchung.")
94  ("texelSize", value<float>(&m_texelSize)->default_value(1), "Texel size that determines texture resolution.")
95  ("classifier", value<string>(&m_classifier)->default_value("PlaneSimpsons"),"Classfier object used to color the mesh.")
96  ("recalcNormals,r", "Always estimate normals, even if given in .ply file.")
97  ("threads", value<int>(&m_numThreads)->default_value( lvr2::OpenMPConfig::getNumThreads() ), "Number of threads")
98  ("sft", value<float>(&m_sft)->default_value(0.9), "Sharp feature threshold when using sharp feature decomposition")
99  ("sct", value<float>(&m_sct)->default_value(0.7), "Sharp corner threshold when using sharp feature decomposition")
100  ("reductionRatio", value<float>(&m_edgeCollapseReductionRatio)->default_value(0.0), "Percentage of faces to remove via edge-collapse (0.0 means no reduction, 1.0 means to remove all faces which can be removed)")
101  ("tp", value<string>(&m_texturePack)->default_value(""), "Path to texture pack")
102  ("co", value<string>(&m_statsCoeffs)->default_value(""), "Coefficents file for texture matching based on statistics")
103  ("nsc", value<unsigned int>(&m_numStatsColors)->default_value(16), "Number of colors for texture statistics")
104  ("nccv", value<unsigned int>(&m_numCCVColors)->default_value(64), "Number of colors for texture matching based on color information")
105  ("ct", value<unsigned int>(&m_coherenceThreshold)->default_value(50), "Coherence threshold for texture matching based on color information")
106  ("colt", value<float>(&m_colorThreshold)->default_value(FLT_MAX), "Threshold for texture matching based on colors")
107  ("stat", value<float>(&m_statsThreshold)->default_value(FLT_MAX), "Threshold for texture matching based on statistics")
108  ("feat", value<float>(&m_featuresThreshold)->default_value(FLT_MAX), "Threshold for texture matching based on features")
109  ("cro", "Use texture matching based on cross correlation.")
110  ("patt", value<float>(&m_patternThreshold)->default_value(100), "Threshold for pattern extraction from textures")
111  ("mtv", value<int>(&m_minimumTransformationVotes)->default_value(3), "Minimum number of votes to consider a texture transformation as correct")
112  ("vcfp", "Use color information from pointcloud to paint vertices")
113  ("useGPU", "GPU normal estimation")
114  ("flipPoint", value< vector<float> >()->multitoken(), "Flippoint --flipPoint x y z" )
115  ("texFromImages,q", "Foo Bar ............")
116  ("projectDir,a", value<string>()->default_value(""), "Foo Bar ............")
117  ;
118 
119  setup();
120 }
121 
122 float Options::getVoxelsize() const
123 {
124  return m_variables["voxelsize"].as<float>();
125 }
126 
127 float Options::getSharpFeatureThreshold() const
128 {
129  return m_variables["sft"].as<float>();
130 }
131 
132 float Options::getSharpCornerThreshold() const
133 {
134  return m_variables["sct"].as<float>();
135 }
136 
137 int Options::getNumThreads() const
138 {
139  return m_variables["threads"].as<int>();
140 }
141 
142 int Options::getKi() const
143 {
144  return m_variables["ki"].as<int>();
145 }
146 
147 int Options::getKd() const
148 {
149  return m_variables["kd"].as<int>();
150 }
151 
152 int Options::getKn() const
153 {
154  return m_variables["kn"].as<int>();
155 }
156 
157 int Options::getIntersections() const
158 {
159  return m_variables["intersections"].as<int>();
160 }
161 
162 int Options::getPlaneIterations() const
163 {
164  return m_variables["planeIterations"].as<int>();
165 }
166 
167 string Options::getInputFileName() const
168 {
169  return (m_variables["inputFile"].as< vector<string> >())[0];
170 }
171 
172 string Options::getOutputFileName() const
173 {
174  return getOutputFileNames()[0];
175 }
176 
177 vector<string> Options::getOutputFileNames() const
178 {
179  return m_variables["outputFile"].as< vector<string> >();
180 }
181 
182 string Options::getPCM() const
183 {
184  return (m_variables["pcm"].as< string >());
185 }
186 
187 string Options::getClassifier() const
188 {
189  return (m_variables["classifier"].as< string >());
190 }
191 
192 string Options::getDecomposition() const
193 {
194  return (m_variables["decomposition"].as< string >());
195 }
196 
197 string Options::getScanPoseFile() const
198 {
199  return (m_variables["scanPoseFile"].as<string>());
200 }
201 
202 float Options::getEdgeCollapseReductionRatio() const
203 {
204  return (m_variables["reductionRatio"].as<float>());
205 }
206 
207 int Options::getDanglingArtifacts() const
208 {
209  return (m_variables["rda"].as<int> ());
210 }
211 
212 int Options::getFillHoles() const
213 {
214  return (m_variables["fillHoles"].as<int> ());
215 }
216 
217 int Options::getMinPlaneSize() const
218 {
219  return (m_variables["mp"].as<int> ());
220 }
221 
222 bool Options::printUsage() const
223 {
224  if (m_variables.count("help"))
225  {
226  cout << endl;
227  cout << m_descr << endl;
228  return true;
229  }
230  else if (!m_variables.count("inputFile"))
231  {
232  cout << "Error: You must specify an input file." << endl;
233  cout << endl;
234  cout << m_descr << endl;
235  return true;
236  }
237  return false;
238 }
239 
240 bool Options::saveFaceNormals() const
241 {
242  return m_variables.count("saveFaceNormals");
243 }
244 
245 bool Options::writeClassificationResult() const
246 {
247  return m_variables.count("writeClassificationResult")
248  || m_variables.count("w");
249 }
250 
251 bool Options::doTextureAnalysis() const
252 {
253  return m_variables.count("textureAnalyis");
254 }
255 
256 bool Options::filenameSet() const
257 {
258  return (m_variables["inputFile"].as< vector<string> >()).size() > 0;
259 }
260 
261 bool Options::recalcNormals() const
262 {
263  return (m_variables.count("recalcNormals"));
264 }
265 
266 bool Options::savePointNormals() const
267 {
268  return (m_variables.count("exportPointNormals"));
269 }
270 
271 bool Options::saveNormals() const
272 {
273  return (m_variables.count("saveNormals"));
274 }
275 
276 bool Options::saveGrid() const
277 {
278  return (m_variables.count("saveGrid"));
279 }
280 
281 bool Options::useRansac() const
282 {
283  return (m_variables.count("ransac"));
284 }
285 
286 bool Options::saveOriginalData() const
287 {
288  return (m_variables.count("saveOriginalData"));
289 }
290 
291 bool Options::optimizePlanes() const
292 {
293  return m_variables.count("optimizePlanes")
294  || m_variables.count("retesselate");
295 }
296 
297 bool Options::clusterPlanes() const
298 {
299  return m_variables.count("clusterPlanes");
300 }
301 
302 bool Options::extrude() const
303 {
304  if(m_variables.count("noExtrusion"))
305  {
306  return false;
307  }
308  else
309  {
310  return true;
311  }
312 }
313 
314 bool Options::colorRegions() const
315 {
316  return m_variables.count("colorRegions");
317 }
318 
319 bool Options::retesselate() const
320 {
321  return m_variables.count("retesselate");
322 }
323 
324 bool Options::generateTextures() const
325 {
326  return m_variables.count("generateTextures");
327 }
328 
329 float Options::getNormalThreshold() const
330 {
331  return m_variables["pnt"].as<float>();
332 }
333 
334 int Options::getSmallRegionThreshold() const
335 {
336  return m_variables["smallRegionThreshold"].as<int>();
337 }
338 
339 int Options::getCleanContourIterations() const
340 {
341  return m_variables["cleanContours"].as<int>();
342 }
343 
344 float Options::getTexelSize() const
345 {
346  return m_texelSize;
347 }
348 
349 float Options::getLineFusionThreshold() const
350 {
351  return m_variables["lft"].as<float>();
352 }
353 
354 string Options::getTexturePack() const
355 {
356  return m_variables["tp"].as<string>();
357 }
358 
359 unsigned int Options::getNumStatsColors() const
360 {
361  return m_variables["nsc"].as<unsigned int>();
362 }
363 
364 unsigned int Options::getNumCCVColors() const
365 {
366  return m_variables["nccv"].as<unsigned int>();
367 }
368 
369 unsigned int Options::getCoherenceThreshold() const
370 {
371  return m_variables["ct"].as<unsigned int>();
372 }
373 
374 float Options::getColorThreshold() const
375 {
376  return m_variables["colt"].as<float>();
377 }
378 
379 float Options::getStatsThreshold() const
380 {
381  return m_variables["stat"].as<float>();
382 }
383 
384 float Options::getFeatureThreshold() const
385 {
386  return m_variables["feat"].as<float>();
387 }
388 
389 bool Options::getUseCrossCorr() const
390 {
391  return m_variables.count("cro");
392 }
393 
394 float Options::getPatternThreshold() const
395 {
396  return m_variables["patt"].as<float>();
397 }
398 
399 int Options::getMinimumTransformationVotes() const
400 {
401  return m_variables["mtv"].as<int>();
402 }
403 
404 float* Options::getStatsCoeffs()const
405 {
406  float* result = new float[14];
407  std::ifstream in (m_variables["tp"].as<string>().c_str());
408  if (in.good())
409  {
410  for(int i = 0; i < 14; i++)
411  {
412  in >> result[i];
413  }
414  in.close();
415  }
416  else
417  {
418  for(int i = 0; i < 14; i++)
419  {
420  result[i] = 0.5;
421  }
422  }
423  return result;
424 }
425 
426 int Options::getTexMinClusterSize() const
427 {
428  return m_variables["texMinClusterSize"].as<int>();
429 }
430 
431 int Options::getTexMaxClusterSize() const
432 {
433  return m_variables["texMaxClusterSize"].as<int>();
434 }
435 
436 bool Options::vertexColorsFromPointcloud() const
437 {
438  return m_variables.count("vcfp");
439 }
440 
441 bool Options::useGPU() const
442 {
443  return m_variables.count("useGPU");
444 }
445 
446 vector<float> Options::getFlippoint() const
447 {
448  vector<float> dest;
449  if(m_variables.count("flipPoint"))
450  {
451  dest = (m_variables["flipPoint"].as< vector<float> >());
452  if(dest.size() != 3)
453  {
454  dest.clear();
455  dest.push_back(10000000);
456  dest.push_back(10000000);
457  dest.push_back(10000000);
458  }
459  }else{
460  dest.push_back(10000000);
461  dest.push_back(10000000);
462  dest.push_back(10000000);
463  }
464  return dest;
465 }
466 
467 bool Options::texturesFromImages() const
468 {
469  return m_variables.count("texFromImages");
470 }
471 
472 string Options::getProjectDir() const
473 {
474  return m_variables["projectDir"].as<string>();
475 }
476 
478  // TODO Auto-generated destructor stub
479 }
480 
481 } // namespace reconstruct
ply_merger::Options::m_descr
options_description m_descr
The internally used option description.
Definition: src/tools/lvr2_plymerger/Options.hpp:79
ply_merger::Options::m_variables
variables_map m_variables
The internally used variable map.
Definition: src/tools/lvr2_plymerger/Options.hpp:76
Options.hpp
reconstruct
Definition: src/tools/lvr2_largescale_reconstruct/Options.cpp:53
lvropenmp.hpp
reconstruct::Options::Options
Options(int argc, char **argv)
Ctor. Parses the command parameters given to the main function of the program.
Definition: src/tools/lvr2_largescale_reconstruct/Options.cpp:57
argc
int argc
Definition: tests_high_five_parallel.cpp:27
ply_merger::Options::~Options
virtual ~Options()
Definition: src/tools/lvr2_plymerger/Options.hpp:67
std
Definition: HalfEdge.hpp:124
std::operator<<
std::ostream & operator<<(std::ostream &os, const std::vector< std::string > &vec)
Definition: src/tools/lvr2_largescale_reconstruct/Options.cpp:43
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28
lvr2::OpenMPConfig::getNumThreads
static int getNumThreads()
Returns the number of supported threads (or 1 if OpenMP is not supported)
Definition: lvropenmp.cpp:70


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