一、读取常见点云
#include <iostream>
#include <Open3D/Open3D.h>int main(int argc, char* argv[])
{std::string fileName("hand.pcd");auto cloud_ptr = std::make_shared<open3d::geometry::PointCloud>();if (open3d::io::ReadPointCloud(fileName, *cloud_ptr) == 0){open3d::utility::LogWarning("Failed to read {}\n\n", fileName);return -1;}cloud_ptr->NormalizeNormals(); // 将法向量归一化到1open3d::visualization::DrawGeometries({ cloud_ptr }, "PointCloud", 1600, 900);open3d::io::WritePointCloudToPCD("bunny1.pcd", *cloud_ptr, false);return 0;
}
二、显示点云自己颜色
#include <iostream>
#include <Open3D/Open3D.h>using namespace std;int main(int argc, char* argv[])
{auto cloud = std::make_shared<open3d::geometry::PointCloud>();// tree.pcd自身带有RGB颜色if (open3d::io::ReadPointCloud("Armadillo.pcd", *cloud) == 0){open3d::utility::LogWarning("点云读取失败!!!\n\n");return -1;}cout << "从点云数据中读取" << cloud->points_.size() << "个点" << endl;if (cloud->HasNormals())cloud->NormalizeNormals(); // 将法向量归一化到1open3d::visualization::DrawGeometries({ cloud }, "PointCloud", 1600, 900);open3d::io::WritePointCloudToPCD("Armadillo.pcd", *cloud, false);return 0;
}