41 #include <boost/lexical_cast.hpp>
47 void setupArgs(
int argc,
char *argv[],
unsigned int& startId,
unsigned int& endId,
string& extension);
57 int main(
int argc,
char *argv[])
68 const unsigned totalPointCount = boost::lexical_cast<unsigned>(argv[2]);
69 string outputFileName(argv[3]);
77 TP T = TP::Identity(4,4);
84 std::shared_ptr<PM::DataPointsFilter> removeScanner =
85 PM::get().DataPointsFilterRegistrar.create(
86 "MinDistDataPointsFilter",
91 std::shared_ptr<PM::DataPointsFilter> randSubsample =
92 PM::get().DataPointsFilterRegistrar.create(
93 "RandomSamplingDataPointsFilter",
99 std::shared_ptr<PM::DataPointsFilter> normalFilter =
100 PM::get().DataPointsFilterRegistrar.create(
101 "SurfaceNormalDataPointsFilter",
110 std::shared_ptr<PM::DataPointsFilter> densityFilter =
111 PM::get().DataPointsFilterRegistrar.create(
112 "SurfaceNormalDataPointsFilter",
116 {
"keepDensities",
"1"},
121 std::shared_ptr<PM::DataPointsFilter> observationDirectionFilter =
122 PM::get().DataPointsFilterRegistrar.create(
123 "ObservationDirectionDataPointsFilter"
126 std::shared_ptr<PM::DataPointsFilter> orientNormalFilter =
127 PM::get().DataPointsFilterRegistrar.create(
128 "OrientNormalsDataPointsFilter",
129 {{
"towardCenter",
"1"}}
132 std::shared_ptr<PM::DataPointsFilter> uniformSubsample =
133 PM::get().DataPointsFilterRegistrar.create(
134 "MaxDensityDataPointsFilter",
138 std::shared_ptr<PM::DataPointsFilter> shadowFilter =
139 PM::get().DataPointsFilterRegistrar.create(
140 "ShadowDataPointsFilter"
143 for(
unsigned i=0; i < list.size(); i++)
145 cout << endl <<
"-----------------------------" << endl;
146 cout <<
"Loading " << list[i].readingFileName;
147 newCloud =
DP::load(list[i].readingFileName);
149 cout <<
" found " << newCloud.getNbPoints() <<
" points. " << endl;
152 if(list[i].groundTruthTransformation.rows() != 0)
153 T = list[i].groundTruthTransformation;
156 cout <<
"ERROR: the field gTXX (ground truth) is required" << endl;
163 newCloud = removeScanner->filter(newCloud);
167 newCloud = randSubsample->filter(newCloud);
170 newCloud = normalFilter->filter(newCloud);
171 newCloud = observationDirectionFilter->filter(newCloud);
172 newCloud = orientNormalFilter->filter(newCloud);
173 newCloud = shadowFilter->filter(newCloud);
176 cout <<
"Transformation matrix: " << endl <<
T << endl;
185 mapCloud.concatenate(newCloud);
188 double probToKeep = totalPointCount/(double)mapCloud.features.cols();
192 mapCloud = densityFilter->filter(mapCloud);
193 mapCloud = uniformSubsample->filter(mapCloud);
195 probToKeep = totalPointCount/(double)mapCloud.features.cols();
199 cout <<
"Randomly keep " << probToKeep*100 <<
"\% points" << endl;
200 randSubsample =
PM::get().DataPointsFilterRegistrar.create(
201 "RandomSamplingDataPointsFilter",
202 {{
"prob",
toParam(probToKeep)}}
204 mapCloud = randSubsample->filter(mapCloud);
209 stringstream outputFileNameIter;
210 outputFileNameIter << std::filesystem::path(outputFileName).stem().c_str() <<
"_" << i <<
".vtk";
212 mapCloud.save(outputFileNameIter.str());
215 mapCloud = densityFilter->filter(mapCloud);
216 mapCloud = uniformSubsample->filter(mapCloud);
218 mapCloud = densityFilter->filter(mapCloud);
221 cout <<
"-----------------------------" << endl;
222 cout <<
"-----------------------------" << endl;
223 cout <<
"Final number of points in the map: " << mapCloud.getNbPoints() << endl;
224 mapCloud.save(outputFileName);
235 cerr <<
"Error in command line, usage " << argv[0] <<
" listOfFiles.csv maxPoint outputFileName.{vtk,csv,ply}" << endl;
237 cerr <<
" example using file from example/data: " << endl;
238 cerr <<
" " << argv[0] <<
" carCloudList.csv 30000 test.vtk" << endl;
240 cerr <<
"Note: the file listOfFiles.csv need to include a serialize transformation matrix. For example:" << endl;
241 cerr <<
" fileName1.vtk, T00, T01, T02, T03, T10, T11, T12, T13, T20, T21, T22, T23, T30, T31, T32" << endl;
243 cerr <<
"Where Txy would be a 4x4 transformation matrix:" << endl;
244 cerr <<
" [T00 T01 T02 T03] " << endl;
245 cerr <<
" [T10 T11 T12 T13] " << endl;
246 cerr <<
" [T20 T21 T22 T23] " << endl;
247 cerr <<
" [T30 T31 T32 T33] (i.e., 0,0,0,1)" << endl;
249 cerr <<
"For more data visit:" << endl;
250 cerr <<
" http://projects.asl.ethz.ch/datasets/doku.php?id=laserregistration:laserregistration" << endl;