Linux/Ubuntu下Meshlab批量对散乱三维点云泊松重构的方法

Meshlab批量处理多个散乱三维点云:

思路:首先对单点云进行处理,生成mlx的脚本文件,最后通过批量执行meshlabserver命令实现对批量点云的重构。

具体步骤:
(1)打开单个散乱点云文件,文件包含点云上各点的XYZ坐标
(2)Meshlab——Filter——Point Set ——Compute normals for point sets——设置相关的参数
(3)Meshlab——Filter——Remeshing,Smoothing and Reconstruction ——Surface Reconstruction: Screened Poisson设置相关参数
如下图:
在这里插入图片描述
经过泊松重构后,默认当前的图层为点云图层,而并非Mesh图层,因此
(4)删除原点云图层
(5)生成相应的mlx脚本:Filter——Show current filter script ——Save Script,如图:
在这里插入图片描述
mlx文件:

<!DOCTYPE FilterScript>
<FilterScript>
 <filter name="Compute normals for point sets">
  <Param value="100" name="K" type="RichInt" tooltip="The number of neighbors used to estimate normals." description="Neighbour num"/>
  <Param value="0" name="smoothIter" type="RichInt" tooltip="The number of smoothing iteration done on the p used to estimate and propagate normals." description="Smooth Iteration"/>
  <Param value="false" name="flipFlag" type="RichBool" tooltip="If the 'viewpoint' (i.e. scanner position) is known, it can be used to disambiguate normals orientation, so that all the normals will be oriented in the same direction." description="Flip normals w.r.t. viewpoint"/>
  <Param y="0" x="0" z="0" name="viewPos" type="RichPoint3f" tooltip="The viewpoint position can be set by hand (i.e. getting the current viewpoint) or it can be retrieved from mesh camera, if the viewpoint position is stored there." description="Viewpoint Pos."/>
 </filter>
 <filter name="Smooths normals on a point sets">
  <Param value="10" name="K" type="RichInt" tooltip="The number of neighbors used to smooth normals." description="Number of neigbors"/>
  <Param value="false" name="useDist" type="RichBool" tooltip="If selected, the neighbour normals are waighted according to their distance" description="Weight using neighbour distance"/>
 </filter>
 <xmlfilter name="Surface Reconstruction: Screened Poisson">
  <xmlparam value="0" name="cgDepth"/>
  <xmlparam value="false" name="confidence"/>
  <xmlparam value="8" name="depth"/>
  <xmlparam value="5" name="fullDepth"/>
  <xmlparam value="8" name="iters"/>
  <xmlparam value="4" name="pointWeight"/>
  <xmlparam value="false" name="preClean"/>
  <xmlparam value="1.5" name="samplesPerNode"/>
  <xmlparam value="1.1" name="scale"/>
  <xmlparam value="false" name="visibleLayer"/>
 </xmlfilter>
 <filter name="Delete Current Mesh"/>
</FilterScript>

(6)meshlabserver 执行上述mlx文件:
在这里插入图片描述

其中40.xyz为输入文件,40.stl为输出文件,PoissonReconstruction.mlx为脚本文件,如果上述过程能输出40.stl则可进行下一步批量处理

(6)Linux Shell 脚本批量执行上述命令:创建一个batch.sh文件,复制下面命令,最后执行batch.sh即可

#!/usr/bin/env bash

#对某一个文件夹下的所有点云文件进行重构并输出
SHAPES_IN_DIR=/home/chris/Desktop/sorted/
SHAPES_OUT_DIR=/home/chris/Desktop/Poisson/
MLX_SCRIPT=/media/chris/DATA/Programming/meshlab/PoissonReconstruction.mlx

cd /home/chris/Desktop/sorted/
#下面进行循环遍历文件
for((k=0;k<10;k++))
do
	FILE_NAME=${SHAPES_IN_DIR}${k}.xyz
	OUTPUT_NEAME=${SHAPES_OUT_DIR}${k}.stl
	echo  Surface Reconstruction $k : ${FILE_NAME}  ${OUTPUT_NEAME}
	meshlabserver -i ${FILE_NAME} -o ${OUTPUT_NEAME} -s $MLX_SCRIPT
done

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/zch19960629/article/details/89857808
今日推荐