Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accuracy difference between np.cov and pcl.common.compute_mean_and_covariance_matrix #1

Closed
cmpute opened this issue Jul 14, 2017 · 0 comments
Assignees

Comments

@cmpute
Copy link
Owner

cmpute commented Jul 14, 2017

Reproduction code:

rdata = np.random.rand(1000, 3)
cloudx = rdata[:, 0]
cloudy = rdata[:, 1]
cloudz = rdata[:, 2]
coef_xx = np.mean(cloudx * cloudx)
coef_xy = np.mean(cloudx * cloudy)
coef_xz = np.mean(cloudx * cloudz)
coef_yy = np.mean(cloudy * cloudy)
coef_yz = np.mean(cloudy * cloudz)
coef_zz = np.mean(cloudz * cloudz)
coef_x, coef_y, coef_z = np.mean(rdata, axis=0)
cov = np.zeros((3, 3))
cov[0, 0] = coef_xx - coef_x**2
cov[1, 1] = coef_yy - coef_y**2
cov[2, 2] = coef_zz - coef_z**2
cov[0, 1] = cov[1, 0] = coef_xy - coef_x*coef_y
cov[0, 2] = cov[2, 0] = coef_xz - coef_x*coef_z
cov[1, 2] = cov[2, 1] = coef_yz - coef_y*coef_z

npcov = np.cov(rdata, rowvar=False)
print((npcov - cov) / npcov)

Running for times and the outputs are the same:

[[ 0.001  0.001  0.001]
 [ 0.001  0.001  0.001]
 [ 0.001  0.001  0.001]]

If test the difference in pcl.features.normal.compute_point_normal(), the output matrix always consists of scalar 0.2, which is quite large. I think the problem comes with the accuracy configuration of numpy, however, I've got no idea to deal with it now.

There's another issue in normal estimation that the estimated normals are almost all the same, only few of them at the beginning are not the same. I believe this is the consequence of the deviation in covariance matrix computation.

@cmpute cmpute self-assigned this Jul 14, 2017
cmpute referenced this issue Jul 14, 2017
precision problem occurs, implement RegionGrow in the next
@cmpute cmpute closed this as completed Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant