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;

}

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

相关推荐
264玫瑰资源库1 小时前
问道数码兽 怀旧剧情回合手游源码搭建教程(反查重优化版)
java·开发语言·前端·游戏
普if加的帕2 小时前
java Springboot使用扣子Coze实现实时音频对话智能客服
java·开发语言·人工智能·spring boot·实时音视频·智能客服
2301_807611492 小时前
77. 组合
c++·算法·leetcode·深度优先·回溯
安冬的码畜日常3 小时前
【AI 加持下的 Python 编程实战 2_10】DIY 拓展:从扫雷小游戏开发再探问题分解与 AI 代码调试能力(中)
开发语言·前端·人工智能·ai·扫雷游戏·ai辅助编程·辅助编程
朝阳5813 小时前
Rust项目GPG签名配置指南
开发语言·后端·rust
微网兔子3 小时前
伺服器用什么语言开发呢?做什么用什么?
服务器·c++·后端·游戏
朝阳5813 小时前
Rust实现高性能目录扫描工具ll的技术解析
开发语言·后端·rust
程高兴3 小时前
基于Matlab的车牌识别系统
开发语言·matlab
YuforiaCode3 小时前
第十三届蓝桥杯 2022 C/C++组 修剪灌木
c语言·c++·蓝桥杯
YOULANSHENGMENG3 小时前
linux 下python 调用c++的动态库的方法
c++·python