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

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章