| 11 | {} |
| 12 | |
| 13 | QList<pcl::cloud_composer::CloudComposerItem*> |
| 14 | pcl::cloud_composer::NormalEstimationTool::performAction(ConstItemList input_data, |
| 15 | PointTypeFlags::PointType) |
| 16 | { |
| 17 | QList<CloudComposerItem*> output; |
| 18 | const CloudComposerItem* input_item; |
| 19 | // Check input data length |
| 20 | if (input_data.empty()) { |
| 21 | qCritical() << "Empty input in Normal Estimation Tool!"; |
| 22 | return output; |
| 23 | } |
| 24 | if (input_data.size() > 1) { |
| 25 | qWarning() << "Input vector has more than one item in Normal Estimation!"; |
| 26 | } |
| 27 | input_item = input_data.value(0); |
| 28 | |
| 29 | pcl::PCLPointCloud2::ConstPtr input_cloud; |
| 30 | if (input_item->type() == CloudComposerItem::CLOUD_ITEM) { |
| 31 | double radius = parameter_model_->getProperty("Radius").toDouble(); |
| 32 | qDebug() << "Received Radius = " << radius; |
| 33 | pcl::PCLPointCloud2::ConstPtr input_cloud = |
| 34 | input_item->data(ItemDataRole::CLOUD_BLOB) |
| 35 | .value<pcl::PCLPointCloud2::ConstPtr>(); |
| 36 | qDebug() << "Got cloud size = " << input_cloud->width; |
| 37 | //////////////// THE WORK - COMPUTING NORMALS /////////////////// |
| 38 | pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); |
| 39 | pcl::fromPCLPointCloud2(*input_cloud, *cloud); |
| 40 | // Create the normal estimation class, and pass the input dataset to it |
| 41 | pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne; |
| 42 | ne.setInputCloud(cloud); |
| 43 | |
| 44 | // Create an empty kdtree representation, and pass it to the normal estimation |
| 45 | // object. Its content will be filled inside the object, based on the given input |
| 46 | // dataset (as no other search surface is given). |
| 47 | pcl::search::KdTree<pcl::PointXYZ>::Ptr tree( |
| 48 | new pcl::search::KdTree<pcl::PointXYZ>()); |
| 49 | ne.setSearchMethod(tree); |
| 50 | |
| 51 | // Output datasets |
| 52 | pcl::PointCloud<pcl::Normal>::Ptr cloud_normals(new pcl::PointCloud<pcl::Normal>); |
| 53 | |
| 54 | // Use all neighbors in a sphere of radius 3cm |
| 55 | ne.setRadiusSearch(radius); |
| 56 | |
| 57 | // Compute the features |
| 58 | ne.compute(*cloud_normals); |
| 59 | ////////////////////////////////////////////////////////////////// |
| 60 | NormalsItem* normals_item = |
| 61 | new NormalsItem(tr("Normals r=%1").arg(radius), cloud_normals, radius); |
| 62 | output.append(normals_item); |
| 63 | qDebug() << "Calced normals"; |
| 64 | } |
| 65 | else { |
| 66 | qDebug() << "Input item in Normal Estimation is not a cloud!!!"; |
| 67 | } |
| 68 | |
| 69 | return output; |
| 70 | } |
nothing calls this directly
no test coverage detected