PCL-Cpp (70%)
1. PassThrough
์ฝ๋๋ [์ด๊ณณ]์์ ๋ค์ด๋ก๋ ๊ฐ๋ฅํฉ๋๋ค. ์ํํ์ผ์ [tabletop.pcd]์ ์ฌ์ฉํ์์ต๋๋ค.
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
//Filtering a PointCloud using a PassThrough filter
//http://pointclouds.org/documentation/tutorials/passthrough.php#passthrough
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZRGB>);
// *.PCD ํ์ผ ์ฝ๊ธฐ (https://raw.githubusercontent.com/adioshun/gitBook_Tutorial_PCL/master/Beginner/sample/tabletop.pcd)
pcl::io::loadPCDFile<pcl::PointXYZRGB> ("tabletop.pcd", *cloud);
// ํฌ์ธํธ์ ์ถ๋ ฅ
std::cout << "Loaded :" << cloud->width * cloud->height << std::endl;
// ์ค๋ธ์ ํธ ์์ฑ
pcl::PassThrough<pcl::PointXYZRGB> pass;
pass.setInputCloud (cloud); //์
๋ ฅ
pass.setFilterFieldName ("z"); //์ ์ฉํ ์ขํ ์ถ (eg. Z์ถ)
pass.setFilterLimits (0.70, 1.5); //์ ์ฉํ ๊ฐ (์ต์, ์ต๋ ๊ฐ)
//pass.setFilterLimitsNegative (true); //์ ์ฉํ ๊ฐ ์ธ
pass.filter (*cloud_filtered); //ํํฐ ์ ์ฉ
// ํฌ์ธํธ์ ์ถ๋ ฅ
std::cout << "Filtered :" << cloud_filtered->width * cloud_filtered->height << std::endl;
// ์ ์ฅ
pcl::io::savePCDFile<pcl::PointXYZRGB>("tabletop_passthrough.pcd", *cloud_filtered); //Default binary mode save
return (0);
}
์คํ & ๊ฒฐ๊ณผ
$ Loaded :202627
$ Filtered :72823
์๊ฐํ & ๊ฒฐ๊ณผ
$ pcl_viewer tabletop.pcd
$ pcl_viewer tabletop_passthrough.pcd
์๋ณธ
๊ฒฐ๊ณผ
๊ฒฐ๊ณผ(Negative)
2. Conditional Outlier removal
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/conditional_removal.h>
//Removing outliers using a Conditional or RadiusOutlier removal
//http://pointclouds.org/documentation/tutorials/remove_outliers.php#remove-outliers
int
main (int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZRGB>);
// *.PCD ํ์ผ ์ฝ๊ธฐ (https://raw.githubusercontent.com/adioshun/gitBook_Tutorial_PCL/master/Beginner/sample/tabletop.pcd)
pcl::io::loadPCDFile<pcl::PointXYZRGB> ("tabletop.pcd", *cloud);
// ํฌ์ธํธ์ ์ถ๋ ฅ
std::cout << "Loaded " << cloud->width * cloud->height << std::endl;
// ์กฐ๊ฑด ์ ์
pcl::ConditionAnd<pcl::PointXYZRGB>::Ptr range_cond (new pcl::ConditionAnd<pcl::PointXYZRGB> ());
range_cond->addComparison (pcl::FieldComparison<pcl::PointXYZRGB>::ConstPtr (new //์กฐ๊ฑด 1
pcl::FieldComparison<pcl::PointXYZRGB> ("z", pcl::ComparisonOps::GT, 0.0))); //eg. z์ถ์ผ๋ก 0.00๋ณด๋ค ํฐ๊ฐ(GT:Greater Than)
range_cond->addComparison (pcl::FieldComparison<pcl::PointXYZRGB>::ConstPtr (new //์กฐ๊ฑด 2
pcl::FieldComparison<pcl::PointXYZRGB> ("z", pcl::ComparisonOps::LT, 0.8))); //eg. z์ถ์ผ๋ก 0.08๋ณด๋ค ์์๊ฐ(LT:Less Than)
//์คํ์ ํธ ์์ฑ
pcl::ConditionalRemoval<pcl::PointXYZRGB> condrem;
condrem.setInputCloud (cloud); //์
๋ ฅ
condrem.setCondition (range_cond); //์กฐ๊ฑด ์ค์
condrem.setKeepOrganized(true); //
condrem.filter (*cloud_filtered); //ํํฐ ์ ์ฉ
// ํฌ์ธํธ์ ์ถ๋ ฅ
std::cout << "Filtered " << cloud_filtered->width * cloud_filtered->height << std::endl;
// ์ ์ฅ
pcl::io::savePCDFile<pcl::PointXYZRGB>("tabletop_conditional.pcd", *cloud_filtered); //Default binary mode save
return (0);
}
์๋ณธ
๊ฒฐ๊ณผ
Last updated