前言:
先将点云数据生成深度图像,再对深度图像进行边界提取,而不是直接对点云进行边界提取!!!
基于法线估计的边界提取见https://blog.csdn.net/suyunzzz/article/details/99610120
代码:
/* \author Bastian Steder */
#include <iostream>
#include <boost/thread/thread.hpp>//线程头文件
#include <pcl/range_image/range_image.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/range_image_visualizer.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/features/range_image_border_extractor.h>
#include <pcl/console/parse.h>//解析命令行参数头文件
#include <pcl/visualization/common/float_image_utils.h>//保存深度图相关头文件
#include <pcl/io/png_io.h>//保存至图片的头文件
#include <pcl/filters/statistical_outlier_removal.h>//statiacl滤波
typedef pcl::PointXYZ PointType;
// --------------------
// -----参数-----
// --------------------
float angular_resolution = 0.5f;
pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME;
bool setUnseenToMaxRange = false;//设置不可见点为最大距离?
// --------------
// -----帮助-----
// --------------
void
printUsage (const char* progName)
{
std::cout << "\n\nUsage: "<<progName<<" [options] <scene.pcd>\n\n"
<< "Options:\n"
<< "-------------------------------------------\n"
<< "-r <float> angular resolution in degrees (default "<<angular_resolution<<")\n"
<< "-c <int> coordinate frame (default "<< (int)coordinate_frame<<")\n"
<< "-m Treat all unseen points to max range\n"
<< "-h this help\n"
<< "\n\n";
}
// --------------
// -----主函数----
// --------------
int
main (int argc, char** argv)
{
// --------------------------------------
// -----解析命令行参数-----
// --------------------------------------
if (pcl::console::find_argument (argc, argv, "-h") >= 0)
{
printUsage (argv[0]);
return 0;
}
if (pcl::console::find_argument (argc, argv, "-m") >= 0)
{
setUnseenToMaxRange = true;
cout << "Setting unseen values in range image to maximum range readings.\n";
}
int tmp_coordinate_frame;//临时坐标系
if (pcl::console::parse (ar