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 {}\n\n", 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 {}\n\n", 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文件)
 
  

打开效果如下:

Ubuntu18.04源码安装Open3D_第1张图片

如果想通过Open3D查看文件:

终端输入

open3d draw 文件名

Ubuntu18.04源码安装Open3D_第2张图片

 

参考:

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

你可能感兴趣的:(ubuntu,linux,open3d)