本文整理汇总了C++中Filter::ExtractionObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::ExtractionObject方法的具体用法?C++ Filter::ExtractionObject怎么用?C++ Filter::ExtractionObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::ExtractionObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char** argv)
{
// Initialize ROS
ros::init (argc, argv, "objectMaster");
ros::NodeHandle n;
ros::Rate waiting_rate(30);
//strat a traver and wait for its ready
cloudTraver ct(n);
while(!ct.isReady())
{
ros::spinOnce();
waiting_rate.sleep();
}
cvNamedWindow("CurrentImage",CV_WINDOW_AUTOSIZE);
cv::Mat image;
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloudP;
Mat src, dst, color_dst;
std::string objectNameTemp="TEMP";
int count=0;
while(ros::ok())
{
while(!ct.isReady())
{
ros::spinOnce();
}
image=ct.getImage();
cloudP=ct.getCloud();
if(cloudP->empty())
{
std::cout<<"No pointCloud passed into this process, fuck you no points you play MAOXIAN!"<<std::endl;
continue;
}
pcl::PointCloud<PointType>::Ptr cloud_RGBA(new pcl::PointCloud<PointType>);
*cloud_RGBA=*cloudP;
Filter filter;
cloud_RGBA=filter.PassThrough(cloud_RGBA);
cloud_RGBA=filter.DeSamping(cloud_RGBA);
cloud_RGBA=filter.RemovePlane(cloud_RGBA);
if(cloud_RGBA->empty())
{
std::cout<<"No pointCloud left after the samping"<<std::endl;
continue;
}
std::vector<pcl::PointIndices> cluster_indices;
filter.ExtractionObject(cloud_RGBA,cluster_indices);
if(cluster_indices.size()!=0)
{
std::cout<<cluster_indices.size()<<"clusters extraced"<<std::endl;
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_f (new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud = cloud_RGBA;
//voxelgrid并不是产生球面空洞的原因
pcl::VoxelGrid<pcl::PointXYZRGBA> vg;
vg.setInputCloud (cloud);
vg.setLeafSize (0.01f, 0.01f, 0.01f);
vg.filter (*cloud_filtered);
//Create the segmentation object for the planar model and set all the parameters
pcl::SACSegmentation<pcl::PointXYZRGBA> seg;
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_plane (new pcl::PointCloud<pcl::PointXYZRGBA> ());
pcl::PCDWriter writer;
seg.setOptimizeCoefficients (true);
seg.setModelType (pcl::SACMODEL_PLANE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setMaxIterations (100);
seg.setDistanceThreshold (0.02);
//.........
int i=0, nr_points = (int) cloud_filtered->points.size ();
while (cloud_filtered->points.size () > 0.3 * nr_points)
{
// Segment the largest planar component from the remaining cloud
seg.setInputCloud (cloud_filtered);
seg.segment (*inliers, *coefficients);
if (inliers->indices.size () == 0)
{
std::cout << "Could not estimate a planar model for the given dataset." << std::endl;
break;
}
// Extract the planar inliers from the input cloud
pcl::ExtractIndices<pcl::PointXYZRGBA> extract;
extract.setInputCloud (cloud_filtered);
extract.setIndices (inliers);
extract.setNegative (false);
// Get the points associated with the planar surface
extract.filter (*cloud_plane);
//std::cout << "PointCloud representing the planar component: " << cloud_plane->points.size () << " data points." << std::endl;
// Remove the planar inliers, extract the rest
//.........这里部分代码省略.........