版權聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權協(xié)議,轉(zhuǎn)載請附上原文出處鏈接和本聲明。
本文鏈接:https://blog.csdn.net/zaibeijixing/article/details/130770476
————————————————
?本文為Windows配置點云庫pcl步驟,具體win10、visual studio 2019、pcl1.11.1。
目錄
【1】下載安裝包
【2】安裝
2.1 先執(zhí)行win64.exe
2.2 解壓win64.zip
2.3 OpenNI2安裝
【3】設置環(huán)境變量
【4】visual studio 項目實戰(zhàn)
4.1 新建C++空項目
4.2?包含目錄
4.3?庫目錄
4.4?添加附加依賴項
4.5?添加.cpp并執(zhí)行顯示效果
另:執(zhí)行可能出現(xiàn)的代碼錯誤解決方法
【1】下載安裝包
下載鏈接:Releases · PointCloudLibrary/pcl · GitHub
?其中,AllInOne是一個包含了PCL庫所有模塊的單獨下載包,方便快速獲取整個PCL庫,而pdb則是PCL庫的調(diào)試信息文件,可以在程序崩潰時提供更詳細的調(diào)試信息來分析解決錯誤。
【2】安裝
2.1 先執(zhí)行win64.exe
?
??建議自定義安裝的位置,按提示操作即可,建議把pcl添加到PATH中。
2.2 解壓win64.zip
把解壓出來的子文件,全部復制到如下 PCL/bin中
?
2.3 OpenNI2安裝
?執(zhí)行.msi,建議修改路徑到該文件夾下;如果已安裝過,建議Remove后重新安裝,以便后續(xù)添加PATH和使用時路徑清晰。
?
?安裝完畢,該路徑如下:
【3】設置環(huán)境變量
“此電腦”右鍵>>屬性,如下圖添加,再重啟電腦:
?
【4】visual studio 項目實戰(zhàn)
4.1 新建C++空項目
可設置Debug-x64,并右鍵 >> 屬性進行配置。
4.2?包含目錄
如下圖,編輯包含目錄:
?添加如下路徑(不同庫的路徑層級不同,建議各層級都添加避免包含錯誤):
D:\tools\PCL 1.11.1\include\pcl-1.11
D:\tools\PCL 1.11.1\include\pcl-1.11\pcl
D:\tools\PCL 1.11.1\3rdParty\Boost\include\boost-1_74
D:\tools\PCL 1.11.1\3rdParty\Boost\include\boost-1_74\boost
D:\tools\PCL 1.11.1\3rdParty\Eigen\eigen3
D:\tools\PCL 1.11.1\3rdParty\Eigen\eigen3\Eigen
D:\tools\PCL 1.11.1\3rdParty\Eigen\eigen3\unsupported
D:\tools\PCL 1.11.1\3rdParty\Eigen\eigen3\unsupported\Eigen
D:\tools\PCL 1.11.1\3rdParty\FLANN\include
D:\tools\PCL 1.11.1\3rdParty\FLANN\include\flann
D:\tools\PCL 1.11.1\3rdParty\OpenNI2\Include
D:\tools\PCL 1.11.1\3rdParty\Qhull\include
D:\tools\PCL 1.11.1\3rdParty\Qhull\include\libqhull
D:\tools\PCL 1.11.1\3rdParty\Qhull\include\libqhull_r
D:\tools\PCL 1.11.1\3rdParty\Qhull\include\libqhullcpp
D:\tools\PCL 1.11.1\3rdParty\VTK\include
D:\tools\PCL 1.11.1\3rdParty\VTK\include\vtk-8.2
4.3?庫目錄
仿照4.3包含目錄添加庫目錄:
D:\tools\PCL 1.11.1\lib
D:\tools\PCL 1.11.1\3rdParty\Boost\lib
D:\tools\PCL 1.11.1\3rdParty\FLANN\lib
D:\tools\PCL 1.11.1\3rdParty\OpenNI2\Lib
D:\tools\PCL 1.11.1\3rdParty\Qhull\lib
D:\tools\PCL 1.11.1\3rdParty\VTK\lib
4.4?添加附加依賴項
需要添加PCL和VTK的debug版lib,總共140多個。
可以通過以下批處理的方法:
cd\d D:\tools\PCL 1.11.1\lib? //轉(zhuǎn)到lib目錄
dir/b *d.lib? >0.txt? ? ? ? ? ? ? ? ? //把debug用的d.lib后綴名字寫到0.txt中
兩次操作把這些名字復制粘貼到附加依賴項中。
4.5?添加.cpp并執(zhí)行顯示效果
#include <iostream>
#include <thread>
#include <pcl/console/parse.h>
#include <pcl/point_cloud.h> // for PointCloud
#include <pcl/common/io.h> // for copyPointCloud
#include <pcl/point_types.h>
#include <pcl/sample_consensus/ransac.h>
#include <pcl/sample_consensus/sac_model_plane.h>
#include <pcl/sample_consensus/sac_model_sphere.h>
#include <pcl/visualization/pcl_visualizer.h>
using namespace std::chrono_literals;
pcl::visualization::PCLVisualizer::Ptr
simpleVis(pcl::PointCloud<pcl::PointXYZ>::ConstPtr cloud)
{
// --------------------------------------------
// -----Open 3D viewer and add point cloud-----
// --------------------------------------------
pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
viewer->setBackgroundColor(0, 0, 0);
viewer->addPointCloud<pcl::PointXYZ>(cloud, "sample cloud");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
//viewer->addCoordinateSystem (1.0, "global");
viewer->initCameraParameters();
return (viewer);
}
int
main(int argc, char** argv)
{
// initialize PointClouds
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr final(new pcl::PointCloud<pcl::PointXYZ>);
// populate our PointCloud with points
cloud->width = 500;
cloud->height = 1;
cloud->is_dense = false;
cloud->points.resize(cloud->width * cloud->height);
for (pcl::index_t i = 0; i < static_cast<pcl::index_t>(cloud->size()); ++i)
{
if (pcl::console::find_argument(argc, argv, "-s") >= 0 || pcl::console::find_argument(argc, argv, "-sf") >= 0)
{
(*cloud)[i].x = 1024 * rand() / (RAND_MAX + 1.0);
(*cloud)[i].y = 1024 * rand() / (RAND_MAX + 1.0);
if (i % 5 == 0)
(*cloud)[i].z = 1024 * rand() / (RAND_MAX + 1.0);
else if (i % 2 == 0)
(*cloud)[i].z = sqrt(1 - ((*cloud)[i].x * (*cloud)[i].x)
- ((*cloud)[i].y * (*cloud)[i].y));
else
(*cloud)[i].z = -sqrt(1 - ((*cloud)[i].x * (*cloud)[i].x)
- ((*cloud)[i].y * (*cloud)[i].y));
}
else
{
(*cloud)[i].x = 1024 * rand() / (RAND_MAX + 1.0);
(*cloud)[i].y = 1024 * rand() / (RAND_MAX + 1.0);
if (i % 2 == 0)
(*cloud)[i].z = 1024 * rand() / (RAND_MAX + 1.0);
else
(*cloud)[i].z = -1 * ((*cloud)[i].x + (*cloud)[i].y);
}
}
std::vector<int> inliers;
// created RandomSampleConsensus object and compute the appropriated model
pcl::SampleConsensusModelSphere<pcl::PointXYZ>::Ptr
model_s(new pcl::SampleConsensusModelSphere<pcl::PointXYZ>(cloud));
pcl::SampleConsensusModelPlane<pcl::PointXYZ>::Ptr
model_p(new pcl::SampleConsensusModelPlane<pcl::PointXYZ>(cloud));
if (pcl::console::find_argument(argc, argv, "-f") >= 0)
{
pcl::RandomSampleConsensus<pcl::PointXYZ> ransac(model_p);
ransac.setDistanceThreshold(.01);
ransac.computeModel();
ransac.getInliers(inliers);
}
else if (pcl::console::find_argument(argc, argv, "-sf") >= 0)
{
pcl::RandomSampleConsensus<pcl::PointXYZ> ransac(model_s);
ransac.setDistanceThreshold(.01);
ransac.computeModel();
ransac.getInliers(inliers);
}
// copies all inliers of the model computed to another PointCloud
pcl::copyPointCloud(*cloud, inliers, *final);
// creates the visualization object and adds either our original cloud or all of the inliers
// depending on the command line arguments specified.
pcl::visualization::PCLVisualizer::Ptr viewer;
if (pcl::console::find_argument(argc, argv, "-f") >= 0 || pcl::console::find_argument(argc, argv, "-sf") >= 0)
viewer = simpleVis(final);
else
viewer = simpleVis(cloud);
while (!viewer->wasStopped())
{
viewer->spinOnce(100);
std::this_thread::sleep_for(100ms);
}
return 0;
}
執(zhí)行結果:
另:執(zhí)行可能出現(xiàn)的代碼錯誤解決方法
有兩種解決方法:
1、直接跳轉(zhuǎn)到該位置注釋;
2、或在預編譯器添加?_CRT_SECURE_NO_DEPRECATE
注:部分地方參考:
PCL學習筆記(一)-- Windows下配置安裝PCL開發(fā)環(huán)境_pcl環(huán)境配置_看到我請叫我學C++的博客-CSDN博客文章來源:http://www.zghlxwxcb.cn/news/detail-618032.html
?版權聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權協(xié)議,轉(zhuǎn)載請附上原文出處鏈接和本聲明。
本文鏈接:https://blog.csdn.net/zaibeijixing/article/details/130770476
————————————————文章來源地址http://www.zghlxwxcb.cn/news/detail-618032.html
到了這里,關于Windows環(huán)境下pcl點云庫 安裝配置全流程(精簡、有效)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!