LargeScaleOptions.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 "LargeScaleOptions.hpp"
36 
37 #include <fstream>
39 
41 {
42 
43 using namespace boost::program_options;
44 
45 Options::Options(int argc, char** argv) : BaseOption(argc, argv)
46 {
47  // Create option descriptions
48  vector<float> flippoint;
49  flippoint.push_back(1000000);
50  flippoint.push_back(1000000);
51  flippoint.push_back(1000000);
52  m_descr.add_options()
53  ("help", "Produce help message")
54  ("inputFile", value<vector<string>>(),"Input file name. Supported formats are ASCII (.pts, .xyz) and .ply")
55  ("voxelSizes,v",value<vector<float>>(&m_voxelSizes)->multitoken(),"Voxelsize of grid used for reconstruction. multitoken option: it is possible to enter more then one voxelsize")
56  ("bgVoxelSize,bgv",value<float>(&m_voxelsizeBG)->default_value(10),"Voxelsize of the bigGrid.")
57  ("partMethod",value<int>(&m_partMethod)->default_value(1),"Option to change the partition-process to a gridbase partition (0 = kd-Tree; 1 = VGrid)")
58  ("chunkSize",value<int>(&m_chunkSize)->default_value(20),"Set the chunksize for the virtual grid. (default: 20)")
59  ("extrude", value<bool>(&m_extrude)->default_value(false), "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.")
60  ("intersections,i",value<int>(&m_intersections)->default_value(-1),"Number of intersections used for reconstruction. If other than -1, voxelsize will calculated automatically.")
61  ("pcm,p",value<string>(&m_pcm)->default_value("FLANN"),"Point cloud manager used for point handling and normal estimation. Choose from {STANN, PCL, NABO}.")
62  ("useRansac", "Set this flag for RANSAC based normal estimation.")
63  ("decomposition,d",value<string>(&m_pcm)->default_value("PMC"),"Defines the type of decomposition that is used for the voxels (Standard Marching Cubes "
64  "(MC), Planar Marching Cubes (PMC), Standard Marching Cubes with sharp feature detection "
65  "(SF) or Tetraeder (MT) decomposition. Choose from {MC, PMC, MT, SF}")(
66  "optimizePlanes,o", "Shift all triangle vertices of a cluster onto their shared plane")(
67  "clusterPlanes,c",
68  "Cluster planar regions based on normal threshold, do not shift vertices into regression "
69  "plane.")("cleanContours",
70  value<int>(&m_cleanContourIterations)->default_value(0),
71  "Remove noise artifacts from contours. Same values are between 2 and 4")(
72  "planeIterations",
73  value<int>(&m_planeIterations)->default_value(3),
74  "Number of iterations for plane optimization")(
75  "fillHoles,f", value<int>(&m_fillHoles)->default_value(0), "Maximum size for hole filling")(
76  "removeDanglingArtifacts,rda",
77  value<int>(&m_removeDanglingArtifacts)->default_value(0),
78  "Remove dangling artifacts, i.e. remove the n smallest not connected surfaces")(
79  "planeNormalThreshold,pnt",
80  value<float>(&m_planeNormalThreshold)->default_value(0.85),
81  "(Plane Normal Threshold) Normal threshold for plane optimization. Default 0.85 equals "
82  "about 3 degrees.")("smallRegionThreshold",
83  value<int>(&m_smallRegionThreshold)->default_value(0),
84  "Threshold for small region removal. If 0 nothing will be deleted.")(
85  "writeClassificationResult,w", "Write classification results to file 'clusters.clu'")(
86  "exportPointNormals,e",
87  "Exports original point cloud data together with normals into a single file called "
88  "'pointnormals.ply'")("saveGrid,g",
89  "Writes the generated grid to a file called 'fastgrid.grid. The "
90  "result can be rendered with qviewer.")(
91  "saveOriginalData,s",
92  "Save the original points and the estimated normals together with the reconstruction into "
93  "one file ('triangle_mesh.ply')")(
94  "scanPoseFile",
95  value<string>()->default_value(""),
96  "ASCII file containing scan positions that can be used to flip normals")(
97  "kd",
98  value<int>(&m_kd)->default_value(5),
99  "Number of normals used for distance function evaluation")(
100  "ki",
101  value<int>(&m_ki)->default_value(10),
102  "Number of normals used in the normal interpolation process")(
103  "kn",
104  value<int>(&m_kn)->default_value(10),
105  "Size of k-neighborhood used for normal estimation")(
106  "minPlaneSize,mp", value<int>(&m_minPlaneSize)->default_value(7), "Minimum value for plane optimzation")(
107  "retesselate,t",
108  "Retesselate regions that are in a regression plane. Implies --optimizePlanes.")(
109  "lineFusionThreshold,lft",
110  value<float>(&m_lineFusionThreshold)->default_value(0.01),
111  "(Line Fusion Threshold) Threshold for fusing line segments while tesselating.")(
112  "generateTextures", "Generate textures during finalization.")(
113  "textureAnalysis", "Enable texture analysis features for texture matchung.")(
114  "texelSize",
115  value<float>(&m_texelSize)->default_value(1),
116  "Texel size that determines texture resolution.")(
117  "classifier",
118  value<string>(&m_classifier)->default_value("PlaneSimpsons"),
119  "Classfier object used to color the mesh.")("depth",
120  value<int>(&m_depth)->default_value(100),
121  "Maximum recursion depth for region growing.")(
122  "recalcNormals,r", "Always estimate normals, even if given in .ply file.")(
123  "threads",
124  value<int>(&m_numThreads)->default_value(lvr2::OpenMPConfig::getNumThreads()),
125  "Number of threads")("sft",
126  value<float>(&m_sft)->default_value(0.9),
127  "Sharp feature threshold when using sharp feature decomposition")(
128  "sct",
129  value<float>(&m_sct)->default_value(0.7),
130  "Sharp corner threshold when using sharp feature decomposition")(
131  "ecm",
132  value<string>(&m_ecm)->default_value("QUADRIC"),
133  "Edge collapse method for mesh reduction. Choose from QUADRIC, QUADRIC_TRI, MELAX, "
134  "SHORTEST")("ecc",
135  value<int>(&m_numEdgeCollapses)->default_value(0),
136  "Edge collapse count. Number of edges to collapse for mesh reduction.")(
137  "tp", value<string>(&m_texturePack)->default_value(""), "Path to texture pack")(
138  "co",
139  value<string>(&m_statsCoeffs)->default_value(""),
140  "Coefficents file for texture matching based on statistics")(
141  "nsc",
142  value<unsigned int>(&m_numStatsColors)->default_value(16),
143  "Number of colors for texture statistics")(
144  "nccv",
145  value<unsigned int>(&m_numCCVColors)->default_value(64),
146  "Number of colors for texture matching based on color information")(
147  "ct",
148  value<unsigned int>(&m_coherenceThreshold)->default_value(50),
149  "Coherence threshold for texture matching based on color information")(
150  "colt",
151  value<float>(&m_colorThreshold)->default_value(FLT_MAX),
152  "Threshold for texture matching based on colors")(
153  "stat",
154  value<float>(&m_statsThreshold)->default_value(FLT_MAX),
155  "Threshold for texture matching based on statistics")(
156  "feat",
157  value<float>(&m_featuresThreshold)->default_value(FLT_MAX),
158  "Threshold for texture matching based on features")(
159  "cro", "Use texture matching based on cross correlation.")(
160  "patt",
161  value<float>(&m_patternThreshold)->default_value(100),
162  "Threshold for pattern extraction from textures")(
163  "mtv",
164  value<int>(&m_minimumTransformationVotes)->default_value(3),
165  "Minimum number of votes to consider a texture transformation as correct")(
166  "buff",
167  value<unsigned int>(&m_bufferSize)->default_value(30000000),
168  "Minimum number of votes to consider a texture transformation as correct")(
169  "nodeSize, ns",
170  value<unsigned int>(&m_octreeNodeSize)->default_value(1000000),
171  "Max. Number of Points in a leaf (used to devide pointcloud)")(
172  "outputFolder",
173  value<string>(&m_outputFolderPath)->default_value(""),
174  "Output Folder Path")("useGPU", "Use GPU for normal estimation")(
175  "flipPoint", value<vector<float>>()->multitoken(), "Flippoint, used for GPU normal calculation, multitoken option: use it like this: --flipPoint x y z")(
176  "lineReaderBuffer",
177  value<size_t>(&m_lineReaderBuffer)->default_value(1024),
178  "Size of input stream buffer when parsing point cloud files")(
179  "interpolateBoxes", "Interpolate Boxes in intersection BoundingBox of two Grids")(
180  "useNormals",
181  "the ply file contains normals")
182  ("bigMesh", value<bool>(&m_bigMesh)->default_value(true),"generate a .ply file of the reconstructed mesh")
183  ("debugChunks", value<bool>(&m_debugChunks)->default_value(false), "generate .ply file for every chunk")
184  ("scale",
185  value<float>(&m_scaling)->default_value(1),
186  "Scaling factor, applied to all input points")(
187  "volumenSize",
188  value<size_t>(&m_volumenSize)->default_value(0),
189  "The volumen of the partitions. Volume = (voxelsize*volumenSize)^3 if not set kd-tree will "
190  "be used")("onlyNormals", "If true, only normals will be generated");
191 
192  setup();
193 }
195 {
196  if (m_variables.count("help"))
197  {
198  cout << endl;
199  cout << m_descr << endl;
200  return true;
201  }
202  else if (!m_variables.count("inputFile"))
203  {
204  cout << "Error: You must specify an input file." << endl;
205  cout << endl;
206  cout << m_descr << endl;
207  return true;
208  }
209  return false;
210 }
211 
212 bool Options::getBigMesh() const { return m_variables["bigMesh"].as<bool>();}
213 
214 bool Options::getDebugChunks() const { return m_variables["debugChunks"].as<bool>();}
215 
216 bool Options::useGPU() const { return m_variables.count("useGPU"); }
217 
218 vector<float> Options::getVoxelSizes() const
219 {
220  vector<float> dest;
221  if (m_variables.count("voxelSizes"))
222  {
223  dest = (m_variables["voxelSizes"].as<vector<float>>());
224  }
225  else
226  {
227  dest.push_back(0.1);
228  }
229 
230  return dest;
231 }
232 
233 float Options::getVoxelsize() const { return getVoxelSizes()[0]; }
234 
235 float Options::getBGVoxelsize() const { return m_variables["bgVoxelSize"].as<float>(); }
236 
237 float Options::getScaling() const { return m_variables["scale"].as<float>(); }
238 
239 int Options::getChunkSize() const { return (m_variables["chunkSize"].as<int>()); }
240 
241 unsigned int Options::getNodeSize() const { return m_variables["nodeSize"].as<unsigned int>(); }
242 
243 int Options::getPartMethod() const { return (m_variables["partMethod"].as<int>()); }
244 
245 int Options::getKi() const { return m_variables["ki"].as<int>(); }
246 
247 int Options::getKd() const { return m_variables["kd"].as<int>(); }
248 
249 int Options::getKn() const { return m_variables["kn"].as<int>(); }
250 
251 bool Options::useRansac() const { return (m_variables.count("useRansac")); }
252 
253 bool Options::extrude() const { return m_extrude; }
254 
255 int Options::getDanglingArtifacts() const { return (m_variables["removeDanglingArtifacts"].as<int>()); }
256 
257 int Options::getCleanContourIterations() const { return m_variables["cleanContours"].as<int>(); }
258 
259 int Options::getFillHoles() const { return (m_variables["fillHoles"].as<int>()); }
260 
262 {
263  return m_variables.count("optimizePlanes") || m_variables.count("retesselate");
264 }
265 
266 float Options::getNormalThreshold() const { return m_variables["planeNormalThreshold"].as<float>(); }
267 
268 int Options::getPlaneIterations() const { return m_variables["planeIterations"].as<int>(); }
269 
271 
272 /*
273  * Definition from here on are not used (anymore?)
274  */
275 
276 
277 size_t Options::getLineReaderBuffer() const { return m_variables["lineReaderBuffer"].as<size_t>(); }
278 
279 unsigned int Options::getBufferSize() const { return m_variables["buff"].as<unsigned int>(); }
280 
281 
282 
283 
284 float Options::getSharpFeatureThreshold() const { return m_variables["sft"].as<float>(); }
285 
286 float Options::getSharpCornerThreshold() const { return m_variables["sct"].as<float>(); }
287 
288 int Options::getNumThreads() const { return m_variables["threads"].as<int>(); }
289 
290 
291 
292 int Options::getIntersections() const { return m_variables["intersections"].as<int>(); }
293 
294 
295 vector<string> Options::getInputFileName() const
296 {
297  return (m_variables["inputFile"].as<vector<string>>());
298 }
299 
300 string Options::getPCM() const { return (m_variables["pcm"].as<string>()); }
301 
302 string Options::getClassifier() const { return (m_variables["classifier"].as<string>()); }
303 
304 string Options::getEdgeCollapseMethod() const { return (m_variables["ecm"].as<string>()); }
305 
306 string Options::getDecomposition() const { return (m_variables["decomposition"].as<string>()); }
307 
308 string Options::getScanPoseFile() const { return (m_variables["scanPoseFile"].as<string>()); }
309 
310 int Options::getNumEdgeCollapses() const { return (m_variables["ecc"].as<int>()); }
311 
312 bool Options::saveFaceNormals() const { return m_variables.count("saveFaceNormals"); }
313 
315 {
316  return m_variables.count("writeClassificationResult") || m_variables.count("w");
317 }
318 
319 bool Options::doTextureAnalysis() const { return m_variables.count("textureAnalyis"); }
320 
322 {
323  return (m_variables["inputFile"].as<vector<string>>()).size() > 0;
324 }
325 
327 {
328  return (m_variables["outputFolder"].as<vector<string>>())[0];
329 }
330 
331 bool Options::recalcNormals() const { return (m_variables.count("recalcNormals")); }
332 
333 bool Options::savePointNormals() const { return (m_variables.count("exportPointNormals")); }
334 
335 bool Options::saveNormals() const { return (m_variables.count("saveNormals")); }
336 
337 bool Options::saveGrid() const { return (m_variables.count("saveGrid")); }
338 
339 bool Options::saveOriginalData() const { return (m_variables.count("saveOriginalData")); }
340 
341 bool Options::clusterPlanes() const { return m_variables.count("clusterPlanes"); }
342 
343 bool Options::colorRegions() const { return m_variables.count("colorRegions"); }
344 
345 bool Options::retesselate() const { return m_variables.count("retesselate"); }
346 
347 bool Options::generateTextures() const { return m_variables.count("generateTextures"); }
348 
350 {
351  return m_variables["smallRegionThreshold"].as<int>();
352 }
353 
354 int Options::getDepth() const { return m_depth; }
355 
356 float Options::getTexelSize() const { return m_texelSize; }
357 
358 float Options::getLineFusionThreshold() const { return m_variables["lineFusionThreshold"].as<float>(); }
359 
360 string Options::getTexturePack() const { return m_variables["tp"].as<string>(); }
361 
362 unsigned int Options::getNumStatsColors() const { return m_variables["nsc"].as<unsigned int>(); }
363 
364 unsigned int Options::getNumCCVColors() const { return m_variables["nccv"].as<unsigned int>(); }
365 
366 unsigned int Options::getCoherenceThreshold() const { return m_variables["ct"].as<unsigned int>(); }
367 
368 float Options::getColorThreshold() const { return m_variables["colt"].as<float>(); }
369 
370 float Options::getStatsThreshold() const { return m_variables["stat"].as<float>(); }
371 
372 float Options::getFeatureThreshold() const { return m_variables["feat"].as<float>(); }
373 
374 bool Options::getUseCrossCorr() const { return m_variables.count("cro"); }
375 
376 float Options::getPatternThreshold() const { return m_variables["patt"].as<float>(); }
377 
378 int Options::getMinimumTransformationVotes() const { return m_variables["mtv"].as<int>(); }
379 
380 bool Options::interpolateBoxes() const { return m_variables.count("interpolateBoxes"); }
381 
382 bool Options::getUseNormals() const { return m_variables.count("useNormals"); }
383 size_t Options::getVolumenSize() const { return m_variables["volumenSize"].as<size_t>(); }
384 
385 bool Options::onlyNormals() const { return m_variables.count("onlyNormals"); }
387 {
388  float* result = new float[14];
389  std::ifstream in(m_variables["tp"].as<string>().c_str());
390  if (in.good())
391  {
392  for (int i = 0; i < 14; i++)
393  {
394  in >> result[i];
395  }
396  in.close();
397  }
398  else
399  {
400  for (int i = 0; i < 14; i++)
401  {
402  result[i] = 0.5;
403  }
404  }
405  return result;
406 }
407 
408 vector<float> Options::getFlippoint() const
409 {
410  vector<float> dest;
411  if (m_variables.count("flipPoint"))
412  {
413  dest = (m_variables["flipPoint"].as<vector<float>>());
414  if (dest.size() != 3)
415  {
416  dest.clear();
417  dest.push_back(10000000);
418  dest.push_back(10000000);
419  dest.push_back(10000000);
420  }
421  }
422  else
423  {
424  dest.push_back(10000000);
425  dest.push_back(10000000);
426  dest.push_back(10000000);
427  }
428  return dest;
429 }
430 
432 {
433  // TODO Auto-generated destructor stub
434 }
435 
436 } // namespace LargeScaleOptions
float getLineFusionThreshold() const
Returns the fusion threshold for tesselation.
int m_ki
The number of neighbors for normal interpolation.
bool generateTextures() const
If true, textures will be generated during finalization of mesh.
string getScanPoseFile() const
Returns the name of the given file with scan poses used for normal flipping.
string m_classifier
Name of the classifier object to color the mesh.
float getSharpFeatureThreshold() const
Returns the sharp feature threshold when using sharp feature decomposition.
bool optimizePlanes() const
Returns true if cluster optimization is enabled.
static int getNumThreads()
Returns the number of supported threads (or 1 if OpenMP is not supported)
Definition: lvropenmp.cpp:70
int m_planeIterations
Number of iterations for plane optimzation.
int getNumEdgeCollapses() const
Number of edge collapses.
int getNumThreads() const
Returns the number of used threads.
int getDanglingArtifacts() const
Returns the number of dangling artifacts to remove from a created mesh.
float m_featuresThreshold
Threshold for texture matching based on features.
virtual void setup()
Setup internal data structures.
Definition: BaseOption.cpp:84
int m_chunkSize
gridsize for virtual grid
float m_sft
Sharp feature threshold when using sharp feature decomposition.
bool extrude() const
Whether to extend the grid. Enabled by default.
bool saveFaceNormals() const
Returns true if the face normals of the reconstructed mesh should be saved to an extra file ("face_no...
int getPartMethod() const
Retuns flag for partition-method (0 = kd-Tree; 1 = VGrid)
int m_depth
Maximum recursion depth for region growing.
int m_minPlaneSize
Threshold for plane optimization.
unsigned int getBufferSize() const
bool useGPU() const
Returns if the GPU shuold be used for the normal estimation.
int getKn() const
Returns the number of neighbors used for initial normal estimation.
int m_removeDanglingArtifacts
Number of dangling artifacts to remove.
float getVoxelsize() const
Returns the first given voxelsize.
unsigned int m_coherenceThreshold
Coherence threshold for texture matching based on color information.
bool printUsage() const
Prints a usage message to stdout.
float m_lineFusionThreshold
Threshold for line fusing when tesselating.
bool doTextureAnalysis() const
True if texture analysis is enabled.
int m_kn
The number of neighbors for normal estimation.
float m_sct
Sharp corner threshold when using sharp feature decomposition.
float m_planeNormalThreshold
Threshold for plane optimization.
int getKi() const
Returns the number of neighbors for normal interpolation.
bool saveNormals() const
Returns true if the interpolated normals should be saved in the putput file.
int m_partMethod
sets partition method to kd-tree or virtual grid
options_description m_descr
The internally used option description.
Definition: BaseOption.hpp:107
bool getDebugChunks() const
Returns if the mesh of every chunk additionally should be written as a .ply.
float getNormalThreshold() const
Returns the normal threshold for plane optimization.
float getScaling() const
Returns the scaling factor.
float m_patternThreshold
Threshold for pattern extraction from textures.
int getDepth() const
Returns the maximum recursion depth for region growing.
unsigned int getNumStatsColors() const
int m_minimumTransformationVotes
Minimum number of vote to consider a texture transformation as "correct".
int m_smallRegionThreshold
Threshold for small regions.
float m_colorThreshold
Threshold for texture matching based on colors.
int getPlaneIterations() const
Returns to number plane optimization iterations.
bool filenameSet() const
Returns true if an output filen name was set.
std::vector< string > getInputFileName() const
Returns the output file name.
int getMinPlaneSize() const
Minimum value for plane optimzation.
bool savePointNormals() const
Indicates whether to save the used points together with the interpolated normals. ...
int m_cleanContourIterations
number of cleanContour iterations
vector< float > getFlippoint() const
Returns the flipPoint for GPU normal computation.
unsigned int getCoherenceThreshold() const
int m_numThreads
The number of used threads.
string m_statsCoeffs
Coefficents file for texture matching based on statistics.
bool colorRegions() const
Returns true of region coloring is enabled.
string m_pcm
The used point cloud manager.
float m_voxelsizeBG
The set voxelsize for BigGrid.
int m_kd
The number of neighbors for distance function evaluation.
int getFillHoles() const
Returns the region threshold for hole filling.
float m_statsThreshold
Threshold for texture matching based on statistics.
string getDecomposition() const
Returns the name of the used point cloud handler.
vector< float > m_voxelSizes
The set voxelsizes.
unsigned int m_numStatsColors
Number of colors for texture statistics.
bool saveGrid() const
Returns true if the Marching Cubes grid should be save.
int getSmallRegionThreshold() const
Returns the threshold for the size of small region deletion after plane optimization.
string m_ecm
Edge collapse method.
variables_map m_variables
The internally used variable map.
Definition: BaseOption.hpp:104
bool recalcNormals() const
If true, normals should be calculated even if they are already given in the input file...
float getSharpCornerThreshold() const
Returns the sharp corner threshold when using sharp feature decomposition.
bool clusterPlanes() const
True if region clustering without plane optimization is required.
int getCleanContourIterations() const
Number of iterations for contour cleanup.
bool m_debugChunks
flag to generate debug meshes for every chunk as a .ply
int m_intersections
The number of intersections used for reconstruction.
int m_numEdgeCollapses
Number of edge collapses.
string getEdgeCollapseMethod() const
Edge collapse method.
bool writeClassificationResult() const
True if region clustering without plane optimization is required.
unsigned int getNodeSize() const
Only used in kd-tree (partMethod=0). Returns the maximum number of points in a leaf.
bool useRansac() const
If true, RANSAC based normal estimation is used.
bool retesselate() const
Return whether the mesh should be retesselated or not.
int getKd() const
Returns the number of neighbors used for distance function evaluation.
string getClassifier() const
Returns the name of the classifier used to color the mesh.
bool saveOriginalData() const
Returns true if the original points should be stored together with the reconstruction.
float getTexelSize() const
Returns the texel size for texture resolution.
bool m_bigMesh
flag to generate a .ply file for the reconstructed mesh
int getChunkSize() const
Returns the chunksize.
int getIntersections() const
Returns the number of intersections. If the return value is positive it will be used for reconstructi...
int m_fillHoles
Threshold for hole filling.
string getPCM() const
Returns the name of the used point cloud handler.
float getBGVoxelsize() const
Returns the given voxelsize for bigGrid.
unsigned int getNumCCVColors() const
unsigned int m_numCCVColors
Number of colors for texture matching based on color information.
vector< float > getVoxelSizes() const
Returns all voxelsizes as a vector.
string m_texturePack
Path to texture pack.
Options(int argc, char **argv)
Ctor. Parses the command parameters given to the main function of the program.
bool getBigMesh() const
Returns if the new chunks should be written as a .ply-mesh.
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:06