编译好Open3D,就用cmake配置了个工程,测试下效果,c++版本的接口和python接口基本一致,使用上很方便,编译和运行速度相对比较快
cmake_minimum_required(VERSION 3.18)
project(Open3DCMakeFindPackage LANGUAGES C CXX)
# Find installed Open3D, which exports Open3D::Open3D
find_package(Open3D REQUIRED)
add_executable(Draw)
target_sources(Draw PRIVATE Draw.cpp)
target_link_libraries(Draw PRIVATE Open3D::Open3D)
点云数据较不稳定,采用较大搜索半径来计算法向量,提高准确性
#include
#include
#include
#include
#include
#include
#include
#include
#include "open3d/Open3D.h"
int main(int argc, char *argv[]) {
auto cloud = std::make_shared<open3d::geometry::PointCloud>();
open3d::io::ReadPointCloudOption rdo;
open3d::io::ReadPointCloudFromPCD("./cloud/0913--005/001_0005-00004.pcd", *cloud, rdo);
auto st = std::chrono::steady_clock::now();
auto downpcd = cloud->VoxelDownSample(30);
// printf("down size: %d \n", )
downpcd->EstimateNormals(open3d::geometry::KDTreeSearchParamRadius(200),true);
std::chrono::duration<double> tm = (std::chrono::steady_clock::now()-st) ;
printf("time is :%f ms\n",tm.count()*1000.0);
cloud->PaintUniformColor({0.0, 1.0, 0.0});
open3d::visualization::DrawGeometries({cloud},"source cloud",640,480,50,50,false,false,false );
open3d::visualization::DrawGeometries({downpcd},"Open3D normal estimatio",640,480,50,50,true,false,false );
return 0;
}