我想计算通过立体视觉获得的3d点云的“密度”。
我像https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.SphericalVoronoi.html一样实现了3D Voronoi图
结果在许多不同的幅度上都提高了ValueError("Radius inconsistent with generators.")
(我尝试了很多)
我的点云示例为:
[[ 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)我该如何解决?
b)而且我的点云也在变化,这取决于我所在的位置(点云是真实世界的坐标)。因此,我需要一个自适应指标来输入半径,具体取决于我认为的点云本身?
还有想法?非常感谢!:)
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