pclpy icon indicating copy to clipboard operation
pclpy copied to clipboard

I get something wrong with the function 'compute3DCentroid'

Open laiming997 opened this issue 4 years ago • 8 comments

Thank you for your work of the pcl to python. And when I use the pclpy to compute the point cloud centroid and compute Covariance Matrix. I was confused about the result I get. I initialize a array which is [[1.0],[1.0],[1.0],[1.0]], and it's the array([4,1],float) variable,when I use this code pcl.common.compute3DCentroid(cloud_filter,centroid) to compute, the result is always [[1.0],[1.0],[1.0],[1.0]], it has no change , and the function result I get is the size of the pointCloud which is mean the Centroid has no change. But when I use this code pcl.common.computeCentroid(cloud_filter,centroid_point) , I get the normal result . Is there any problem of my usage? How can I compute the Centroid correctly?

laiming997 avatar Apr 11 '20 17:04 laiming997

@davidcaron

laiming997 avatar Apr 11 '20 17:04 laiming997

I can't find the function pcl.common.compute3DCentroid in pclpy

Marvelsh avatar May 26 '20 12:05 Marvelsh

Thank you for your work of the pcl to python. And when I use the pclpy to compute the point cloud centroid and compute Covariance Matrix. I was confused about the result I get. I initialize a array which is [[1.0],[1.0],[1.0],[1.0]], and it's the array([4,1],float) variable,when I use this code pcl.common.compute3DCentroid(cloud_filter,centroid) to compute, the result is always [[1.0],[1.0],[1.0],[1.0]], it has no change , and the function result I get is the size of the pointCloud which is mean the Centroid has no change. But when I use this code pcl.common.computeCentroid(cloud_filter,centroid_point) , I get the normal result . Is there any problem of my usage? How can I compute the Centroid correctly?

so ami i,have u detail it

naah69 avatar Jul 16 '20 04:07 naah69

You're right that the compute3DCentroid function is not there.

For this case, I think I would suggest using numpy. You can get a numpy view of the points (no memory is copied) by using the .xyz property:

>>> import pclpy
>>> import numpy as np
>>> pc = pclpy.pcl.PointCloud.PointXYZ.from_array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 1]])
>>> np.cov(pc.xyz.T)
array([[0.33333333, 0.        , 0.        ],
       [0.        , 0.33333333, 0.        ],
       [0.        , 0.        , 0.33333333]])
>>> centroid = pc.xyz.mean(axis=0)
>>> centroid
array([0.5, 0.5, 0.5], dtype=float32)

davidcaron avatar Jul 16 '20 12:07 davidcaron

is there computeCovarianceMatrixNormalized? it didn't change too

naah69 avatar Jul 16 '20 13:07 naah69

At first glance, I'm not sure why some on these functions didn't get compiled. They probably have arguments or outputs that are tricky to bind to python.

davidcaron avatar Jul 16 '20 13:07 davidcaron

oh,It's really a sad story

naah69 avatar Jul 16 '20 13:07 naah69

i found that both of compute3DCentroid and computeCovarianceMatrixNormalized are use numpy array as param.

are the others same problem?

naah69 avatar Jul 16 '20 13:07 naah69