src/tools/lvr2_largescale_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 
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) 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 
123 {
124  return m_variables["voxelsize"].as<float>();
125 }
126 
128 {
129  return m_variables["sft"].as<float>();
130 }
131 
133 {
134  return m_variables["sct"].as<float>();
135 }
136 
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 
158 {
159  return m_variables["intersections"].as<int>();
160 }
161 
163 {
164  return m_variables["planeIterations"].as<int>();
165 }
166 
168 {
169  return (m_variables["inputFile"].as< vector<string> >())[0];
170 }
171 
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 
188 {
189  return (m_variables["classifier"].as< string >());
190 }
191 
193 {
194  return (m_variables["decomposition"].as< string >());
195 }
196 
198 {
199  return (m_variables["scanPoseFile"].as<string>());
200 }
201 
203 {
204  return (m_variables["reductionRatio"].as<float>());
205 }
206 
208 {
209  return (m_variables["rda"].as<int> ());
210 }
211 
213 {
214  return (m_variables["fillHoles"].as<int> ());
215 }
216 
218 {
219  return (m_variables["mp"].as<int> ());
220 }
221 
222 
224 {
225  if(!m_variables.count("inputFile"))
226  {
227  cout << "Error: You must specify an input file." << endl;
228  cout << endl;
229  cout << m_descr << endl;
230  return true;
231  }
232 
233  if(m_variables.count("help"))
234  {
235  cout << endl;
236  cout << m_descr << endl;
237  return true;
238  }
239  return false;
240 }
241 
243 {
244  return m_variables.count("saveFaceNormals");
245 }
246 
248 {
249  return m_variables.count("writeClassificationResult")
250  || m_variables.count("w");
251 }
252 
254 {
255  return m_variables.count("textureAnalyis");
256 }
257 
259 {
260  return (m_variables["inputFile"].as< vector<string> >()).size() > 0;
261 }
262 
264 {
265  return (m_variables.count("recalcNormals"));
266 }
267 
269 {
270  return (m_variables.count("exportPointNormals"));
271 }
272 
274 {
275  return (m_variables.count("saveNormals"));
276 }
277 
278 bool Options::saveGrid() const
279 {
280  return (m_variables.count("saveGrid"));
281 }
282 
283 bool Options::useRansac() const
284 {
285  return (m_variables.count("ransac"));
286 }
287 
289 {
290  return (m_variables.count("saveOriginalData"));
291 }
292 
294 {
295  return m_variables.count("optimizePlanes")
296  || m_variables.count("retesselate");
297 }
298 
300 {
301  return m_variables.count("clusterPlanes");
302 }
303 
304 bool Options::extrude() const
305 {
306  if(m_variables.count("noExtrusion"))
307  {
308  return false;
309  }
310  else
311  {
312  return true;
313  }
314 }
315 
317 {
318  return m_variables.count("colorRegions");
319 }
320 
322 {
323  return m_variables.count("retesselate");
324 }
325 
327 {
328  return m_variables.count("generateTextures");
329 }
330 
332 {
333  return m_variables["pnt"].as<float>();
334 }
335 
337 {
338  return m_variables["smallRegionThreshold"].as<int>();
339 }
340 
342 {
343  return m_variables["cleanContours"].as<int>();
344 }
345 
347 {
348  return m_texelSize;
349 }
350 
352 {
353  return m_variables["lft"].as<float>();
354 }
355 
357 {
358  return m_variables["tp"].as<string>();
359 }
360 
361 unsigned int Options::getNumStatsColors() const
362 {
363  return m_variables["nsc"].as<unsigned int>();
364 }
365 
366 unsigned int Options::getNumCCVColors() const
367 {
368  return m_variables["nccv"].as<unsigned int>();
369 }
370 
371 unsigned int Options::getCoherenceThreshold() const
372 {
373  return m_variables["ct"].as<unsigned int>();
374 }
375 
377 {
378  return m_variables["colt"].as<float>();
379 }
380 
382 {
383  return m_variables["stat"].as<float>();
384 }
385 
387 {
388  return m_variables["feat"].as<float>();
389 }
390 
392 {
393  return m_variables.count("cro");
394 }
395 
397 {
398  return m_variables["patt"].as<float>();
399 }
400 
402 {
403  return m_variables["mtv"].as<int>();
404 }
405 
407 {
408  float* result = new float[14];
409  std::ifstream in (m_variables["tp"].as<string>().c_str());
410  if (in.good())
411  {
412  for(int i = 0; i < 14; i++)
413  {
414  in >> result[i];
415  }
416  in.close();
417  }
418  else
419  {
420  for(int i = 0; i < 14; i++)
421  {
422  result[i] = 0.5;
423  }
424  }
425  return result;
426 }
427 
429 {
430  return m_variables["texMinClusterSize"].as<int>();
431 }
432 
434 {
435  return m_variables["texMaxClusterSize"].as<int>();
436 }
437 
439 {
440  return m_variables.count("vcfp");
441 }
442 
443 bool Options::useGPU() const
444 {
445  return m_variables.count("useGPU");
446 }
447 
448 vector<float> Options::getFlippoint() const
449 {
450  vector<float> dest;
451  if(m_variables.count("flipPoint"))
452  {
453  dest = (m_variables["flipPoint"].as< vector<float> >());
454  if(dest.size() != 3)
455  {
456  dest.clear();
457  dest.push_back(10000000);
458  dest.push_back(10000000);
459  dest.push_back(10000000);
460  }
461  }else{
462  dest.push_back(10000000);
463  dest.push_back(10000000);
464  dest.push_back(10000000);
465  }
466  return dest;
467 }
468 
470 {
471  return m_variables.count("texFromImages");
472 }
473 
475 {
476  return m_variables["projectDir"].as<string>();
477 }
478 
479 
481  // TODO Auto-generated destructor stub
482 }
483 
484 } // namespace reconstruct
bool printUsage() const
Prints a usage message to stdout.
static int getNumThreads()
Returns the number of supported threads (or 1 if OpenMP is not supported)
Definition: lvropenmp.cpp:70
float m_edgeCollapseReductionRatio
Reduction ratio for mesh reduction via edge collapse.
bool colorRegions() const
Returns true of region coloring is enabled.
int m_intersections
The number of intersections used for reconstruction.
virtual void setup()
Setup internal data structures.
Definition: BaseOption.cpp:84
string getClassifier() const
Returns the name of the classifier used to color the mesh.
int getPlaneIterations() const
Returns to number plane optimization iterations.
float m_featuresThreshold
Threshold for texture matching based on features.
bool saveFaceNormals() const
Returns true if the face normals of the reconstructed mesh should be saved to an extra file ("face_no...
bool saveGrid() const
Returns true if the Marching Cubes grid should be save.
int getDanglingArtifacts() const
Returns the number of dangling artifacts to remove from a created mesh.
bool recalcNormals() const
If true, normals should be calculated even if they are already given in the input file...
int getKd() const
Returns the number of neighbors used for distance function evaluation.
int m_texMinClusterSize
Minimum number of textures of a cluster needed for generating textures.
bool saveNormals() const
Returns true if the interpolated normals should be saved in the putput file.
int m_kn
The number of neighbors for normal estimation.
float getSharpFeatureThreshold() const
Returns the sharp feature threshold when using sharp feature decomposition.
bool filenameSet() const
Returns true if an output filen name was set.
int m_ki
The number of neighbors for normal interpolation.
float m_sft
Sharp feature threshold when using sharp feature decomposition.
vector< string > getOutputFileNames() const
Returns the output file names.
bool retesselate() const
Return whether the mesh should be retesselated or not.
int getCleanContourIterations() const
Number of iterations for contour cleanup.
float m_colorThreshold
Threshold for texture matching based on colors.
float getTexelSize() const
Returns the texel size for texture resolution.
int m_planeIterations
Number of iterations for plane optimzation.
int getKn() const
Returns the number of neighbors used for initial normal estimation.
float m_sct
Sharp corner threshold when using sharp feature decomposition.
int getKi() const
Returns the number of neighbors for normal interpolation.
bool extrude() const
Whether to extend the grid. Enable by default.
options_description m_descr
The internally used option description.
Definition: BaseOption.hpp:107
unsigned int m_numCCVColors
Number of colors for texture matching based on color information.
int getNumThreads() const
Returns the number of used threads.
int getSmallRegionThreshold() const
Returns the threshold for the size of small region deletion after plane optimization.
float m_lineFusionThreshold
Threshold for line fusing when tesselating.
float getVoxelsize() const
Returns the given voxelsize.
string getDecomposition() const
Returns the name of the used point cloud handler.
unsigned int m_coherenceThreshold
Coherence threshold for texture matching based on color information.
float getSharpCornerThreshold() const
Returns the sharp corner threshold when using sharp feature decomposition.
int getMinPlaneSize() const
Minimum value for plane optimzation.
int m_minPlaneSize
Threshold for plane optimization.
float getNormalThreshold() const
Returns the normal threshold for plane optimization.
string m_statsCoeffs
Coefficents file for texture matching based on statistics.
bool saveOriginalData() const
Returns true if the original points should be stored together with the reconstruction.
int getFillHoles() const
Returns the region threshold for hole filling.
unsigned int m_numStatsColors
Number of colors for texture statistics.
string m_classifier
Name of the classifier object to color the mesh.
int m_smallRegionThreshold
Threshold for small ragions.
string getScanPoseFile() const
Returns the name of the given file with scan poses used for normal flipping.
string getInputFileName() const
Returns the input file name.
bool writeClassificationResult() const
True if region clustering without plane optimization is required.
variables_map m_variables
The internally used variable map.
Definition: BaseOption.hpp:104
float getEdgeCollapseReductionRatio() const
Reduction ratio for mesh reduction via edge collapse.
float m_patternThreshold
Threshold for pattern extraction from textures.
int getIntersections() const
Returns the number of intersections. If the return value is positive it will be used for reconstructi...
bool generateTextures() const
If true, textures will be generated during finalization of mesh.
float m_planeNormalThreshold
Threshold for plane optimization.
bool doTextureAnalysis() const
True if texture analysis is enabled.
bool savePointNormals() const
Indicates whether to save the used points together with the interpolated normals. ...
int m_minimumTransformationVotes
Minimum number of vote to consider a texture transformation as "correct".
bool useRansac() const
If true, RANSAC based normal estimation is used.
bool optimizePlanes() const
Returns true if cluster optimization is enabled.
int m_kd
The number of neighbors for distance function evaluation.
bool clusterPlanes() const
True if region clustering without plane optimization is required.
string m_pcm
The used point cloud manager.
float getLineFusionThreshold() const
Returns the fusion threshold for tesselation.
int m_rda
Number of dangling artifacts to remove.
float m_statsThreshold
Threshold for texture matching based on statistics.
string getPCM() const
Returns the name of the used point cloud handler.
string getOutputFileName() const
Returns the output file name.
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