new_cloud-pointshighestYIndexr = 0; new_cloud-pointshighestYIndexg = 255; new_cloud-pointshighestYIndexb = 0;现在这三句在pc181中报错如何解决
在pcl-1.8.1版本中,点云数据的颜色信息的类型为pcl::PointXYZRGB,而不是pcl::PointXYZ。所以在设置颜色时,需要将点云数据类型转换为pcl::PointXYZRGB类型。
以下是解决方法:
- 首先,确保你的点云数据类型是pcl::PointXYZRGB类型。如果不是,请将点云数据类型转换为pcl::PointXYZRGB类型。可以使用以下代码将点云数据类型转换为pcl::PointXYZRGB类型:
pcl::PointCloud<pcl::PointXYZRGB>::Ptr new_cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB> cloud_xyzrgb;
pcl::copyPointCloud(*new_cloud, cloud_xyzrgb);
- 然后,使用以下代码设置颜色:
cloud_xyzrgb.points[highestYIndex].r = 0;
cloud_xyzrgb.points[highestYIndex].g = 255;
cloud_xyzrgb.points[highestYIndex].b = 0;
请注意,这里使用的是cloud_xyzrgb.points而不是new_cloud->points。
希望这可以帮助你解决问题
原文地址: http://www.cveoy.top/t/topic/h8g7 著作权归作者所有。请勿转载和采集!