Pass Through Filter๋กœ ROI ์ •ํ•˜๊ธฐ

์ „์ฒด ์ฝ”๋“œ

#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>

using namespace std;

int main(int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);

  // ๊ฐ’ ๋Œ€์ž…
  cloud->width = 5;
  cloud->height = 1;
  cloud->points.resize (cloud->width * cloud->height);

  for (auto& point: *cloud)
  {
    point.x = 1024 * rand() / (RAND_MAX + 1.0f);
    point.y = 1024 * rand() / (RAND_MAX + 1.0f);
    point.z = 1024 * rand() / (RAND_MAX + 1.0f);
  }

  // Create filtering object
  pcl::PassThrough<pcl::PointXYZ> pass;
  pass.setInputCloud(cloud);
  pass.setFilterFieldName("z");
  pass.setFilterLimits(0, 9); // min, max
  pass.setFilterLimitsNegative();
  pass.filter(*cloud_filtered);
  
  return 0;
}

Reference

Leave a comment