資源簡介
基于PCL的曲面重建代碼
代碼片段和文件信息
/********************************************
功能:曲面重建(泊松重建)
*********************************************/
//點的類型的頭文件
#include?
//點云文件IO(pcd文件和ply文件)
#include?
#include?
//kd樹
#include?
//特征提取
#include?
#include?
//重構
#include?
#include?
//可視化
#include?
//多線程
#include?
#include?
#include?
#include?
#include?
int?main(int?argc?char**?argv)
{
//?確定文件格式
char?tmpStr[100];
strcpy(tmpStrargv[1]);
char*?pext?=?strrchr(tmpStr?‘.‘);
std::string?extply(“ply“);
std::string?extpcd(“pcd“);
if(pext)
{
*pext=‘\0‘;
pext++;
}
std::string?ext(pext);
//如果不支持文件格式,退出程序
if?(!((ext?==?extply)||(ext?==?extpcd)))
{
std::cout?<“文件格式不支持!“?< std::cout?<“支持文件格式:*.pcd和*.ply!“?< return(-1);
}
//創(chuàng)建點云對象指針,用于存儲輸入
pcl::PointCloud::Ptr?cloud(new?pcl::PointCloud)?;?
if?(ext?==?extply)
{
if?(pcl::io::loadPLYFile(argv[1]??*cloud)?==?-1){
PCL_ERROR(“Could?not?read?ply?file!\n“)?;
return?-1;
}
}
else
{
if?(pcl::io::loadPCDFile(argv[1]??*cloud)?==?-1){
PCL_ERROR(“Could?not?read?pcd?file!\n“)?;
return?-1;
}
}
//?計算法向量
pcl::PointCloud::Ptr?cloud_with_normals(new?pcl::PointCloud);?//法向量點云對象指針
pcl::NormalEstimation?n?;//法線估計對象
pcl::PointCloud::Ptr?normals(new?pcl::PointCloud)?;//存儲估計的法線的指針
pcl::search::KdTree::Ptr?tree(new?pcl::search::KdTree)?;
tree->setInputCloud(cloud)?;
n.setInputCloud(cloud)?;
n.setSearchMethod(tree)?;
n.setKSearch(20);
n.compute(*normals);?//計算法線,結果存儲在normals中
//將點云和法線放到一起
pcl::concatenateFields(*cloud??*normals??*cloud_with_normals)?;
//創(chuàng)建搜索樹
pcl::search::KdTree::Ptr?tree2(new?pcl::search::KdTree)?;
tree2->setInputCloud(cloud_with_normals)?;
//創(chuàng)建Poisson對象,并設置參數(shù)
pcl::Poisson?pn?;
pn.setConfidence(false);?//是否使用法向量的大小作為置信信息。如果false,所有法向量均歸一化。
pn.setDegree(2);?//設置參數(shù)degree[15]值越大越精細,耗時越久。
pn.setDepth(8);?//樹的最大深度,求解2^d?x?2^d?x?2^d立方體元。由于八叉樹自適應采樣密度,指定值僅為最大深度。
pn.setIsoDivide(8);?//用于提取ISO等值面的算法的深度
pn.setManifold(false);?//是否添加多邊形的重心,當多邊形三角化時。?設置流行標志,如果設置為true,則對多邊形進行細分三角話時添加重心,設置false則不添加
pn.setOutputPolygons(false);?//是否輸出多邊形網格(而不是三角化移動立方體的結果)
pn.setSamplesPerNode(3.0);?//設置落入一個八叉樹結點中的樣本點的最小數(shù)量。無噪聲,[1.0-5.0]有噪聲[15.-20.]平滑
pn.setScale(1.25);?//設置用于重構的立方體直徑和樣本邊界立方體直徑的比率。
pn.setSolverDivide(8);?//設置求解線性方程組的Gauss-Seidel迭代方法的深度
//pn.setIndices();
//設置搜索方法和輸入點云
pn.setSearchMethod(tree2);
pn.setInputCloud(cloud_with_normals);
//創(chuàng)建多變形網格,用于存儲結果
pcl::PolygonMesh?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-07-05?11:03??1.PossionReconstruction\
?????目錄???????????0??2016-07-05?13:03??1.PossionReconstruction\PointCloudView\
?????目錄???????????0??2016-07-05?11:27??1.PossionReconstruction\PointCloudView\Debug\
?????文件??????547840??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\Debug\PointCloudView.exe
?????文件?????2360096??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\Debug\PointCloudView.ilk
?????文件????46189568??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\Debug\PointCloudView.pdb
?????文件?????1489079??2016-05-22?11:23??1.PossionReconstruction\PointCloudView\Debug\option-0000.ply
?????文件??????958480??2016-05-22?11:35??1.PossionReconstruction\PointCloudView\Debug\rabbit0.pcd
?????文件?????1926687??2016-07-05?11:27??1.PossionReconstruction\PointCloudView\Debug\result.ply
?????目錄???????????0??2016-07-05?11:03??1.PossionReconstruction\PointCloudView\PointCloudView\
?????目錄???????????0??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\
?????文件??????649026??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\CL.read.1.tlog
?????文件????????1120??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\CL.write.1.tlog
?????文件????????1603??2016-05-24?10:33??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.Build.CppClean.log
?????文件?????????406??2016-05-24?10:41??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.exe.em
?????文件?????????472??2016-07-05?11:10??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.exe.em
?????文件?????????381??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.exe.intermediate.manifest
?????文件?????????142??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.lastbuildstate
?????文件???????29145??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.log
?????文件???????????0??2016-05-24?10:33??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView.write.1.tlog
?????文件?????????218??2016-05-24?10:34??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\PointCloudView_manifest.rc
?????文件????????1598??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\cl.command.1.tlog
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
?????文件???????????2??2016-07-05?11:12??1.PossionReconstruction\PointCloudView\PointCloudView\Debug\li
............此處省略37個文件信息
- 上一篇:嵌入式系統(tǒng)(北航PPT教案)
- 下一篇:三維點云的可視化
評論
共有 條評論