statistical_outlier_removal.cpp
Go to the documentation of this file.
00001 #include <pcl/apps/cloud_composer/tools/statistical_outlier_removal.h>
00002 #include <pcl/apps/cloud_composer/items/cloud_item.h>
00003 
00004 #include <pcl/filters/statistical_outlier_removal.h>
00005 #include <pcl/point_types.h>
00006 
00007 
00008 Q_EXPORT_PLUGIN2(cloud_composer_statistical_outlier_removal_tool, pcl::cloud_composer::StatisticalOutlierRemovalToolFactory)
00009 
00010 
00011 pcl::cloud_composer::StatisticalOutlierRemovalTool::StatisticalOutlierRemovalTool (PropertiesModel* parameter_model, QObject* parent)
00012   : ModifyItemTool (parameter_model, parent)
00013 {
00014 
00015   
00016 }
00017 
00018 pcl::cloud_composer::StatisticalOutlierRemovalTool::~StatisticalOutlierRemovalTool ()
00019 {
00020   
00021 }
00022 
00023 QList <pcl::cloud_composer::CloudComposerItem*>
00024 pcl::cloud_composer::StatisticalOutlierRemovalTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type)
00025 {
00026   QList <CloudComposerItem*> output;
00027   const CloudComposerItem* input_item;
00028   // Check input data length
00029   if ( input_data.size () == 0)
00030   {
00031     qCritical () << "Empty input in StatisticalOutlierRemovalTool!";
00032     return output;
00033   }
00034   else if ( input_data.size () > 1)
00035   {
00036     qWarning () << "Input vector has more than one item in StatisticalOutlierRemovalTool";
00037   }
00038   input_item = input_data.value (0);
00039   if ( !input_item->isSanitized () )
00040   {
00041     qCritical () << "StatisticalOutlierRemovalTool requires sanitized input!";
00042     return output;
00043   }
00044   
00045   if (input_item->type () ==  CloudComposerItem::CLOUD_ITEM )
00046   {
00047     pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value <pcl::PCLPointCloud2::ConstPtr> ();
00048     
00049     int mean_k = parameter_model_->getProperty("Mean K").toInt ();
00050     double std_dev_thresh = parameter_model_->getProperty ("Std Dev Thresh").toDouble ();
00051     
00053     // Create the filtering object
00054     pcl::StatisticalOutlierRemoval<pcl::PCLPointCloud2> sor;
00055     sor.setInputCloud (input_cloud);
00056     sor.setMeanK (mean_k);
00057     sor.setStddevMulThresh (std_dev_thresh);
00058     
00059     //Create output cloud
00060     pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2);
00061     //Filter!  
00062     sor.filter (*cloud_filtered);
00063 
00065     //Get copies of the original origin and orientation
00066     Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value<Eigen::Vector4f> ();
00067     Eigen::Quaternionf source_orientation =  input_item->data (ItemDataRole::ORIENTATION).value<Eigen::Quaternionf> ();
00068     //Put the modified cloud into an item, stick in output
00069     CloudItem* cloud_item = new CloudItem (input_item->text () + tr (" sor filtered")
00070                                            , cloud_filtered
00071                                            , source_origin
00072                                            , source_orientation);
00073 
00074     
00075     output.append (cloud_item);
00076   }
00077   else
00078   {
00079     qDebug () << "Input item in StatisticalOutlierRemovalTool is not a cloud!!!";
00080   }
00081   
00082   
00083   return output;
00084 }
00085 
00087 pcl::cloud_composer::PropertiesModel*
00088 pcl::cloud_composer::StatisticalOutlierRemovalToolFactory::createToolParameterModel (QObject* parent)
00089 {
00090   PropertiesModel* parameter_model = new PropertiesModel(parent);
00091   
00092   parameter_model->addProperty ("Mean K", 50,  Qt::ItemIsEditable | Qt::ItemIsEnabled);
00093   parameter_model->addProperty ("Std Dev Thresh", 1.0,  Qt::ItemIsEditable | Qt::ItemIsEnabled);
00094   
00095   return parameter_model;
00096 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:33:44