Open3D C++与Python 安装步骤
python 版本的open3d安装起来比较容易可以直接使用pip或者conda命令.
pip
pip install open3d
conda
conda install -c open3d-admin open3d
官网提供了丰富的python的接口教程, 希望使用python的朋友,可以参考官网
Open3D C++版本安装
安装环境: ubuntu18.04.
首先clone最新版本的源码到你的系统下面.
1. 下载源码包
git clone --recursive https://github.com/intel-isl/Open3D
由于作者将移除了部分依赖包,需要使用–recursive将依赖包一起下载下来.
这里如果你的网络不好, 可以下载笔者安装时候的版本(0.10.0)链接.提取码: 5s9s
2. 安装open3d所需要的依赖项
cd Open3D
util/scripts/install-deps-ubuntu.sh
3. 编译并安装
Open3D是一个标准的C++工程,按照正常的cmake顺序安装即可.
mkdir -p build
cd build
cmake ..
make -j4
sudo make install
经过一段时间的编译和安装以后, Open3D会成功的安装到你的系统上.
4. 使用测试
新建一个cmake工程文件.
输入以下源码读取ply点云后, 进行降采样, 估计点云的法向量, 并进行可视化.
#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中写入
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})
编译运行, 请在命令行中输入ply的文件路径.笔者使用的ply文件是examples/TestData/ICP/cloud_bin_0.pcd
一切顺利的话, 你将会看到一下结果
原始点云
体素滤波降采样后的点云
end: 有没有觉得比pcl的可视化酷炫多了, 哈哈~!!!