Win10 系統(tǒng)下VisualStudio2019 配置點(diǎn)云庫(kù) PCL1.11.0的圖文教程
一、下載PCL1.11.0
Github下載地址:https://github.com/PointCloudLibrary/pcl/releases
下載紅框內(nèi)的兩個(gè)文件
二、安裝PCL1.11.0
2.1 安裝“PCL-1.11.0-AllInOne-msvc2019-win64.exe”。
(1)選擇第二個(gè),自動(dòng)添加系統(tǒng)變量
(2)安裝路徑選擇D盤(pán),系統(tǒng)會(huì)自動(dòng)新建PCL 1.11.0文件夾。
2.2 安裝完成之后打開(kāi)文件夾 D:\PCL 1.11.0\3rdParty\OpenNI2
雙擊OpenNI-Windows-x64-2.2 選擇路徑(D:\PCL 1.11.0\3rdParty\OpenNI2)安裝即可。
2.3 全部安裝完成后,將pcl-1.11.0-pdb-msvc2019-win64.zip解壓后的.pdb文件拷貝到(D:\PCL 1.11.0\bin)中。
2.4 設(shè)置環(huán)境變量:右擊計(jì)算機(jī)—屬性—高級(jí)系統(tǒng)設(shè)置—高級(jí)—環(huán)境變量—用戶變量—Path—編輯!
如下圖所示,設(shè)置完成后重啟電腦。
在這里直接給出,防止出現(xiàn)錯(cuò)誤(依次添加):
%PCL_ROOT%\3rdParty\FLANN\bin
%PCL_ROOT%\3rdParty\VTK\bin
%OPENNI2_REDIST64%
%OPENNI2_LIB64%
%OPENNI2_INCLUDE64%
到此,環(huán)境變量的配置完成。
三、VS2019相關(guān)設(shè)置
3.1 新建空項(xiàng)目
解決方案配置選擇Debug,解決方案平臺(tái)選擇x64。
3.2 新建一個(gè)C++源文件
3.3 右擊新建的項(xiàng)目—屬性:打開(kāi)屬性表
3.4 配置屬性—調(diào)試—環(huán)境—添加:
PATH=D:\PCL 1.11.0\\bin;D:\PCL 1.11.0\\3rdParty\FLANN\bin;D:\PCL 1.11.0\\3rdParty\VTK\bin;D:\PCL 1.11.0\\3rdParty\OpenNI2\Tools
3.5 C/C++—語(yǔ)言—符合模式:否
3.6 C/C++—常規(guī)—SDL檢查:否
四、配置PCL1.11.0
為了使用方便,這里使用添加屬性表的形式
4.1 視圖—其他窗口—屬性管理器
4.2 打開(kāi)屬性管理器之后,選擇Debug|X64—單擊Debug|X64左側(cè)倒三角—右擊選擇 添加型項(xiàng)目屬性表
4.3 項(xiàng)目屬性表命名
4.4 雙擊新添加的屬性表—VC++目錄—包含目錄,添加7個(gè)include路徑
具體添加的include路徑如下:
D:\PCL 1.11.0\include\pcl-1.11
D:\PCL 1.11.0\3rdParty\Boost\include\boost-1_73
D:\PCL 1.11.0\3rdParty\Eigen\eigen3
D:\PCL 1.11.0\3rdParty\FLANN\include
D:\PCL 1.11.0\3rdParty\Qhull\include
D:\PCL 1.11.0\3rdParty\VTK\include\vtk-8.2
D:\PCL 1.11.0\3rdParty\OpenNI2\Include
4.5 VC++目錄—包含目錄,添加6個(gè)lib路徑
具體添加的lib路徑如下:
D:\PCL 1.11.0\lib
D:\PCL 1.11.0\3rdParty\Boost\lib
D:\PCL 1.11.0\3rdParty\FLANN\lib
D:\PCL 1.11.0\3rdParty\Qhull\lib
D:\PCL 1.11.0\3rdParty\OpenNI2\Lib
D:\PCL 1.11.0\3rdParty\VTK\lib
4.6 C/C++—預(yù)處理器—預(yù)處理器定義—添加:
BOOST_USE_WINDOWS_H
NOMINMAX
_CRT_SECURE_NO_DEPRECATE
4.7 鏈接器—輸入—附加依賴項(xiàng)——添加PCL和VTK的相關(guān)lib文件。我用的Debug版本。
附加依賴項(xiàng)具體添加內(nèi)容如下:(內(nèi)容略多,放在PCL1.11.0附加依賴項(xiàng)里邊了。文章末尾 附錄中 給出批量獲取附加依賴項(xiàng)的方法)
輸入到屬性表里邊的時(shí)候必須一行對(duì)應(yīng)一個(gè)lib才能成功。
Debug版本
4.8保存屬性表
下一次需要?jiǎng)?chuàng)建新項(xiàng)目的時(shí)候,只需進(jìn)行第三步 VS2019相關(guān)設(shè)置 的操作,然后打開(kāi)屬性管理器,添加現(xiàn)有屬性表,找到之前保存的屬性表添加進(jìn)去即可。
五、測(cè)試代碼
#include <iostream> #include <vector> #include <ctime> #include <pcl/point_cloud.h> #include <pcl/octree/octree.h> #include <boost/thread/thread.hpp> #include <pcl/visualization/pcl_visualizer.h> using namespace std; int main(int argc, char** argv) { srand((unsigned int)time(NULL)); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); // 創(chuàng)建點(diǎn)云數(shù)據(jù) cloud->width = 1000; cloud->height = 1; cloud->points.resize(cloud->width * cloud->height); for (size_t i = 0; i < cloud->points.size(); ++i) { cloud->points[i].x = 1024.0f * rand() / (RAND_MAX + 1.0f); cloud->points[i].y = 1024.0f * rand() / (RAND_MAX + 1.0f); cloud->points[i].z = 1024.0f * rand() / (RAND_MAX + 1.0f); } pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(0.1); octree.setInputCloud(cloud); octree.addPointsFromInputCloud(); pcl::PointXYZ searchPoint; searchPoint.x = 1024.0f * rand() / (RAND_MAX + 1.0f); searchPoint.y = 1024.0f * rand() / (RAND_MAX + 1.0f); searchPoint.z = 1024.0f * rand() / (RAND_MAX + 1.0f); //半徑內(nèi)近鄰搜索 vector<int>pointIdxRadiusSearch; vector<float>pointRadiusSquaredDistance; float radius = 256.0f * rand() / (RAND_MAX + 1.0f); cout << "Neighbors within radius search at (" << searchPoint.x << " " << searchPoint.y << " " << searchPoint.z << ") with radius=" << radius << endl; if (octree.radiusSearch(searchPoint, radius, pointIdxRadiusSearch, pointRadiusSquaredDistance) > 0) { for (size_t i = 0; i < pointIdxRadiusSearch.size(); ++i) cout << " " << cloud->points[pointIdxRadiusSearch[i]].x << " " << cloud->points[pointIdxRadiusSearch[i]].y << " " << cloud->points[pointIdxRadiusSearch[i]].z << " (squared distance: " << pointRadiusSquaredDistance[i] << ")" << endl; } // 初始化點(diǎn)云可視化對(duì)象 boost::shared_ptr<pcl::visualization::PCLVisualizer>viewer(new pcl::visualization::PCLVisualizer("顯示點(diǎn)云")); viewer->setBackgroundColor(0, 0, 0); //設(shè)置背景顏色為黑色 // 對(duì)點(diǎn)云著色可視化 (red). pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ>target_color(cloud, 255, 0, 0); viewer->addPointCloud<pcl::PointXYZ>(cloud, target_color, "target cloud"); viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "target cloud"); // 等待直到可視化窗口關(guān)閉 while (!viewer->wasStopped()) { viewer->spinOnce(100); boost::this_thread::sleep(boost::posix_time::microseconds(1000)); } return (0); }
輸出下圖(數(shù)字可能不同),則表示安裝成功!
六、附錄—獲取自己的鏈接庫(kù)列表
win+r調(diào)出“運(yùn)行”窗口并輸出cmd
輸入:cd /d D:\PCL 1.11.0\3rdParty\VTK\lib 回車 (填自己的路徑)
輸入:dir /b *.lib *>0.txt 回車
這時(shí)打開(kāi)你對(duì)應(yīng)路勁的目錄,多了一個(gè)0.txt文件,里面存了你這個(gè)文件夾里所有鏈接庫(kù)名字。
由于每一個(gè)Debug版本和Release版本的鏈接庫(kù)是挨在一起的。寫(xiě)一個(gè)讀取文檔并對(duì)其分別保存就行了。
具體代碼如下:(主要功能是讀取一個(gè)txt文件,將其中奇數(shù)行和偶數(shù)行單獨(dú)輸出到新的txt文檔。)
#include <iostream> #include <string> #include <fstream> #include <iostream> using namespace std; int main() { ifstream txtfile;//打開(kāi)讀取的文件 ofstream txt01;//保存的文件 ofstream txt02;//保存的文件 string temp; int index = 0;//用于判斷奇偶 txtfile.open("0.txt", ios::in); while (!txtfile.eof()) // 若未到文件結(jié)束一直循環(huán) { getline(txtfile, temp);//一行一行讀取 if (index%2==0)//判斷除以2的余數(shù),即為奇偶的判斷 { txt01.open("1.txt", ios::app); txt01 << temp; txt01 << endl; txt01.close(); } else { txt02.open("2.txt", ios::app); txt02 << temp; txt02 << endl; txt02.close(); } index++; } txtfile.close(); //關(guān)閉文件 txtfile.close(); txt01.close(); txt02.close(); return 0; }
到此這篇關(guān)于Win10 系統(tǒng)下VisualStudio2019 配置點(diǎn)云庫(kù) PCL1.11.0的圖文教程的文章就介紹到這了,更多相關(guān)VisualStudio2019 配置點(diǎn)云庫(kù) PCL1.11.0內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
WPF自定義TreeView控件樣式實(shí)現(xiàn)QQ聯(lián)系人列表效果
TreeView控件在項(xiàng)目中使用比較頻繁,下面這篇文章主要給大家介紹了關(guān)于WPF自定義TreeView控件樣式實(shí)現(xiàn)QQ聯(lián)系人列表效果的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來(lái)一起看看吧。2018-04-04C# Onnx實(shí)現(xiàn)特征匹配DeDoDe檢測(cè)
這篇文章主要為大家詳細(xì)介紹了C# Onnx如何實(shí)現(xiàn)特征匹配DeDoDe檢測(cè),文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-11-11C#如何優(yōu)雅的對(duì)WinForm窗體應(yīng)用程序進(jìn)行權(quán)限控制
經(jīng)常會(huì)出現(xiàn)winfrom頁(yè)面需要加載權(quán)限樹(shù),下面這篇文章主要給大家介紹了關(guān)于C#如何優(yōu)雅的對(duì)WinForm窗體應(yīng)用程序進(jìn)行權(quán)限控制的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-11-11C#語(yǔ)法相比其它語(yǔ)言比較獨(dú)特的地方(三)
這篇文章主要介紹了C#語(yǔ)法相比其它語(yǔ)言比較獨(dú)特的地方(三),本文講解了在C++中允許從一個(gè)case貫穿到另一個(gè)case標(biāo)簽、as和is只會(huì)檢測(cè)待轉(zhuǎn)化類型的類型,而不會(huì)進(jìn)行其它操作等內(nèi)容,需要的朋友可以參考下2015-04-04C#利用itext實(shí)現(xiàn)PDF頁(yè)面處理與切分
這篇文章主要介紹了如何在C#中使用itext做一個(gè)pdf的頁(yè)面大小一致性處理,然后再根據(jù)數(shù)據(jù)切分出需要的pdf,感興趣的小伙伴可以了解一下2022-04-04