欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

《PCL》点云的最小外包围盒实现

程序员文章站 2024-03-16 18:02:58
...
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/common/common.h>
int main(int argc, char** argv)
{
 //定义一个点云cloud
 //pcl::PointCloud<pcl::PointXYZ> cloud;
 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
 if (pcl::io::loadPCDFile<pcl::PointXYZ>("E:\\abx.pcd", *cloud) == -1)
 {
  std::cout << "读取失败";
 }
 //定义储存极值的两个点
 pcl::PointXYZ minPoint, maxPoint;
 pcl::getMinMax3D(*cloud,minPoint, maxPoint);
 //输出结果
 std::cout << "max:x" << maxPoint.x << std::endl;
 std::cout << "max:y" << maxPoint.y << std::endl;
 std::cout << "max:z" << maxPoint.z << std::endl;
 std::cout << "min:x" << minPoint.x << std::endl;
 std::cout << "min:y" << minPoint.y << std::endl;
 std::cout << "min:z" << minPoint.z << std::endl;
 
 system("pause");
 return 0;
}