Go to the documentation of this file.00001 #include <pcl/apps/cloud_composer/tools/normal_estimation.h>
00002 #include <pcl/apps/cloud_composer/items/normals_item.h>
00003
00004 #include <pcl/features/normal_3d.h>
00005 #include <pcl/point_types.h>
00006
00007
00008 Q_EXPORT_PLUGIN2(cloud_composer_normal_estimation_tool, pcl::cloud_composer::NormalEstimationToolFactory)
00009
00010
00011 pcl::cloud_composer::NormalEstimationTool::NormalEstimationTool (PropertiesModel* parameter_model, QObject* parent)
00012 : NewItemTool (parameter_model, parent)
00013 {
00014
00015
00016 }
00017
00018 pcl::cloud_composer::NormalEstimationTool::~NormalEstimationTool ()
00019 {
00020
00021 }
00022
00023 QList <pcl::cloud_composer::CloudComposerItem*>
00024 pcl::cloud_composer::NormalEstimationTool::performAction (ConstItemList input_data, PointTypeFlags::PointType type)
00025 {
00026 QList <CloudComposerItem*> output;
00027 const CloudComposerItem* input_item;
00028
00029 if ( input_data.size () == 0)
00030 {
00031 qCritical () << "Empty input in Normal Estimation Tool!";
00032 return output;
00033 }
00034 else if ( input_data.size () > 1)
00035 {
00036 qWarning () << "Input vector has more than one item in Normal Estimation!";
00037 }
00038 input_item = input_data.value (0);
00039
00040 pcl::PCLPointCloud2::ConstPtr input_cloud;
00041 if (input_item->type () == CloudComposerItem::CLOUD_ITEM)
00042 {
00043 double radius = parameter_model_->getProperty("Radius").toDouble();
00044 qDebug () << "Received Radius = " <<radius;
00045 pcl::PCLPointCloud2::ConstPtr input_cloud = input_item->data (ItemDataRole::CLOUD_BLOB).value <pcl::PCLPointCloud2::ConstPtr> ();
00046 qDebug () << "Got cloud size = "<<input_cloud->width;
00048 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
00049 pcl::fromPCLPointCloud2 (*input_cloud, *cloud);
00050
00051 pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
00052 ne.setInputCloud (cloud);
00053
00054
00055
00056 pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
00057 ne.setSearchMethod (tree);
00058
00059
00060 pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);
00061
00062
00063 ne.setRadiusSearch (radius);
00064
00065
00066 ne.compute (*cloud_normals);
00068 NormalsItem* normals_item = new NormalsItem (tr("Normals r=%1").arg(radius),cloud_normals,radius);
00069 output.append (normals_item);
00070 qDebug () << "Calced normals";
00071 }
00072 else
00073 {
00074 qDebug () << "Input item in Normal Estimation is not a cloud!!!";
00075 }
00076
00077
00078 return output;
00079 }
00080
00082 pcl::cloud_composer::PropertiesModel*
00083 pcl::cloud_composer::NormalEstimationToolFactory::createToolParameterModel (QObject* parent)
00084 {
00085 PropertiesModel* parameter_model = new PropertiesModel(parent);
00086
00087 parameter_model->addProperty ("Radius", 0.04, Qt::ItemIsEditable | Qt::ItemIsEnabled);
00088
00089 return parameter_model;
00090 }