Windows采用VS2019实现Open3D的C++应用

1、参考链接

https://blog.csdn.net/qq_31254435/article/details/137799739

但是,我的方法和上述链接不大一样,我是采用VS2019进行编译的,方便在Windows平台上验证各种算法。

2、创建一个VS2019的C++ Console工程

#include <iostream>

#include <open3d/Open3D.h>

int main() {

using namespace open3d::geometry;

auto sphere = TriangleMesh::CreateSphere(1.0, 4);

sphere->ComputeVertexNormals();

sphere->PaintUniformColor({ 1, 0.706, 0 });

std::cout << sphere->vertices_.size() << " vertices\n";

std::cout << sphere->triangles_.size() << " triangles\n";

open3d::visualization::DrawGeometries({ sphere });

}

Include目录:

库目录:

3、将Open3D.dll放入到系统的Path当中

4、运行效果

5、载入一个PLY文件显示

#include <iostream>

#include <open3d/Open3D.h>

int main()

{

std::string file_path = "E:\\PDAL\\PDAL\\bin\\t2.ply";

// 创建 PointCloud 对象

open3d::geometry::PointCloud point_cloud;

// 创建读取选项(可以根据需要添加参数)

open3d::io::ReadPointCloudOption params;

// 读取 PLY 文件

if (!open3d::io::ReadPointCloudFromPLY(file_path, point_cloud, params)) {

std::cerr << "Failed to load PLY file: " << file_path << std::endl;

return 1;

}

// 对点云进行法线估计

point_cloud.EstimateNormals(open3d::geometry::KDTreeSearchParamHybrid(0.1, 30));

// 缩放点云

double scale_factor = 10.0; // 调整此因子以改变点云大小

for (auto& point : point_cloud.points_) {

point = point * scale_factor;

}

// 创建可视化窗口

open3d::visualization::Visualizer visualizer;

visualizer.CreateVisualizerWindow("Point Cloud from PLY", 1024, 768);

// 使用 std::make_shared 将 PointCloud 转换为 std::shared_ptr

visualizer.AddGeometry(std::make_shared<const open3d::geometry::PointCloud>(point_cloud));

visualizer.Run();

visualizer.DestroyVisualizerWindow();

return 0;

}

(愿意点赞和收藏的小伙伴,不妨关注我,我正在寻求涨粉)

相关推荐
环能jvav大师6 分钟前
基于R语言的统计分析基础:使用SQL语句操作数据集
开发语言·数据库·sql·数据分析·r语言·sqlite
吱吱鼠叔9 分钟前
MATLAB方程求解:1.线性方程组
开发语言·matlab·php
Antonio91514 分钟前
【CMake】使用CMake在Visual Studio内构建多文件夹工程
开发语言·c++·visual studio
LyaJpunov27 分钟前
C++中move和forword的区别
开发语言·c++
程序猿练习生32 分钟前
C++速通LeetCode中等第9题-合并区间
开发语言·c++·leetcode
z千鑫40 分钟前
【人工智能】如何利用AI轻松将java,c++等代码转换为Python语言?程序员必读
java·c++·人工智能·gpt·agent·ai编程·ai工具
一名路过的小码农42 分钟前
C/C++动态库函数导出 windows
c语言·开发语言·c++
m0_6312704044 分钟前
标准c语言(一)
c语言·开发语言·算法
万河归海42844 分钟前
C语言——二分法搜索数组中特定元素并返回下标
c语言·开发语言·数据结构·经验分享·笔记·算法·visualstudio
Messiah___1 小时前
【论文阅读】Slim Fly: A Cost Effective Low-Diameter Network Topology 一种经济高效的小直径网络拓扑
开发语言·php