๐Ÿ’ป
Tutorial
  • INTRO
  • Part 0 (๊ฐœ์š”)
    • README
    • 3D ์˜์ƒ์ฒ˜๋ฆฌ
    • [๋ณ„์ฒจ] PCL & PCD๋ž€ (100%)
    • chapter02 : PCL ์„ค์น˜ (100%)
    • chapter03 : ROS ์‹ค์Šต ์ค€๋น„(100%)
  • Part 1 (์ดˆ๊ธ‰)
    • README
    • PCL ๊ธฐ๋ฐ˜ ๋กœ๋ด‡ ๋น„์ ผ
    • [๋ณ„์ฒจ] ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์ž…์ถœ๋ ฅ (70%)
      • PCL-Cpp (70%)
      • PCL-Python (70%)
      • Open3D-Python (70%)
      • ROS ์‹ค์Šต (90%)
    • Filter
    • [๋ณ„์ฒจ] ์ƒ˜ํ”Œ๋ง (70%)
      • ๋‹ค์šด์ƒ˜ํ”Œ๋ง-PCL-Cpp (70%)
      • ๋‹ค์šด์ƒ˜ํ”Œ๋ง-PCL-Python (50%)
      • ์—…์ƒ˜ํ”Œ๋ง-PCL-Cpp (70%)
      • ROS ์‹ค์Šต (90%)
    • [๋ณ„์ฒจ] ๊ด€์‹ฌ ์˜์—ญ ์„ค์ • (70%)
      • PCL-Cpp (70%)
      • PCL-Python (70%)
      • ROS ์‹ค์Šต (90%)
    • [๋ณ„์ฒจ] ๋…ธ์ด์ฆˆ ์ œ๊ฑฐ (70%)
      • PCL-Cpp (70%)
      • PCL-Python (50%)
      • ROS ์‹ค์Šต (90%)
  • Part 2 (์ค‘๊ธ‰)
    • README
    • Kd-Tree/Octree Search
    • Chapter03 : Sample Consensus
    • [๋ณ„์ฒจ] ๋ฐ”๋‹ฅ์ œ๊ฑฐ (RANSAC) (70%)
      • PCL-Cpp (70%)
      • PCL-Python (70%)
      • ROS ์‹ค์Šต (90%)
    • ๊ตฐ์ง‘ํ™” (70%)
      • Euclidean-PCL-Cpp (70%)
      • Euclidean-PCL-Python (0%)
      • Conditional-Euclidean-PCL-Cpp (50%)
      • DBSCAN-PCL-Python (0%)
      • Region-Growing-PCL-Cpp (50%)
      • Region-Growing-RGB-PCL-Cpp (50%)
      • Min-Cut-PCL-Cpp (50%)
      • Model-Outlier-Removal-PCL-Cpp (50%)
      • Progressive-Morphological-Filter-PCL-Cpp (50%)
    • ํฌ์ธํŠธ ํƒ์ƒ‰๊ณผ ๋ฐฐ๊ฒฝ์ œ๊ฑฐ (60%)
      • Search-Octree-PCL-Cpp (70%)
      • Search-Octree-PCL-Python (70%)
      • Search-Kdtree-PCL-Cpp (70%)
      • Search-Kdtree-PCL-Python (70%)
      • Compression-PCL-Cpp (70%)
      • DetectChanges-PCL-Cpp (50%)
      • DetectChanges-PCL-Python (50%)
    • ํŠน์ง• ์ฐพ๊ธฐ (50%)
      • PFH-PCL-Cpp
      • FPFH-PCL-Cpp
      • Normal-PCL-Cpp (70%)
      • Normal-PCL-Python (80%)
      • Tmp
    • ๋ถ„๋ฅ˜/์ธ์‹ (30%)
      • ์ธ์‹-GeometricConsistencyGrouping
      • SVM-RGBD-PCL-Python (70%)
      • SVM-LIDAR-PCL-Python (0%)
      • SVM-ROS (0%)
    • ์ •ํ•ฉ (70%)
      • ICP-PCL-Cpp (70%)
      • ICP-ROS ์‹ค์Šต (10%)
    • ์žฌ๊ตฌ์„ฑ (30%)
      • Smoothig-PCL-Cpp (70%)
      • Smoothig-PCL-Python (70%)
      • Triangulation-PCL-Cpp (70%)
  • Part 3 (๊ณ ๊ธ‰)
    • README
    • ๋”ฅ๋Ÿฌ๋‹ ๊ธฐ๋ฐ˜ ํ•™์Šต ๋ฐ์ดํ„ฐ ์ƒ์„ฑ (0%)
      • PointGAN (90%)
      • AutoEncoder (0%)
    • ๋”ฅ๋Ÿฌ๋‹ ๊ธฐ๋ฐ˜ ์ƒ˜ํ”Œ๋ง ๊ธฐ๋ฒ• (0%)
      • DenseLidarNet (50%)
      • Point Cloud Upsampling Network
      • Pseudo-LiDAR
    • ๋”ฅ๋Ÿฌ๋‹ ๊ธฐ๋ฐ˜ ์ž์œจ์ฃผํ–‰ ํƒ์ง€ ๊ธฐ์ˆ  (0%)
    • ๋”ฅ๋Ÿฌ๋‹ ๊ธฐ๋ฐ˜ ์ž์œจ์ฃผํ–‰ ๋ถ„๋ฅ˜ ๊ธฐ์ˆ  (0%)
      • Multi3D
      • PointNet
      • VoxelNet (50%)
      • YOLO3D
      • SqueezeSeg
      • butNet
  • Snippets
    • PCL-Snippets
    • PCL-Python-Helper (10%)
    • Lidar Data Augmentation
  • Appendix
    • ์‹œ๊ฐํ™”Code
    • ์‹œ๊ฐํ™”ํˆด
    • Annotationํˆด
    • Point Cloud Libraries (0%)
    • ๋ฐ์ดํ„ฐ์…‹
    • Cling_PCL
    • ์ฐธ๊ณ  ์ž๋ฃŒ
    • ์ž‘์„ฑ ๊ณ„ํš_Tips
    • ์šฉ์–ด์ง‘
Powered by GitBook
On this page

Was this helpful?

  1. Part 2 (์ค‘๊ธ‰)
  2. ๊ตฐ์ง‘ํ™” (70%)

Conditional-Euclidean-PCL-Cpp (50%)

#include <pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/console/time.h>

#include <pcl/filters/voxel_grid.h>
#include <pcl/features/normal_3d.h>
#include <pcl/segmentation/conditional_euclidean_clustering.h>

//Conditional Euclidean Clustering
//http://pointclouds.org/documentation/tutorials/conditional_euclidean_clustering.php#conditional-euclidean-clustering


bool
customRegionGrowing (const pcl::PointXYZINormal& point_a, const pcl::PointXYZINormal& point_b, float squared_distance)
{
  Eigen::Map<const Eigen::Vector3f> point_a_normal = point_a.getNormalVector3fMap (), point_b_normal = point_b.getNormalVector3fMap ();
  if (squared_distance < 10000)
  {
    if (std::abs (point_a.intensity - point_b.intensity) < 8.0f)
      return (true);
    if (std::abs (point_a_normal.dot (point_b_normal)) < 0.06)
      return (true);
  }
  else
  {
    if (std::abs (point_a.intensity - point_b.intensity) < 3.0f)
      return (true);
  }
  return (false);
}

int
main (int argc, char** argv)
{
  // *.PCD ํŒŒ์ผ ์ฝ๊ธฐ 
  // https://excellmedia.dl.sourceforge.net/project/pointclouds/PCD%20datasets/Trimble/Outdoor1/Statues_4.pcd.zip
  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZI>);
  pcl::io::loadPCDFile <pcl::PointXYZI> ("Statues_4.pcd", *cloud_in);
  // ํฌ์ธํŠธ์ˆ˜ ์ถœ๋ ฅ
  std::cout << "Loaded :" << cloud_in->points.size () << std::endl;

  // ๋‹ค์šด ์ƒ˜ํ”Œ๋ง 
  pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZI>);
  pcl::VoxelGrid<pcl::PointXYZI> vg;
  vg.setInputCloud (cloud_in);
  vg.setLeafSize (80.0, 80.0, 80.0);
  vg.setDownsampleAllData (true);
  vg.filter (*cloud_out);

  // Normal ๊ณ„์‚ฐํ›„ ํ•ฉ์น˜๊ธฐ (Set up a Normal Estimation class and merge data in cloud_with_normals)
  pcl::PointCloud<pcl::PointXYZINormal>::Ptr cloud_with_normals (new pcl::PointCloud<pcl::PointXYZINormal>);
  pcl::search::KdTree<pcl::PointXYZI>::Ptr search_tree (new pcl::search::KdTree<pcl::PointXYZI>);
  pcl::copyPointCloud (*cloud_out, *cloud_with_normals);
  pcl::NormalEstimation<pcl::PointXYZI, pcl::PointXYZINormal> ne;
  ne.setInputCloud (cloud_out);
  ne.setSearchMethod (search_tree);
  ne.setRadiusSearch (300.0);
  ne.compute (*cloud_with_normals);


  // Set up a Conditional Euclidean Clustering class
  pcl::IndicesClustersPtr clusters (new pcl::IndicesClusters);
  pcl::ConditionalEuclideanClustering<pcl::PointXYZINormal> cec(true);   //True = ์ž‘๊ฑฐ๋‚˜(setMinClusterSize) ํฐ๊ฒƒ๋„(setMaxClusterSize) ์ˆ˜ํ–‰ 
  cec.setInputCloud (cloud_with_normals);                            // ์ž…๋ ฅ 
  cec.setConditionFunction (&customRegionGrowing);                   // ์‚ฌ์šฉ์ž ์ •์˜ ์กฐ๊ฑด 
  cec.setClusterTolerance (500.0);                                   //K-NN ํƒ์ƒ‰์‹œ Radius๊ฐ’ (ํ›„๋ณด ํฌ์ธํŠธ ํƒ์ƒ‰์— ์‚ฌ์šฉ)
  cec.setMinClusterSize (cloud_with_normals->points.size () / 1000); //ํด๋Ÿฌ์Šคํ„ฐ ์ตœ์†Œ ํฌ์ธํŠธ ์ˆ˜ (eg. ์ „์ฒด ํฌ์ธํŠธ ์ˆ˜์˜ 0.1% ์ดํ•˜ ) 
  cec.setMaxClusterSize (cloud_with_normals->points.size () / 5);    //ํด๋Ÿฌ์Šคํ„ฐ ์ตœ๋Œ€ ํฌ์ธํŠธ ์ˆ˜ (eg. ์ „์ฒด ํฌ์ธํŠธ ์ˆ˜์˜ 20% ์ด์ƒ )
  cec.segment (*clusters);                                           //๊ตฐ์ง‘ํ™” ์‹คํ–‰ 

  // True๋กœ ์ดˆ๊ธฐํ™”์‹œ ์ž‘๊ฑฐ๋‚˜ ํฐ๊ฒƒ์˜ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ๊ณณ 
  pcl::IndicesClustersPtr small_clusters (new pcl::IndicesClusters);
  pcl::IndicesClustersPtr large_clusters (new pcl::IndicesClusters);
  cec.getRemovedClusters (small_clusters, large_clusters);           


  // Using the intensity channel for lazy visualization of the output
  for (int i = 0; i < small_clusters->size (); ++i)
    for (int j = 0; j < (*small_clusters)[i].indices.size (); ++j)
      cloud_out->points[(*small_clusters)[i].indices[j]].intensity = -2.0;
  for (int i = 0; i < large_clusters->size (); ++i)
    for (int j = 0; j < (*large_clusters)[i].indices.size (); ++j)
      cloud_out->points[(*large_clusters)[i].indices[j]].intensity = +10.0;
  for (int i = 0; i < clusters->size (); ++i)
  {
    int label = rand () % 8;
    for (int j = 0; j < (*clusters)[i].indices.size (); ++j)
      cloud_out->points[(*clusters)[i].indices[j]].intensity = label;
  }

  // Save the output point cloud

  pcl::io::savePCDFile ("output.pcd", *cloud_out);


  return (0);
}



/*
bool
enforceIntensitySimilarity (const pcl::PointXYZINormal& point_a, const pcl::PointXYZINormal& point_b, float squared_distance)
{
  if (std::abs (point_a.intensity - point_b.intensity) < 5.0f)
    return (true);
  else
    return (false);
}

bool
enforceCurvatureOrIntensitySimilarity (const pcl::PointXYZINormal& point_a, const pcl::PointXYZINormal& point_b, float squared_distance)
{
  Eigen::Map<const Eigen::Vector3f> point_a_normal = point_a.getNormalVector3fMap (), point_b_normal = point_b.getNormalVector3fMap ();
  if (std::abs (point_a.intensity - point_b.intensity) < 5.0f)
    return (true);
  if (std::abs (point_a_normal.dot (point_b_normal)) < 0.05)
    return (true);
  return (false);
}

*/
PreviousEuclidean-PCL-Python (0%)NextDBSCAN-PCL-Python (0%)

Last updated 5 years ago

Was this helpful?