我正在使用vedo来可视化和处理从激光雷达扫描中获取的3D模型;它们是我打开的.obj文件。
在我的应用程序中,如果有意义的话,我想要找到能够“放入”我的扫描对象的最大球体。假设我有一个房间或走廊--基本上,我正在尝试测量可用空间的大小。
所以我想放入一堆球体,然后看看这些球体有多大。对于我加载的任何.obj文件,我都可以自动执行这个过程,这一点很重要,否则我会手动测量……
这是我打开的一个示例.obj文件,一个粗略扫描的走廊:


我不知道如何使用vedo,我找到的最接近的例子是来自示例网站的“Fit a Sphere”,它启发了我的解决方案:

https://vedo.embl.es/#quick_start https://github.com/marcomusy/vedo/blob/master/examples/advanced/fitspheres1.py
但是,我如何在球体上定义约束,使它们“适合”网格(走廊/房间)?
作为参考,下面是我的启动代码,它真正做的就是读取和显示网格:
import vedo
import numpy as np
# https://vedo.embl.es/#quick_start
mesh_str = 'meshes/mesh1_indoor_scene_1.obj'
# Load a polygonal mesh, make it white and glossy:
scene = vedo.Mesh(mesh_str)
scene.c('white').lighting('glossy')
# Create two points:
p1 = vedo.Point([ 1,0,1], c='yellow')
p2 = vedo.Point([-1,0,2], c='red')
# Add colored light sources at the point positions:
l1 = vedo.Light(p1, c='yellow')
l2 = vedo.Light(p2, c='red')
# Show everything in one go:
vedo.show(scene, l1, l2, p1, p2, mesh_str, axes=True)感谢任何帮助,并乐于考虑其他可行的解决方案,可以用python代码实现。
发布于 2021-08-04 11:43:59
如果可以从点云重建曲面,则可以直接使用surf.volume(),也可以生成点栅格并使用insidePoints() (而不是拟合球体),例如:
from vedo import *
import numpy as np
surf = Mesh(dataurl+'cow.vtk').wireframe()
printc("true volume: ", surf.volume())
pts = []
step = 0.05
b = surf.bounds()
for x in np.arange(b[0], b[1], step):
for y in np.arange(b[2], b[3], step):
for z in np.arange(b[4], b[5], step):
pts.append([x,y,z])
pts = np.array(pts)
ipts = surf.insidePoints(pts)
printc("approx volume:", ipts.NPoints()*step**3)
show(surf, ipts, N=2, axes=1)

true volume: 0.8346111674784022
approx volume: 0.8287500000000002你也可以发布一个问题here。
https://stackoverflow.com/questions/68640665
复制相似问题