2 #ifndef vgl_fit_plane_3d_hxx_ 3 #define vgl_fit_plane_3d_hxx_ 11 # include <vcl_msvc_warnings.h> 14 #include <vnl/algo/vnl_svd.h> 15 #include <vnl/vnl_matrix.h> 19 : points_(std::move(points))
45 T min = this->fit(errstream);
46 if (min > error_marg) {
47 if (errstream) *errstream <<
"Error Margin " << error_marg <<
'<' << min <<
". Could not fit the points to a plane\n";
60 *errstream <<
"there is a problem with norm transform\n";
64 T A=0, B=0, C=0, D=0, E=0, F=0, G=0, H=0, I=0;
65 const unsigned n = static_cast<const unsigned>(points_.size());
66 for (
unsigned i=0; i<n; i++) {
67 points_[i] = norm(points_[i]);
68 const T x = points_[i].x()/points_[i].w();
69 const T y = points_[i].y()/points_[i].w();
70 const T z = points_[i].z()/points_[i].w();
82 vnl_matrix<T> coeff_matrix(4,4);
83 coeff_matrix(0, 0) = D;
84 coeff_matrix(0, 1) = G;
85 coeff_matrix(0, 2) = I;
86 coeff_matrix(0, 3) = A;
88 coeff_matrix(1, 0) = G;
89 coeff_matrix(1, 1) = E;
90 coeff_matrix(1, 2) = H;
91 coeff_matrix(1, 3) = B;
93 coeff_matrix(2, 0) = I;
94 coeff_matrix(2, 1) = H;
95 coeff_matrix(2, 2) = F;
96 coeff_matrix(2, 3) = C;
98 coeff_matrix(3, 0) = A;
99 coeff_matrix(3, 1) = B;
100 coeff_matrix(3, 2) = C;
101 coeff_matrix(3, 3) = T(n);
103 vnl_svd<T> svd(coeff_matrix);
107 vnl_vector<T> s = svd.nullvector();
110 vnl_matrix_fixed<T,4,4> N_transp=norm.
get_matrix().transpose();
120 return svd.sigma_min();
124 #undef VGL_FIT_PLANE_3D_INSTANTIATE 125 #define VGL_FIT_PLANE_3D_INSTANTIATE(T) \ 126 template class vgl_fit_plane_3d<T > 128 #endif // vgl_fit_plane_3d_hxx_
void clear()
clear internal data.
Represents a homogeneous 3D point.
bool fit(const T error_marg, std::ostream *outstream=nullptr)
fits a plane to the stored points.
void add_point(vgl_homg_point_3d< T > const &p)
add a point to point set.
bool compute_from_points(std::vector< vgl_homg_point_3d< T > > const &points)
compute the normalizing transform.
vnl_matrix_fixed< T, 4, 4 > const & get_matrix() const
Return the 4x4 homography matrix.
vgl_fit_plane_3d()=default
The similarity transform that normalizes a 3-d point set.
Fits a plane to a set of 3D points.