icp_simple.cpp
Go to the documentation of this file.
1 // kate: replace-tabs off; indent-width 4; indent-mode normal
2 // vim: ts=4:sw=4:noexpandtab
3 /*
4 
5 Copyright (c) 2010--2012,
6 François Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
7 You can contact the authors at <f dot pomerleau at gmail dot com> and
8 <stephane at magnenat dot net>
9 
10 All rights reserved.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of the <organization> nor the
20  names of its contributors may be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
37 #include <cassert>
38 #include <iostream>
39 #include "boost/filesystem.hpp"
40 
41 using namespace std;
42 
43 void validateArgs(int argc, char *argv[], bool& isCSV);
44 
49 int main(int argc, char *argv[])
50 {
51  bool isCSV = true;
52  validateArgs(argc, argv, isCSV);
53 
54  typedef PointMatcher<float> PM;
55  typedef PM::DataPoints DP;
56 
57  // Load point clouds
58  const DP ref(DP::load(argv[1]));
59  const DP data(DP::load(argv[2]));
60 
61  // Create the default ICP algorithm
62  PM::ICP icp;
63 
64  // See the implementation of setDefault() to create a custom ICP algorithm
65  icp.setDefault();
66 
67  // Compute the transformation to express data in ref
69 
70  // Transform data to express it in ref
71  DP data_out(data);
72  icp.transformations.apply(data_out, T);
73 
74  // Safe files to see the results
75  ref.save("test_ref.vtk");
76  data.save("test_data_in.vtk");
77  data_out.save("test_data_out.vtk");
78  cout << "Final transformation:" << endl << T << endl;
79 
80  return 0;
81 }
82 
83 void validateArgs(int argc, char *argv[], bool& isCSV )
84 {
85  if (argc != 3)
86  {
87  cerr << "Wrong number of arguments, usage " << argv[0] << " reference.csv reading.csv" << endl;
88  cerr << "Will create 3 vtk files for inspection: ./test_ref.vtk, ./test_data_in.vtk and ./test_data_out.vtk" << endl;
89  cerr << endl << "2D Example:" << endl;
90  cerr << " " << argv[0] << " ../../examples/data/2D_twoBoxes.csv ../../examples/data/2D_oneBox.csv" << endl;
91  cerr << endl << "3D Example:" << endl;
92  cerr << " " << argv[0] << " ../../examples/data/car_cloud400.csv ../../examples/data/car_cloud401.csv" << endl;
93  exit(1);
94  }
95 }
build_map.T
T
Definition: build_map.py:34
DataPoints
PM::DataPoints DataPoints
Definition: pypoint_matcher_helper.h:16
PointMatcher< float >
align_sequence.icp
icp
Definition: align_sequence.py:40
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
icp.data
data
Definition: icp.py:50
icp.data_out
data_out
Definition: icp.py:93
ICP
PM::ICP ICP
Definition: pypoint_matcher_helper.h:33
icp.ref
ref
Definition: icp.py:49
main
int main(int argc, char *argv[])
Definition: icp_simple.cpp:49
std
icp
Definition: icp.py:1
DP
PM::DataPoints DP
Definition: convert.cpp:45
PM
PointMatcher< float > PM
Definition: eval_solution.cpp:61
validateArgs
void validateArgs(int argc, char *argv[], bool &isCSV)
Definition: icp_simple.cpp:83
PointMatcher::DataPoints::load
static DataPoints load(const std::string &fileName)
Load a point cloud from a file, determine format from extension.
Definition: pointmatcher/IO.cpp:375
PointMatcher.h
public interface
PointMatcher< float >::TransformationParameters
Matrix TransformationParameters
A matrix holding the parameters a transformation.
Definition: PointMatcher.h:182


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:09