Go to the documentation of this file.00001 #include <pcl/apps/cloud_composer/tools/fpfh_estimation.h>
00002 #include <pcl/apps/cloud_composer/items/cloud_item.h>
00003 #include <pcl/apps/cloud_composer/items/normals_item.h>
00004 #include <pcl/apps/cloud_composer/items/fpfh_item.h>
00005
00006 #include <pcl/features/fpfh.h>
00007 #include <pcl/point_types.h>
00008 #include <pcl/filters/filter.h>
00009
00010
00011
00012 Q_EXPORT_PLUGIN2(cloud_composer_fpfh_estimation_tool, pcl::cloud_composer::FPFHEstimationToolFactory)
00013
00014
00015 pcl::cloud_composer::FPFHEstimationTool::FPFHEstimationTool (PropertiesModel* parameter_model, QObject* parent)
00016 : NewItemTool (parameter_model, parent)
00017 {
00018
00019
00020 }
00021
00022 pcl::cloud_composer::FPFHEstimationTool::~FPFHEstimationTool ()
00023 {
00024
00025 }
00026
00027 QList <pcl::cloud_composer::CloudComposerItem*>
00028 pcl::cloud_composer::FPFHEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type)
00029 {
00030 QList <CloudComposerItem*> output;
00031 const CloudComposerItem* input_item;
00032
00033 if ( input_data.size () == 0)
00034 {
00035 qCritical () << "Empty input in FPFH Estimation Tool!";
00036 return output;
00037 }
00038 else if ( input_data.size () > 1)
00039 {
00040 qWarning () << "Input vector has more than one item in FPFH Estimation!";
00041 }
00042 input_item = input_data.value (0);
00043
00044
00045 if (input_item->type () == CloudComposerItem::CLOUD_ITEM)
00046 {
00047
00048 QList <CloudComposerItem*> normals_list = input_item->getChildren (CloudComposerItem::NORMALS_ITEM);
00049 if ( normals_list.size () == 0 )
00050 {
00051 qCritical () << "No normals item child found in this cloud item";
00052 return output;
00053 }
00054 qDebug () << "Found item text="<<normals_list.at(0)->text();
00055
00056 double radius = parameter_model_->getProperty("Radius").toDouble();
00057
00058 pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value <pcl::PCLPointCloud2::ConstPtr> ();
00059
00060 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
00061 pcl::fromPCLPointCloud2 (*input_cloud, *cloud);
00062
00063
00064 pcl::PointCloud<pcl::Normal>::ConstPtr input_normals = normals_list.value(0)->data(ItemDataRole::CLOUD_TEMPLATED).value <pcl::PointCloud<pcl::Normal>::ConstPtr> ();
00065
00066 pcl::FPFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::FPFHSignature33> fpfh;
00067
00068
00070
00071 fpfh.setInputCloud (cloud);
00072 fpfh.setInputNormals (input_normals);
00073
00074
00075
00076 qDebug () << "Building KD Tree";
00077 pcl::search::KdTree<PointXYZ>::Ptr tree (new pcl::search::KdTree<PointXYZ>);
00078 fpfh.setSearchMethod (tree);
00079
00080
00081 pcl::PointCloud<pcl::FPFHSignature33>::Ptr fpfhs (new pcl::PointCloud<pcl::FPFHSignature33> ());
00082
00083
00084
00085 fpfh.setRadiusSearch (radius);
00086
00087
00088 qDebug () << "Computing FPFH features";
00089 fpfh.compute (*fpfhs);
00090 qDebug () << "Size of computed features ="<<fpfhs->width;
00092 FPFHItem* fpfh_item = new FPFHItem (tr("FPFH r=%1").arg(radius),fpfhs,radius);
00093 output.append (fpfh_item);
00094 }
00095 else
00096 {
00097 qCritical () << "Input item in FPFH Estimation is not a cloud!!!";
00098 }
00099
00100
00101 return output;
00102 }
00103
00105 pcl::cloud_composer::PropertiesModel*
00106 pcl::cloud_composer::FPFHEstimationToolFactory::createToolParameterModel (QObject* parent)
00107 {
00108 PropertiesModel* parameter_model = new PropertiesModel(parent);
00109
00110 parameter_model->addProperty ("Radius", 0.03, Qt::ItemIsEditable | Qt::ItemIsEnabled);
00111
00112 return parameter_model;
00113 }