栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

Ubuntu18.04源码安装Open3D

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Ubuntu18.04源码安装Open3D

安装Open3D

git clone https://github.com/isl-org/Open3D.git
cd Open3D
sh util/install_deps_ubuntu.sh
mkdir build
cd build
cmake ..
make -j4
sudo make install

测试安装是否成功:

这里写一个简单的文件编译运行试试

文件如下:

demo.cpp文件如下:

#include 
#include 
#include 
#include 

// A simplified version of examples/Cpp/Visualizer.cpp to demonstrate linking
// an external project to Open3D.
int main(int argc, char *argv[])
{
    using namespace open3d;

    utility::SetVerbosityLevel(utility::VerbosityLevel::Debug);
    if (argc < 3)
    {
        utility::LogInfo("Open3D {}n", OPEN3D_VERSION);
        utility::LogInfo("n");
        utility::LogInfo("Usage:n");
        utility::LogInfo("    > TestVisualizer [mesh|pointcloud] [filename]n");
        //CI will execute this file without input files, return 0 to pass
        return 0;
    }

    std::string option(argv[1]);
    if (option == "mesh")
    {
        auto mesh_ptr = std::make_shared();
        if (io::ReadTriangleMesh(argv[2], *mesh_ptr))
        {
            utility::LogInfo("Successfully read {}n", argv[2]);
        }
        else
        {
            utility::LogWarning("Failed to read {}nn", argv[2]);
            return 1;
        }
        mesh_ptr->ComputeVertexNormals();
        visualization::DrawGeometries({mesh_ptr}, "Mesh", 1600, 900);
    }
    else if (option == "pointcloud")
    {
        auto cloud_ptr = std::make_shared();
        if (io::ReadPointCloud(argv[2], *cloud_ptr))
        {
            utility::LogInfo("Successfully read {}n", argv[2]);
        }
        else
        {
            utility::LogWarning("Failed to read {}nn", argv[2]);
            return 1;
        }
        cloud_ptr->NormalizeNormals();
        visualization::DrawGeometries({cloud_ptr}, "PointCloud", 1600, 900);
    }
    else
    {
        utility::LogWarning("Unrecognized option: {}n", option);
        return 1;
    }
    utility::LogInfo("End of the test.n");

    return 0;
}

CMakeLists.txt文件如下:

cmake_minimum_required(VERSION 3.0)
project(open3d_test)
set (CMake policy CMP0074)
set(CMAKE_CXX_STANDARD 11)

find_package( Open3D  REQUIRED)

include_directories(${Open3D_INCLUDE_DIRS})
link_directories(${Open3D_LIBRARY_DIRS})

add_executable(TestVisualizer demo.cpp)
target_link_libraries(TestVisualizer ${Open3D_LIBRARIES})

target_include_directories(TestVisualizer PUBLIC ${Open3D_INCLUDE_DIRS})

mkdir build
cd build
cmake ..
make -j4
cd build
./TestVisualizer pointcloud 文件路径名(此处我选择的是一个ply文件)
 

打开效果如下:

如果想通过Open3D查看文件:

终端输入

open3d draw 文件名

 

参考:

Ubuntu18.04 install Open3D C++ and Python version - Katastros

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1027030.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号