資源簡介
使用PCL中RANSAC探測識別平面,并且可將探測出的多個平面進行單獨保存。
代碼片段和文件信息
//RANSAC探測多個平面
#include
#include?
#include?
#include?
#include????//隨機參數估計方法頭文件
#include????//模型定義頭文件
#include????//基于采樣一致性分割的類的頭文件
#include?
#include?
#include
#include?
#include
using?namespace?std;
int?GetRandomNumber()
{
int?RandomNumber;
RandomNumber?=?rand()?%?(256)?+?0;//0到255之間選擇顏色
//生成其他范圍的數字:RandomNumber?=?rand()?%?(b-a+1)?+?a;
return?RandomNumber;
}
void?main()
{
//第一步:定義輸入的原始數據及濾波后的點,以及分割獲得的點、平面系數coefficients、存儲內點的索引集合對象inliers、用于顯示的窗口
pcl::PointCloud::Ptr?cloud(new?pcl::PointCloud);
pcl::PointCloud::Ptr?planar_segment(new?pcl::PointCloud);//創建分割對象
pcl::io::loadPCDFile(“E:\\program_study\\C++\\pcd_data\\table_scene_lms400.pcd“?*cloud);
//pcl::io::loadPCDFile(“E:\\program_study\\C++\\pcd_data\\cubic.pcd“?*cloud);
pcl::ModelCoefficients::Ptr?coefficients(new?pcl::ModelCoefficients);//模型系數
pcl::PointIndices::Ptr?inliers(new?pcl::PointIndices);//索引列表
pcl::SACSegmentation?seg;//分割對象
pcl::visualization::PCLVisualizer?viewer(“planar?segment“);
viewer.setBackgroundColor(0?0?0);
pcl::ExtractIndices?extract;//提取器
int?n_piece=2;//需要探測的面的個數
//第二步:將原始點加載進入
pcl::visualization::P
- 上一篇:學生通訊錄管理系統
- 下一篇:實序列FFT算法的C語言實現
評論
共有 條評論