39 #include "boost/filesystem.hpp"
54 int main(
int argc,
char *argv[])
60 typedef PM::DataPoints
DP;
75 name =
"MinDistDataPointsFilter";
76 params[
"minDist"] =
"1.0";
77 std::shared_ptr<PM::DataPointsFilter> minDist_read =
78 PM::get().DataPointsFilterRegistrar.create(name, params);
81 name =
"RandomSamplingDataPointsFilter";
82 params[
"prob"] =
"0.05";
83 std::shared_ptr<PM::DataPointsFilter> rand_read =
84 PM::get().DataPointsFilterRegistrar.create(name, params);
88 name =
"MinDistDataPointsFilter";
89 params[
"minDist"] =
"1.0";
90 std::shared_ptr<PM::DataPointsFilter> minDist_ref =
91 PM::get().DataPointsFilterRegistrar.create(name, params);
94 name =
"RandomSamplingDataPointsFilter";
95 params[
"prob"] =
"0.05";
96 std::shared_ptr<PM::DataPointsFilter> rand_ref =
97 PM::get().DataPointsFilterRegistrar.create(name, params);
101 name =
"KDTreeMatcher";
103 params[
"epsilon"] =
"3.16";
104 std::shared_ptr<PM::Matcher> kdtree =
105 PM::get().MatcherRegistrar.create(name, params);
109 name =
"TrimmedDistOutlierFilter";
110 params[
"ratio"] =
"0.75";
111 std::shared_ptr<PM::OutlierFilter> trim =
112 PM::get().OutlierFilterRegistrar.create(name, params);
116 name =
"PointToPointErrorMinimizer";
117 std::shared_ptr<PM::ErrorMinimizer> pointToPoint =
118 PM::get().ErrorMinimizerRegistrar.create(name);
121 name =
"CounterTransformationChecker";
122 params[
"maxIterationCount"] =
"150";
123 std::shared_ptr<PM::TransformationChecker> maxIter =
124 PM::get().TransformationCheckerRegistrar.create(name, params);
127 name =
"DifferentialTransformationChecker";
128 params[
"minDiffRotErr"] =
"0.001";
129 params[
"minDiffTransErr"] =
"0.01";
130 params[
"smoothLength"] =
"4";
131 std::shared_ptr<PM::TransformationChecker> diff =
132 PM::get().TransformationCheckerRegistrar.create(name, params);
136 std::shared_ptr<PM::Inspector> nullInspect =
137 PM::get().InspectorRegistrar.create(
"NullInspector");
149 std::shared_ptr<PM::Transformation> rigidTrans =
150 PM::get().TransformationRegistrar.create(
"RigidTransformation");
153 icp.readingDataPointsFilters.push_back(minDist_read);
154 icp.readingDataPointsFilters.push_back(rand_read);
156 icp.referenceDataPointsFilters.push_back(minDist_ref);
157 icp.referenceDataPointsFilters.push_back(rand_ref);
159 icp.matcher = kdtree;
161 icp.outlierFilters.push_back(trim);
163 icp.errorMinimizer = pointToPoint;
165 icp.transformationCheckers.push_back(maxIter);
166 icp.transformationCheckers.push_back(diff);
169 icp.inspector = nullInspect;
172 icp.transformations.push_back(rigidTrans);
179 icp.transformations.apply(data_out, T);
182 ref.
save(
"test_ref.vtk");
183 data.
save(
"test_data_in.vtk");
184 data_out.
save(
"test_data_out.vtk");
185 cout <<
"Final transformation:" << endl << T << endl;
194 cerr <<
"Wrong number of arguments, usage " << argv[0] <<
" reference.csv reading.csv" << endl;
195 cerr <<
"Will create 3 vtk files for inspection: ./test_ref.vtk, ./test_data_in.vtk and ./test_data_out.vtk" << endl;
196 cerr << endl <<
"2D Example:" << endl;
197 cerr <<
" " << argv[0] <<
" ../../examples/data/2D_twoBoxes.csv ../../examples/data/2D_oneBox.csv" << endl;
198 cerr << endl <<
"3D Example:" << endl;
199 cerr <<
" " << argv[0] <<
" ../../examples/data/car_cloud400.csv ../../examples/data/car_cloud401.csv" << endl;