forked from SurfaceMan/surface_match
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicp.h
101 lines (89 loc) · 3.11 KB
/
icp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#include <privateType.h>
#include <type.h>
namespace ppf {
struct ConvergenceCriteria {
public:
/**
* @brief Convergence Criteria
*
* @param iterations max iterations for optimization
* @param rejectDist rejection for corresponding set
* @param mseMin min mean-squared-error
* @param mseMax max mean-squared-error indicate whether be converged
* @param tolerance min converge rate
*/
ConvergenceCriteria(int iterations, float rejectDist, float mseMin, float mseMax,
float tolerance = 0.05f);
int iterations;
float rejectDist;
float mseMin;
float mseMax;
float tolerance;
};
enum class ConvergenceType {
ITER, // reach max iterations
MSE, // reach min mean-squared-error
CONVERGE_RATE, // reach min converge rate
NO_CORRESPONDS // no corresponding set
};
struct ConvergenceResult {
ConvergenceResult();
Eigen::Matrix4f pose; // last pose refined
ConvergenceType type; // which cause converge
float mse; // last mse
float convergeRate; // last converge rate
int iterations; // last iteration
bool converged; // whether be converged
};
class ICP {
public:
explicit ICP(ConvergenceCriteria criteria);
~ICP() = default;
/**
* @brief register source to target
*
* @param src source must has normal
* @param dst target must has normal
* @param initPose source initial pose
* @return ConvergenceResult
*/
ConvergenceResult regist(const PointCloud &src, const PointCloud &dst,
const Eigen::Matrix4f &initPose = Eigen::Matrix4f::Identity()) const;
/**
* @brief register source to target
*
* @param src source must has normal
* @param dst target must has normal
* @param kdtree KDTree for target point
* @param initPose source initial pose
* @return ConvergenceResult
*/
ConvergenceResult regist(const PointCloud &src, const PointCloud &dst, const KDTree &kdtree,
const Eigen::Matrix4f &initPose = Eigen::Matrix4f::Identity()) const;
/**
* @brief register source to target
*
* @param src source
* @param dst target
* @param initPose source initial pose
* @return std::vector<ConvergenceResult> same order as initPose
*/
std::vector<ConvergenceResult> regist(const PointCloud &src, const PointCloud &dst,
const std::vector<Eigen::Matrix4f> &initPose) const;
/**
* @brief register source to target
*
* @param src source must has normal
* @param dst target must has normal
* @param kdtree KDTree for target point
* @param initPose source initial pose
* @return ConvergenceResult
*/
std::vector<ConvergenceResult> regist(const PointCloud &src, const PointCloud &dst,
const KDTree &kdtree,
const std::vector<Eigen::Matrix4f> &initPose) const;
private:
ConvergenceCriteria criteria_;
};
} // namespace ppf