資源簡介
采用PCL來對點云的體積進行求解,語言采用C++進行實現

代碼片段和文件信息
#include??????????????????????????//常用輸入輸出頭文件
#include?
#include??????????//OpenNI采集頭文件
#include???????????//采樣一致性模型相關類頭文件
#include?????????????????//點云數據?點類型頭文件
#include??//可視化頭文件
#include?????????????????????//直通濾波器頭文件
#include??????????????????????//體素濾波器頭文件
#include?????????????????//索引提取濾波器頭文件
#include?????//統計濾波頭文件
#include?????????????????//映射相關頭文件
#include???//隨機參數估計方法頭文件
#include????//模型定義頭文件
#include???//基于采樣一致性分割的類的頭文件
#include????????????//提取凸(凹)多邊形的頭文件
//#include????//opencv頭文件
using?namespace?std;
//using?namespace?cv;
class?SimpleOpenNIProcessor
{
public:
pcl::visualization::CloudViewer?viewer;?//?Cloudviewer顯示對象
//?直通濾波器對象
pcl::PassThrough?XpassFilter;
pcl::PassThrough?YpassFilter;
//?下采樣?VoxelGrid?濾波對象
pcl::VoxelGrid?VoxlFilter;
//?創建分割對象
pcl::SACSegmentation?segPlane;
//?提取索引濾波器
pcl::ExtractIndices?extractPlane;
//?統計濾波器
pcl::StatisticalOutlierRemoval?statisFilter;
//?點云投影濾波對象
pcl::ProjectInliers?projec;
int?heightCount?=?0;
float?heightSum?=?0.0;
int?areaCount?=?0;
float?areaSum?=?0.0;
SimpleOpenNIProcessor()?:?viewer(“PCL?OpenNI?Viewer“)?{
//?濾波字段設為x軸方向
XpassFilter.setFilterFieldName(“x“);
//?設定可接受范圍,將不在范圍內的點過濾掉或者保留(由setFilterLimitsNegative決定)
XpassFilter.setFilterLimits(-0.25?0.05);??//?TODO:?X方向裁剪閾值需要調試?實際是0.44m
???//?濾波字段設為y軸方向
YpassFilter.setFilterFieldName(“y“);
//?設定可接受范圍,將不在范圍內的點過濾掉或者保留(由setFilterLimitsNegative決定)
YpassFilter.setFilterLimits(-0.27?0.18);??//?TODO:?Y方向裁剪閾值需要調試?實際是0.69m
???//?設置體素濾波時創建的體素體積為0.5*0.5*0.5cm的立方體
VoxlFilter.setLeafSize(0.005f?0.005f?0.005f);
//?統計濾波初始設置
statisFilter.setMeanK(50);??//?對每個點分析的臨近點個數設為50
statisFilter.setStddevMulThresh(1.0);???//?將標準差倍數設為1,意味著一個點的距離超出平均距離1個標準差以上,就會被標記為離群點,并被移除。
//?可選:設置模型系數需要優化
segPlane.setOptimizeCoefficients(true);
//?必選:設置分割的模型類型、所用的隨機參數估計方法、距離閾值、迭代次數上限
segPlane.setModelType(pcl::SACMODEL_PLANE);
segPlane.setMethodType(pcl::SAC_RANSAC);
segPlane.setDistanceThreshold(0.01);????//?TODO:?距離閾值需要調試
segPlane.setMaxIterations(1000);
//?設置投影模型為SACMODEL_PLANE
projec.setModelType(pcl::SACMODEL_PLANE);
}??//?Construct?a?cloud?viewer?with?a?window?name
??//?定義回調函數cloud_cb_獲取到數據時對數據進行處理
void?cloud_cb_(const?pcl::PointCloud::ConstPtr?&cloud)
{
heightCount++;
areaCount++;
cout?<“原始點云大小:“?<points.size()?<
//?1.?空間裁剪
pcl::PointCloud::Ptr?pass_filtered
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-12-16?22:51??PointCloudVolume\
?????文件????????2518??2018-06-11?20:28??PointCloudVolume\.gitattributes
?????文件????????3781??2018-06-11?20:28??PointCloudVolume\.gitignore
?????文件???????73234??2018-06-11?20:28??PointCloudVolume\ALL_BUILD.vcxproj
?????文件?????????289??2018-06-11?20:28??PointCloudVolume\ALL_BUILD.vcxproj.filters
?????文件????????1412??2018-06-11?20:28??PointCloudVolume\cmake_install.cmake
?????文件???????47860??2018-06-11?20:28??PointCloudVolume\CMakeCache.txt
?????目錄???????????0??2018-12-16?22:51??PointCloudVolume\imgRecord\
?????文件?????5054181??2018-06-11?20:28??PointCloudVolume\imgRecord\GIF.gif
?????文件??????330706??2018-06-11?20:28??PointCloudVolume\imgRecord\originCloud.png
?????文件??????239551??2018-06-11?20:28??PointCloudVolume\imgRecord\passThrough.png
?????文件??????160249??2018-06-11?20:28??PointCloudVolume\imgRecord\PlaneSeg.png
?????文件??????145220??2018-06-11?20:28??PointCloudVolume\imgRecord\statisFiltered.png
?????文件??????135432??2018-06-11?20:28??PointCloudVolume\imgRecord\voxelFiltered.png
?????文件???????11357??2018-06-11?20:28??PointCloudVolume\LICENSE
?????文件????????3063??2018-06-11?20:28??PointCloudVolume\openni_grabber.sln
?????文件??????175894??2018-06-11?20:28??PointCloudVolume\openni_grabber.vcxproj
?????文件?????????596??2018-06-11?20:28??PointCloudVolume\openni_grabber.vcxproj.filters
?????文件????????1240??2018-06-11?20:28??PointCloudVolume\README.md
?????目錄???????????0??2018-12-16?22:51??PointCloudVolume\source\
?????文件?????????443??2018-06-11?20:28??PointCloudVolume\source\CMakeLists.txt
?????文件????????1190??2018-06-11?20:28??PointCloudVolume\source\opencv2413_debug_x64.props
?????文件????????1054??2018-06-11?20:28??PointCloudVolume\source\opencv2413_release_x64.props
?????文件???????12020??2018-06-11?20:28??PointCloudVolume\source\openni_grabber.cpp
?????文件???????12858??2018-06-11?20:28??PointCloudVolume\source\volDetectVisualizer.cpp
?????文件???????63761??2018-06-11?20:28??PointCloudVolume\ZERO_CHECK.vcxproj
?????文件?????????514??2018-06-11?20:28??PointCloudVolume\ZERO_CHECK.vcxproj.filters
- 上一篇:wavelet的dll封裝與c++調用
- 下一篇:opengl簡單的陰影貼圖
評論
共有 條評論