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;

}

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

相关推荐
2501_9032386521 分钟前
Git Bash:Windows下的强大命令行工具
windows·git·bash·个人开发
Forget the Dream36 分钟前
设计模式之责任链模式
java·c++·设计模式·责任链模式
停止重构37 分钟前
【开源】低代码 C++程序框架,Linux多线程程序
c++·低代码·多线程·开源框架·云计算引擎
Joey_friends39 分钟前
【Linux】线程详解
开发语言
Duramentee40 分钟前
C++ 设计模式 十二:责任链模式 (读书 现代c++设计模式)
c++·设计模式·责任链模式
_GR1 小时前
Qt开发⑧Qt的窗口_下_浮动窗口+对话框
开发语言·css·c++·qt·microsoft
Good Note1 小时前
Golang——常用库context和runtime
开发语言·爬虫·golang
萌の鱼1 小时前
leetcode 3183. 达到总和的方法数量
数据结构·c++·算法·leetcode
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
清河__1 小时前
【Go】十七、grpc 服务的具体功能编写
开发语言·后端·golang