"""void stemDiameter() {\n\t\t// 导入点云文件\n\t\tpcl::PointCloudpcl::PointXYZRGB::Ptr cloud(new pcl::PointCloudpcl::PointXYZRGB);\n\t\tpcl::io::loadPLYFilepcl::PointXYZRGB("D:\DIANYUNWENJIANJIA\test_ply.ply", *cloud);\n\n\t\t// 提取索引号为43的点的y值\n\t\tfloat y = cloud->points[43].y;\n\n\t\t// 取y值大于这个点的5cm的所有点\n\t\tpcl::PointCloudpcl::PointXYZRGB::Ptr filteredCloud(new pcl::PointCloudpcl::PointXYZRGB);\n\t\tfor (size_t i = 0; i < cloud->points.size(); ++i) {\n\t\t\tif (cloud->points[i].y > (y + 0.05)) {\n\t\t\t\tfilteredCloud->points.push_back(cloud->points[i]);\n\t\t\t}\n\t\t}\n\t\tfilteredCloud->width = filteredCloud->points.size();\n\t\tfilteredCloud->height = 1;\n\n\t\t// 将筛选出的茎点云数据分为八个切片\n\t\tstd::vector<pcl::PointCloudpcl::PointXYZRGB::Ptr> slices;\n\t\tfor (float thickness = 0.02; thickness <= 0.1; thickness += 0.01) {\n\t\t\tpcl::PointCloudpcl::PointXYZRGB::Ptr slice(new pcl::PointCloudpcl::PointXYZRGB);\n\t\t\tfor (size_t i = 0; i < filteredCloud->points.size(); ++i) {\n\t\t\t\tif (filteredCloud->points[i].y > (y + thickness - 0.01) && filteredCloud->points[i].y < (y + thickness)) {\n\t\t\t\t\tslice->points.push_back(filteredCloud->points[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tslice->width = slice->points.size();\n\t\t\tslice->height = 1;\n\t\t\tslices.push_back(slice);\n\t\t}\n\n\t\t// 对每个切片上的点云数据进行投影到X-Z平面\n\t\tstd::vector<pcl::PointCloudpcl::PointXYZRGB::Ptr> projectedClouds;\n\t\tfor (size_t i = 0; i < slices.size(); ++i) {\n\t\t\tpcl::PointCloudpcl::PointXYZRGB::Ptr projectedCloud(new pcl::PointCloudpcl::PointXYZRGB);\n\t\t\tfor (size_t j = 0; j < slices[i]->points.size(); ++j) {\n\t\t\t\tpcl::PointXYZRGB point;\n\t\t\t\tpoint.x = slices[i]->points[j].x;\n\t\t\t\tpoint.y = 0;\n\t\t\t\tpoint.z = slices[i]->points[j].z;\n\t\t\t\tprojectedCloud->points.push_back(point);\n\t\t\t}\n\t\t\tprojectedCloud->width = projectedCloud->points.size();\n\t\t\tprojectedCloud->height = 1;\n\t\t\tprojectedClouds.push_back(projectedCloud);\n\t\t}\n\n\t\t// 可视化\n\t\tboost::shared_ptrpcl::visualization::PCLVisualizer viewer(new pcl::visualization::PCLVisualizer("Stem Diameter"));\n\t\tviewer->setBackgroundColor(0, 0, 0);\n\t\tviewer->initCameraParameters();\n\n\t\tfor (size_t i = 0; i < projectedClouds.size(); ++i) {\n\t\t\tpcl::visualization::PointCloudColorHandlerRGBFieldpcl::PointXYZRGB rgb(projectedClouds[i]);\n\t\t\tviewer->addPointCloudpcl::PointXYZRGB(projectedClouds[i], rgb, "cloud" + std::to_string(i));\n\t\t}\n\n\t\twhile (!viewer->wasStopped()) {\n\t\t\tviewer->spinOnce(100);\n\t\t\tboost::this_thread::sleep(boost::posix_time::microseconds(100000));\n\t\t}\n\t}"""运行这段代码出现[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:24: property 'float32 focal' of element 'camera' is not handled\n[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:25: property 'float32 scalex' of element 'camera' is not handled\n[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:26: property 'float32 scaley' of element 'camera' is not handled\n[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:27: property 'float32 centerx' of element 'camera' is not handled\n[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:28: property 'float32 centery' of element 'camera' is not handled\n[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:31: property 'float32 k1' of element 'camera' is not handled\n[pcl::PLYReader] D:\DIANYUNWENJIANJIA\test_ply.ply:32: property 'float32 k2' of element 'camera' is not handled\n该如何解决内容:这个警告是由于点云文件中包含了相机参数的属性,而PCL的PLYReader并不处理这些属性。这些属性在该代码中并不需要,因此可以忽略这些警告。\n\n如果你不想看到这些警告,可以使用PointCloud类的getCameraParameters()函数来避免读取这些属性。具体修改如下:\n\ncpp\n\tpcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);\n\tpcl::PLYReader reader;\n\treader.read("D:\\DIANYUNWENJIANJIA\\test_ply.ply", *cloud);\n\tcloud->sensor_orientation_ = Eigen::Quaternionf::Identity();\n\tcloud->sensor_origin_ = Eigen::Vector4f::Zero();\n

解决PCL读取PLY文件时出现的警告:

原文地址: https://www.cveoy.top/t/topic/p2i2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录