編碼的世界 / 優質文選 / 女人

Ubuntu 18.04 安裝不了Open3D C++版本解決辦法


2022年5月06日
-   

 此篇博客引用博客Ubuntu18.04 安裝Open3D C++與Python版本_zpwhust的博客-CSDN博客_ubuntu 安裝open3d
並在此基礎上進行整理
環境 linux:ubuntu 18.04 cmake : cmake 3.22(這個取決於open3D的軟件包,我使用的Open3D軟件包是3.19以上都可以
 安裝
1.下載Open3D源碼包
git clone recursive https://github.com/intel-isl/Open3D

國內用戶使用github下載可能會有問題,所以可以使用以下的命令
git clone recursive https://hub.fastgit.org/intel-isl/Open3D
#或者使用
git clone recursive https://github.com.cnpmjs.org/intel-isl/Open3D

2.安裝Open3D的依賴項
cd Open3D
util/scripts/install-deps-ubuntu.sh

3.編譯安裝
mkdir -p build
cd build
cmake ..
make -j4
sudo make install

在執行cmake的時候,可能出現cmake版本過低,解決方法參考
cmake高版本安裝https://blog.csdn.net/qq_35398033/article/details/106457777https://blog.csdn.net/qq_35398033/article/details/106457777
在cmake ..和make -j4的時候,會因為國內的網絡無法訪問github,而導致失敗,如圖示

可以在圖中的錯誤中,是因為第三方庫下載失敗,所以這個時候主要就是把第三方庫下載下來,並放入他提示的路徑;
友情提示:國內的網絡無法訪問github,所以只要把錯誤提示中的鏈接拷貝到瀏覽器中,講  github.com 替換成 hub.fastgit.org,然後下載就可以了,這個方法可以應用github中所有的項目!!!!!!!!!!!!!( ⊙ o ⊙)
最終完成了cmake

完成make -j4

4.驗證
新建一個cpp文件,代碼就直接引用原博主的代碼,如下
#include <iostream>
#include <memory>
#include <thread>
#include <Open3D/Open3D.h>
int main(int argc, char * argv[]) {
std::cout << "Hello, Open3D!! " << std::endl;
open3d::utility::SetVerbosityLevel(open3d::utility::VerbosityLevel::Debug);
auto pcd = open3d::io::CreatePointCloudFromFile(argv[1]);
// 1. test downsample
auto downsampled = pcd->VoxelDownSample(0.05);
{
open3d::utility::ScopeTimer timer("FPFH estimation with Radius 0.25");
open3d::registration::ComputeFPFHFeature(*downsampled, open3d::geometry::KDTreeSearchParamRadius(0.25));
}
// 2. 估計點雲的法向量
{
open3d::utility::ScopeTimer timer("Normal estimation with KNN20");
for (int i = 0; i < 20; i++){
downsampled->EstimateNormals(open3d::geometry::KDTreeSearchParamKNN(20));
}
}
std::cout << downsampled->normals_[0] << std::endl;
std::cout << downsampled->normals_[10] << std::endl;
{
open3d::utility::ScopeTimer timer("Normal estimation with Radius 0.01666");
for(int i=0; i<20; i++){
downsampled->EstimateNormals(open3d::geometry::KDTreeSearchParamRadius(0.01666));
}
}
std::cout << downsampled->normals_[0] << std::endl;
std::cout << downsampled->normals_[10] << std::endl;
open3d::visualization::DrawGeometries({downsampled}, "TestPCD", 1920, 1080);
return 0;
}

創建一個CMakeLists.txt文件,添加以下內容
cmake_minimum_required(VERSION 2.8)
project(open3d_test)
set(CMAKE_CXX_STANDARD 11)
find_package( Open3D REQUIRED)
include_directories(${Open3D_INCLUDE_DIRS})
link_directories(${Open3D_LIBRARY_DIRS})
add_executable(TestVisualizer main.cpp)
target_link_libraries(TestVisualizer ${Open3D_LIBRARIES})
target_include_directories(TestVisualizer PUBLIC ${Open3D_INCLUDE_DIRS})

 然後執行以下命令
mkdir build
cmake ..
make


 這樣就可以生成可執行文件
接著運行測試數據安裝目錄下examples/test_data/ICP,複制數據到測試代碼同路徑下,運行命令如下
./TestVisualizer ../cloud_bin_0.pcd

 
5.總結
在這個過程中,需要很多的第三方庫,需要耐心的下載,並放在正確的路徑下,看著問題一個個被解決,這對自己是最好的鼓舞,加油!!!!!!!!!!!!!! 





創作打卡挑戰賽


贏取流量/現金/CSDN周邊激勵大獎

熱門文章