2017-03-16 4 views
0

私は平面モデルを(平面状の構造を持つ)点群に収めようとしています。奇数平面モデルを検出するSACSegmentation

私が遭遇している問題は、距離閾値が比較的大きな値に設定されていても、フィットした平面が雲の小さなスライスに過ぎないということです。ここで

は、結果のイメージです。(白の点がモデルインライアある)

enter image description here

あなたは雲がここにあるどのように薄い見ることができます:

enter image description here

enter image description here

私はSACSegmentationオブジェクトのすべての種類のパラメータを微調整しました。 PCLに運がない複数のRANSACメソッドを試してみました。

これは、表示されたポイントクラウドれる: https://drive.google.com/file/d/0B0PUIShwQuU7RmFKUW1Cd2V1Zk0/view?usp=sharing

をここではかなり密接にチュートリアルを次の最小限のコードは次のとおりです。

#include <iostream> 
#include <pcl/ModelCoefficients.h> 
#include <pcl/io/pcd_io.h> 
#include <pcl/point_types.h> 
#include <pcl/sample_consensus/method_types.h> 
#include <pcl/sample_consensus/model_types.h> 
#include <pcl/segmentation/sac_segmentation.h> 


int 
main(int argc, char** argv) 
{ 
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>); 
    pcl::io::loadPCDFile<pcl::PointXYZI>("test.pcd", *cloud); //* load the file 

    pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients); 
    pcl::PointIndices::Ptr inliers(new pcl::PointIndices); 
    // Create the segmentation object 
    pcl::SACSegmentation<pcl::PointXYZI> seg; 
    // Optional 
    seg.setOptimizeCoefficients(true); 
    // Mandatory 
    seg.setModelType(pcl::SACMODEL_PLANE); 
    seg.setMethodType(pcl::SAC_RANSAC); 
    seg.setDistanceThreshold(0.025); 

    seg.setInputCloud(cloud); 
    seg.segment(*inliers, *coefficients); 

    if (inliers->indices.size() == 0) 
    { 
     PCL_ERROR("Could not estimate a planar model for the given dataset."); 
     return (-1); 
    } 

    std::cerr << "Model coefficients: " << coefficients->values[0] << " " 
     << coefficients->values[1] << " " 
     << coefficients->values[2] << " " 
     << coefficients->values[3] << std::endl; 

    //add points to plane that fit plane model 
    pcl::PointCloud<pcl::PointXYZI>::Ptr output(new pcl::PointCloud<pcl::PointXYZI>); 
    for (size_t i = 0; i < inliers->indices.size(); ++i) 
    { 
     output->push_back(cloud->points[inliers->indices[i]]); 
    } 

    displaySubcloud(cloud, output); 
    displayPlane(cloud, coefficients, "plane"); 

    return (0); 
} 

答えて

0

私は解決策を考え出したが、私は知りませんそれがなぜそれを修正するのか。クラウドを原点に近づけることにより、正しい平面モデルを検出することができます。

関連する問題