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;

}

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

相关推荐
磊灬泽1 小时前
【日常错误】鼠标无反应
linux·windows
TomCode先生2 小时前
c#动态树形表达式详解
开发语言·c#
高-老师3 小时前
基于R语言的物种气候生态位动态量化与分布特征模拟
开发语言·r语言·物种气候
大翻哥哥3 小时前
Python 2025:量化金融与智能交易的新纪元
开发语言·python·金融
weixin_437830944 小时前
使用冰狐智能辅助实现图形列表自动点击:OCR与HID技术详解
开发语言·javascript·ocr
鹿鹿学长4 小时前
2025年全国大学生数学建模竞赛(C题) 建模解析|婴儿染色体数学建模|小鹿学长带队指引全代码文章与思路
c语言·开发语言·数学建模
zhousenshan4 小时前
Python爬虫常用框架
开发语言·爬虫·python
利刃大大5 小时前
【高并发内存池】五、页缓存的设计
c++·缓存·项目·内存池
DKPT5 小时前
Java内存区域与内存溢出
java·开发语言·jvm·笔记·学习
C语言小火车5 小时前
【C++八股文】基础知识篇
c++·tcp/ip·const·智能指针·多线程同步·static关键字·c++内存模型