#include <open3d/Open3D.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
// --------------------------------读取点云-------------------------------------
auto cloud = std::make_shared<open3d::geometry::PointCloud>();
if (open3d::io::ReadPointCloud("hand.pcd", *cloud) == 0)
{
open3d::utility::LogInfo("点云读取失败!!!");
return -1;
}
// ------------------------------点云随机赋色------------------------------------
open3d::utility::LogInfo("点云随机赋色");
if (!cloud->HasColors())
{
cloud->PaintUniformColor(Eigen::Vector3d(0, 0, 0));
}
srand(time(NULL));//设置随机数种子,使每次产生的随机序列不同
for (size_t i = 0; i < cloud->points_.size(); i++)
{
double R = rand() % (256) + 0;
double G = rand() % (256) + 0;
double B = rand() % (256) + 0;
R /= 255.0;
G /= 255.0;
B /= 255.0;
Eigen::Vector3d RandomColor = { R, G, B };
cloud->colors_[i] = RandomColor;
}
open3d::visualization::DrawGeometries({ cloud }, "Random Color Cloud", 1600, 900);
return 0;
}
C++ 【 Open3D 】 点云随机渲染颜色
最新推荐文章于 2024-08-07 14:50:42 发布