问题
i want to calculate the "density" of a 3d point cloud obtained by stereo vision.
I implemented the 3D Voronoi diagram like in https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.SphericalVoronoi.html
Result is raise ValueError("Radius inconsistent with generators.")
for many different magnitudes (i tried a lot)
Example of my pointcloud is:
[[ 0.63492548 0.10921954 0.12711886]
[ 0.14530358 0.02687934 -0.0357723 ]
[ 0.16594444 0.02741969 0.04187516]
[ 0.69606036 0.06983382 -0.04752853]
[ 0.31324029 -0.10254659 -0.06861327]
[ 0.14450935 -0.07421818 -0.07544217]
[ 0.66847998 0.08925844 0.2252084 ]
[ 0.17888862 0.02983894 0.01823071]
[ 0.65812635 0.1793924 -0.00177464]
[ 0.7880221 0.25733843 -0.22293468]]
a) How can I fix this?
b) And my point cloud is also changing depending where I am (point cloud are real world coordinates). So I need a adaptive metric to input radius depending on the pointcloud itself I think?
And ideas? Thanks a lot!:)
回答1:
def voronoi_volumes(points):
v = Voronoi(points)
vol = np.zeros(v.npoints)
for i, reg_num in enumerate(v.point_region):
indices = v.regions[reg_num]
if -1 in indices: # some regions can be opened
vol[i] = np.inf
else:
try:
vol[i] = ConvexHull(v.vertices[indices]).volume
except:
vol[i] = np.inf
return vol
来源:https://stackoverflow.com/questions/58915064/3d-voronoi-diagram-radius-inconsistent-with-generators