#include <iostreamの>
する#include <ベクトル>
の#include <PCL / point_types.h>
の#include <PCL / IO / pcd_io.h>
の#include <PCL /検索/ search.h>
の#include <PCL /検索/ kdtree。 H>
の#include <PCL /可視/ cloud_viewer.h>
の#include <PCL /フィルタ/ passthrough.h>
の#include <PCL /分割/ region_growing_rgb.h>
の#include <PCL /コンソール/ PRINT.H>
する#include <PCL /console/parse.h>
の#include <PCL /コンソール/ TIME.H>
の#include <PCL /特長/ normal_3d.h>
使用して 名前空間のPCL ::コンソールを。
int型
のmain(int型argc、char型 ** ARGV)
{
// もし(ARGC <2)
// {
// はstd :: COUT <<」0 -dt 10 -nc 10 -Fc 0 .EXE xx.pcd -b_n 0 -kn 50 -st_n 30 -ct_n 0.05 -bc - CT 6 -rt 5 -mt 600" <<てendl;
// 戻り値0。
// }
のtime_t開始、終了、差分[ 5 ]オプション。
開始 =時間(0 )。
BOOL Bool_Cuting = falseを、B_N = 偽;
INT MinClusterSize = 600、KN_normal = 50 。
フロート far_cuting = 10、near_cuting = 0、DistanceThreshold = 10.0、ColorThreshold = 6、RegionColorThreshold = 5、SmoothnessThreshold = 30.0、CurvatureThreshold = 0.05 。
parse_argument(ARGC、ARGV、" -b_n "、B_N); // 補助正常情報分割使用するかどうか
parse_argument(ARGC、ARGV、" -kn "、KN_normalを); // 検索
parse_argument(ARGC、ARGV、「-st_n "SmoothnessThreshold); // ドットは通常角しきい値との照合場合
parse_argument(ARGC、ARGV、" -ct_n "CurvatureThreshold); // ドット照合曲率しきい値
parse_argument(ARGC、ARGV、" -bc ")、Bool_Cuting; // フィルタリング処理の範囲か
parse_argument(ARGC、ARGV、" -fc "、far_cuting); // フィルタ上限
parse_argument(ARGC、ARGV、" -NC "、near_cuting); // フィルタ下限
parse_argument(ARGC、ARGV、" -dt "、DistanceThreshold ); // ユークリッド距離閾値ドット照合
parse_argument(ARGC、ARGV、" -ct "、ColorThreshold); // カラードット閾値照合
parse_argument(ARGC、ARGV、" -rt "、RegionColorThreshold) ; // 場合に合成されたカラークラスタリング閾値
parse_argument(ARGC、ARGV、「-mt 」、MinClusterSize); // 含ま許容最小クラスタ内の点の数は、隣接クラスタにクラスタの価値よりも小さいです
// 延期ステップ負荷点群
PCL :: PointCloud <PCL :: PointXYZRGB> :: Ptrがクラウド(新しい PCL :: PointCloud <PCL :: PointXYZRGB> );
もし(PCL :: IO :: loadPCDFile <PCL :: PointXYZRGB>(" region_growing_rgb_tutorial.pcd "、*クラウド)== - 1 )
{
std :: coutの << " クラウドが読んで失敗しました。" << はstd ::てendl;
リターン( - 1 )。
}
エンド =時間(0 );
差分[ 0 ] = difftime(終了、開始)。
PCL_INFO(" \ローディングPCDファイル(秒)かかりた:%d \ n "、差分[ 0 ])。
PCL ::検索::検索 <PCL :: PointXYZRGB> ::のPTRツリー=ブースト:: shared_ptrの<PCL ::検索::検索<PCL :: PointXYZRGB>>( 新 PCL ::検索:: KdTree <PCL :: PointXYZRGB> );
// Noraml推定ステップ(1つのパラメータ)
PCL ::検索::検索<PCL :: PointXYZRGB> :: Ptrがtree1という=ブースト:: shared_ptrの<PCL ::検索::検索<PCL :: PointXYZRGB>>( 新 PCL: :検索:: KdTree <PCL :: PointXYZRGB> );
PCL :: PointCloud <PCL ::ノーマル> :: Ptrが法線(新しい PCL :: PointCloud <PCL ::ノーマル> );
PCL :: NormalEstimation <PCL :: PointXYZRGB、PCL ::ノーマル> normal_estimator。
normal_estimator.setSearchMethod(木)。
normal_estimator.setInputCloud(雲)。
normal_estimator.setKSearch(KN_normal)。
normal_estimator.compute( * 法線)。
エンド =時間(0 );
差分[ 1 ] = difftime(終了、開始) -デフ[ 0 ]。
PCL_INFOは(" \見積りノーマル(秒)をとります:%D \ N- "、デフ[ 1。]);
// オプションのステップ:クラッタは、カメラから離れて離れすぎてSCENEを切断
PCL IndicesPtr ::指数(新新 STD ::ベクトルを< INT > );
のiF(Bool_Cuting)// データはz軸のクリッピング範囲で処理されるかどうか
{
PCL ::パススルー <PCL :: PointXYZRGB> 渡します。
pass.setInputCloud(雲)。
pass.setFilterFieldName(" Z " )。
pass.setFilterLimits(far_cuting、near_cuting)。
pass.filter( * 指数)。
}
// リージョンRGB成長
PCL RegionGrowingRGB :: <PCL :: PointXYZRGB> REGを; //はPointXYZRGB型領域成長セグメント化されたオブジェクト作成
reg.setInputCloud(クラウド); // 設定された入力ポイントクラウド
IF(Bool_Cuting)reg.setIndices(指標) ; //は、入力点群のインデックス設定
reg.setSearchMethod(ツリー); // セットポイントクラウド検索機構
reg.setDistanceThreshold(DistanceThresholdを); // セット距離閾値は、2つの隣接点かどうかを決定するために使用される
reg.setPointColorThreshold (ColorThreshold); // セット二色閾値、2点が同じカテゴリに属するかどうかを決定するため
reg.setRegionColorThreshold(RegionColorThreshold); // セット2つの閾値領域の色領域、二つのクラスタは、領域をマージするかどうかを決定するため
reg.setMinClusterSize(MinClusterSize); // 点600のクラスターの最小数を設定
IF (B_N)を
{
reg.setSmoothModeFlag(真の);
reg.setCurvatureTestFlag(真の);
reg.setInputNormals(法線)。
reg.setSmoothnessThreshold(SmoothnessThreshold / 180.0 * M_PI)。
reg.setCurvatureThreshold(CurvatureThreshold)。
}
std ::ベクトル <PCL :: PointIndices> クラスタ。
reg.extract(クラスター)
エンド =時間(0 );
差分[ 2 ] = difftime(終了、開始) -デフ[ 0 ] -差分[ 1 ]。
PCL_INFO(" 成長\ RGB領域は(秒)かかりた:%d \ n "、差分[ 2 ])。
PCL :: PointCloud <PCL :: PointXYZRGB> ::のPtr colored_cloud = reg.getColoredCloud()。
可視化ビューア:: :: CloudViewer PCL(「ベース領域成長アルゴリズムカラーセグメンテーション・ポイント・クラウド」);
viewer.showCloud(colored_cloud)。
しばらく(!viewer.wasStopped())
{
ブースト:: this_thread ::スリープ(ブースト:: posix_time ::マイクロ秒(100 ));
}
リターン(0 )。
}