在 python 中使用 meshlab 函数

2024-01-03

我是 3D 新手,我有一个点云,我想使用 python 库形成一个网格。但我可以使用网格实验室函数,这些函数是“过滤器-->点集-->计算点集的法线”和“过滤器-->重新划分网格、简化和重建-->曲面重建::Poission”

有没有什么方法可以使用 python 来执行上述 meshlab 函数以使其自动化。

Thanks


您可以对 Meshlabserver 进行系统调用,它是 Meshlab 附带的(位于 Meshlab 安装目录中)。

如果不带参数运行 meshlabserver.exe,它将显示以下手册页

用法:meshlabserver [logargs] [args]

其中 logargs 可以是:

-d filename             dump on a text file a list of all the
                        filtering functions

-l filename             log of the filters is ouput on a file

其中 args 可以是:

-p filename             meshlab project (.mlp) to be loaded
-w filename [-v]        output meshlab project (.mlp) to be saved.
                        If -v flag is specified a 3D model meshfile.ext
                        contained in the input project will be overwritten,
                        otherwise it will be saved in the same directory of
                        input mesh as a new file called meshfile_out.ext.
                        All the mesh attributes will be exported in the
                        saved files

-i filename             mesh that has to be loaded

-o filename [-m <opt>]  the name of the file where to write the current mesh
                        of the MeshLab document.
                        If -m is specified  the specified mesh attributes will
                        be saved in the output file. the param <opt> can be a
                        space separated list of the following attributes:
                            vc -> vertex colors,  vf -> vertex flags,
                            vq -> vertex quality, vn-> vertex normals,
                            vt -> vertex texture coords,
                            fc -> face colors,  ff -> face flags,
                            fq -> face quality, fn-> face normals,
                            wc -> wedge colors, wn-> wedge normals,
                            wt -> wedge texture coords

-s filename                 the script to be applied

例子:

'meshlabserver -i input.obj -o output.ply -m vc fq wn -s meshclean.mlx'
       the script contained in file 'meshclean.mlx' will be applied to the
       mesh contained into 'input.obj'. The vertex coordinates and the
       per-vertex-color, the per-face-quality and the per-wedge-normal
       attributes will be saved into the output.ply file

'meshlabserver -i input0.obj -i input1.ply -o outproj.mlp -v -s meshclean.mlx'
       the script file meshclean.mlx will be applied to the document
       composed by input0.obj and input1.ply meshes.
       The mesh input1.ply will become the current mesh of the document
       (e.g. the mesh to which the filters operating on a single model will
       be applied). A new output project outproj.mlp file will be generated
       (containing references to the input0.obj an input1.ply).
       The files input0.obj and input1.ply will be overwritten.

'meshlabserver -l logfile.txt -p proj.mlp -i input.obj -w outproj.mlp -s meshclean.mlx'
       the mesh file input.obj will be added to the meshes referred by the
       loaded meshlab project file proj.mlp. The mesh input.obj will become
       the current mesh of the document, the script file meshclean.mlx will
       be applied to the meshes contained into the resulting document.
       the project file outproj.mlp will be generated
       A 3D model meshfile.ext contained in the input project proj.mlp will
       be saved in a new file called meshfile_out.ext
       (if you want to overwrite the original files use the -v flag after
       the outproject filename) all the attributes of the meshes will be
       saved into the output files; the log info will be saved into the
       file logfile.txt.

笔记: 可以加载多个网格及其列出的顺序 重要的是因为 使用网格作为参数的过滤器根据以下条件选择网格 命令。 输出网格的格式由所使用的扩展猜测。 脚本是可选的,并且必须是MeshLab保存的xml格式。

首先,使用 Meshlab 加载网格,运行您想要运行的过滤器,然后转到filters >> show current filter script并将脚本保存在某处,以便您可以使用 meshlabserver 调用它。

一个专业提示:如果您要加载 .stl 文件,则必须添加以下内容作为第一个过滤器:

<filter name="Merge Close Vertices">
  <Param type="RichAbsPerc" name="Threshold" description="Merging distance" value="0" tooltip="All the vertices that closer than this threshold are merged together. Use very small values, default values is 1/10000 of bounding box diagonal. " min="0" max="0"/>
</filter>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 python 中使用 meshlab 函数 的相关文章

随机推荐