准备工作
根据open3d官网的教程确定gcc5+ clang7+ cmake3.19+ 的版本限制,不满足要求的要升级一下:
参考链接:
cmake升级
clang升级
编译安装
按照链接Ubuntu 18.04 安装Open3D C++版本的安装部分依次操作即可
报错处理
cmake版本太低
升级cmake,cmake升级
cmake时报错:can not find libc++ libc++abi libraries with version >=7
升级clang,clang升级
cmake和make时,下载失败
网络问题。
(1)配置clash:ubuntu18.04 配置clash(设置了私密,需要私我)
(2)如果仍然不能解决,手动下载相关包,并放置在dst指示的地址中:参考解决安装open3d下载失败问题
完结撒花
测试程序:
main.cpp
#include <iostream>
#include <memory>
#include <thread>
#include </usr/local/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::pipelines::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;
}
修改:
(1)#include <open3d/Open3D.h>改成#include </usr/local/include/open3d/Open3D.h>,否则会报错找不到头文件;
(2)open3d::registration::ComputeFPFHFeature(*downsampled, open3d::geometry::KDTreeSearchParamRadius(0.25));改成 open3d::pipelines::registration::ComputeFPFHFeature(*downsampled, open3d::geometry::KDTreeSearchParamRadius(0.25));
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})
运行结果: