我有一个在所有 3 个维度上都具有广泛范围的点云数据。我已经使用 pcl::ConditionalRemoval::filter() 在 -20 >= x >= 20、-20 >= y >= 20 和 -2 >= z >= 2 范围内对其进行过滤。现在我想要 min 和每个维度的最大值,所以我在网上搜索了 nay PCL 函数。我得到pcl::getMinMax3D。我使用它并验证我也在云数据中手动搜索。代码如下:
float xmin = 10000, xmax=-10000;
cout << "Manual Search Result:"<<endl;
for(unsigned int i = 0; i < filtered_data->size(); i++)
{
if(filtered_data->at(i)._PointXYZ::x > xmax)
xmax = filtered_data->at(i)._PointXYZ::x;
if(filtered_data->at(i)._PointXYZ::x < xmin)
xmin = filtered_data->at(i)._PointXYZ::x;
}
cout << "Xmin: " << xmin << "\t\tXmax: " << xmax << endl;
float ymin = 10000, ymax=-10000;
for(unsigned int i = 0; i < filtered_data->size(); i++)
{
if(filtered_data->at(i)._PointXYZ::y > ymax)
ymax = filtered_data->at(i)._PointXYZ::y;
if(filtered_data->at(i)._PointXYZ::y < ymin)
ymin = filtered_data->at(i)._PointXYZ::y;
}
cout << "Ymin: " << ymin << "\t\tYmax: " << ymax << endl;
float zmin = 10000, zmax=-10000;
for(unsigned int i = 0; i < filtered_data->size(); i++)
{
if(filtered_data->at(i)._PointXYZ::z > zmax)
zmax = filtered_data->at(i)._PointXYZ::z;
if(filtered_data->at(i)._PointXYZ::z < zmin)
zmin = filtered_data->at(i)._PointXYZ::z;
}
cout << "Zmin: " << zmin << "\t\tZmax: " << zmax << endl;
pcl::PointXYZ minPt, maxPt;
pcl::getMinMax3D (*filtered_data, minPt, maxPt);
cout << "getMinMax3D Search Result:"<<endl;
std::cout << "Min x: " << minPt.x << "\t\tMax x: " << maxPt.x << std::endl;
std::cout << "Min y: " << minPt.y << "\t\tMax y: " << maxPt.y << std::endl;
std::cout << "Min z: " << minPt.z << "\t\tMax z: " << maxPt.z << std::endl;
我得到的输出是:
Manual Search Result:
Xmin: -19.992 Xmax: 19.915
Ymin: -19.75 Ymax: 19.982
Zmin: -1.999 Zmax: 1.059
getMinMax3D Search Result:
Min x: -3.895 Max x: 3.967
Min y: -4.238 Max y: 4.291
Min z: -1.887 Max z: 0
我对 getMinMax3D() 的使用理解有误吗?