Ubuntu18.04 安装Open3D

本文档详细介绍了在Ubuntu 18.04上安装Open3D的过程,包括升级cmake和clang,处理网络问题,以及解决编译错误。最后,通过一个简单的测试程序验证了Open3D的正确安装,并展示了如何使用Open3D进行点云处理和可视化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

准备工作

根据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})

运行结果:

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

兔子的倔强

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值