Some problems about using the least squares vector of lming_08

Source: Internet
Author: User

Lming_08

How are you doing.

I'm quoting you. Surface normal vector based on least squares method for estimating point clouds some problems encountered in this article, if you can see, please enlighten me.

1. The result of using _method1_ and least squares method is exactly the same.

2, the use of _method2_, the problem is as follows

I slightly changed the plane normal vector code (second coordinate system) directly applied to find the plane equation of point, In the process of using the discrete point is not a plane is fitted out of the plane equation and the least squares to fit the results of the equation difference and large (you give an example of the point cloud to fit the plane and the least squares to fit the plane equation), I can directly use whether it is possible, the question is where it is.


I'm using the point cloud to fit the plane's code

void Computepointnormal (const PCL::P OINTCLOUD<PCL::P ointxyz> &cloud, float &nx, float &ny, float
	&nz,float &nd) {#define _METHOD2_ #ifdef _method2_ eigen::matrixx4f mat_ext (Cloud.size (), 4);
		for (size_t i = 0, ind_num = cloud.size (); i < Ind_num; ++i) {Mat_ext (i, 0) = cloud.points[i].x;
		Mat_ext (i, 1) = CLOUD.POINTS[I].Y;
		Mat_ext (i, 2) = Cloud.points[i].z;
	Mat_ext (i, 3) = 1;    } eigen::matrixxf Mat_mult_ext = Mat_ext.transpose () * MAT_EXT;
	The mat is the 3*k_ matrix, Mat_ext is the k_*4 matrix//a*x = B, A.row (0). Cross (A.row (1)) = eigenvector (0);
	eigen::vector4f Row_vec[3];
	Row_vec[0] = mat_mult_ext.row (0);
	ROW_VEC[1] = Mat_mult_ext.row (1);
	ROW_VEC[2] = Mat_mult_ext.row (2);    eigen::matrix3f I_cofactor, J_cofactor, K_cofactor, L_cofactor; When calculating the cross product, the algebraic cofactor for the I, J, K, L components (size_t row_index = 0; row_index < 3; ++row_index) {for (size_t col_index = 0; col_in Dex < 3; ++col_index) {i_cofactor (Row_index, col_index) = Row_vec[row_index][col_index + 1];
			if (Col_index < 1) {J_cofactor (Row_index, col_index) = Row_vec[row_index][col_index];
			} else {j_cofactor (row_index, col_index) = Row_vec[row_index][col_index + 1];
			} if (Col_index < 2) {K_cofactor (Row_index, col_index) = Row_vec[row_index][col_index];
			} else {k_cofactor (row_index, col_index) = Row_vec[row_index][col_index + 1];
		} l_cofactor (Row_index, col_index) = Row_vec[row_index][col_index];
	}} Float I_dim = 0, J_dim = 0, K_dim = 0, L_dim = 0;
	I_dim = I_cofactor.determinant ();
	J_dim = J_cofactor.determinant ();
	K_dim = K_cofactor.determinant ();
	L_dim = L_cofactor.determinant ();
eigen::vector4f Coeff_vec (I_dim,-j_dim, K_dim,-l_dim);
eigen::vector4f argument = MAT_MULT_EXT.COLPIVHOUSEHOLDERQR (). Solve (b);
	eigen::vector4f Coeff_vec11 (argument[0], argument[1], argument[2],argument[3]);

Coeff_vec.squarednorm ();
eigen::vector3f Coeff_vec (I_dim,-j_dim, K_dim); float len = coeff_vec.sqUarednorm ();
 	Coeff_vec/= Len;

	Coeff_vec/= K_dim;
	NX = Coeff_vec[0];
	NY = coeff_vec[1];
	NZ = coeff_vec[2];
	
nd = coeff_vec[3];
 #endif}

The point cloud that I used to test

X YZ
P1 0 00.01
P2 0 10.2
P3 0 2-0.2
P4 1 00.25
P5 1 1-0.3
P6 1 2-0.1
P7 2 00.2
P8 2 1-0.2
P9 2 20.15


The equation of least squares fitting
z = 0.079 + 0.023x + -0.102y
The equation that your program fits
Z=1.645+0.563x+0.689y
Please enlighten me. Thank you


If you are willing to answer my questions, please leave a message or contact me dearpeer@126.com 719594159

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.