Skip to content

Commit 2d14ee9

Browse files
authored
Merge pull request #5062 from mvieth/revert-2562
Revert "Implement `SampleConsensusModelSphere<PointT>::projectPoints`…
2 parents 6019dd2 + 325dc4e commit 2d14ee9

File tree

2 files changed

+8
-112
lines changed

2 files changed

+8
-112
lines changed

sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp

Lines changed: 8 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -366,84 +366,24 @@ pcl::SampleConsensusModelSphere<PointT>::optimizeModelCoefficients (
366366
//////////////////////////////////////////////////////////////////////////
367367
template <typename PointT> void
368368
pcl::SampleConsensusModelSphere<PointT>::projectPoints (
369-
const Indices &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields) const
369+
const Indices &, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool) const
370370
{
371-
// Needs a valid set of model coefficients
371+
// Needs a valid model coefficients
372372
if (!isModelValid (model_coefficients))
373373
{
374374
PCL_ERROR ("[pcl::SampleConsensusModelSphere::projectPoints] Given model is invalid!\n");
375375
return;
376376
}
377377

378+
// Allocate enough space and copy the basics
379+
projected_points.resize (input_->size ());
378380
projected_points.header = input_->header;
381+
projected_points.width = input_->width;
382+
projected_points.height = input_->height;
379383
projected_points.is_dense = input_->is_dense;
380384

381-
// C : sphere center
382-
const Eigen::Vector3d C (model_coefficients[0], model_coefficients[1], model_coefficients[2]);
383-
// r : radius
384-
const double r = model_coefficients[3];
385-
386-
// Copy all the data fields from the input cloud to the projected one?
387-
if (copy_data_fields)
388-
{
389-
// Allocate enough space and copy the basics
390-
projected_points.resize (input_->size ());
391-
projected_points.width = input_->width;
392-
projected_points.height = input_->height;
393-
394-
using FieldList = typename pcl::traits::fieldList<PointT>::type;
395-
// Iterate over each point
396-
for (std::size_t i = 0; i < projected_points.points.size (); ++i)
397-
// Iterate over each dimension
398-
pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[i], projected_points.points[i]));
399-
400-
// Iterate through the 3d points and calculate the distances from them to the sphere
401-
for (std::size_t i = 0; i < inliers.size (); ++i)
402-
{
403-
// what i have:
404-
// P : Sample Point
405-
const Eigen::Vector3d P (input_->points[inliers[i]].x, input_->points[inliers[i]].y, input_->points[inliers[i]].z);
406-
407-
const Eigen::Vector3d direction = (P - C).normalized();
408-
409-
// K : Point on Sphere
410-
const Eigen::Vector3d K = C + r * direction;
411-
412-
projected_points.points[inliers[i]].x = static_cast<float> (K[0]);
413-
projected_points.points[inliers[i]].y = static_cast<float> (K[1]);
414-
projected_points.points[inliers[i]].z = static_cast<float> (K[2]);
415-
}
416-
}
417-
else
418-
{
419-
// Allocate enough space and copy the basics
420-
projected_points.resize (inliers.size ());
421-
projected_points.width = static_cast<uint32_t> (inliers.size ());
422-
projected_points.height = 1;
423-
424-
using FieldList = typename pcl::traits::fieldList<PointT>::type;
425-
// Iterate over each point
426-
for (std::size_t i = 0; i < inliers.size (); ++i)
427-
// Iterate over each dimension
428-
pcl::for_each_type <FieldList> (NdConcatenateFunctor <PointT, PointT> (input_->points[inliers[i]], projected_points.points[i]));
429-
430-
// Iterate through the 3d points and calculate the distances from them to the plane
431-
for (std::size_t i = 0; i < inliers.size (); ++i)
432-
{
433-
// what i have:
434-
// P : Sample Point
435-
const Eigen::Vector3d P (input_->points[inliers[i]].x, input_->points[inliers[i]].y, input_->points[inliers[i]].z);
436-
437-
const Eigen::Vector3d direction = (P - C).normalized();
438-
439-
// K : Point on Sphere
440-
const Eigen::Vector3d K = C + r * direction;
441-
442-
projected_points.points[i].x = static_cast<float> (K[0]);
443-
projected_points.points[i].y = static_cast<float> (K[1]);
444-
projected_points.points[i].z = static_cast<float> (K[2]);
445-
}
446-
}
385+
PCL_WARN ("[pcl::SampleConsensusModelSphere::projectPoints] Not implemented yet.\n");
386+
projected_points.points = input_->points;
447387
}
448388

449389
//////////////////////////////////////////////////////////////////////////

test/sample_consensus/test_sample_consensus_quadric_models.cpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -651,50 +651,6 @@ TEST (SampleConsensusModelCircle3D, RANSAC)
651651
EXPECT_NEAR ( 0.0, coeff_refined[6], 1e-3);
652652
}
653653

654-
TEST (SampleConsensusModelSphere, projectPoints)
655-
{
656-
Eigen::VectorXf model_coefficients(4);
657-
model_coefficients << -0.32, -0.89, 0.37, 0.12; // center and radius
658-
659-
pcl::PointCloud<pcl::PointXYZ>::Ptr input(new pcl::PointCloud<pcl::PointXYZ>);
660-
input->emplace_back(-0.259754, -0.950873, 0.318377); // inlier, dist from center=0.10
661-
input->emplace_back( 0.595892, 0.455094, 0.025545); // outlier, not projected
662-
input->emplace_back(-0.221871, -0.973718, 0.353817); // inlier, dist from center=0.13
663-
input->emplace_back(-0.332269, -0.848851, 0.437499); // inlier, dist from center=0.08
664-
input->emplace_back(-0.242308, -0.561036, -0.365535); // outlier, not projected
665-
input->emplace_back(-0.327668, -0.800009, 0.290988); // inlier, dist from center=0.12
666-
input->emplace_back(-0.173948, -0.883831, 0.403625); // inlier, dist from center=0.15
667-
input->emplace_back(-0.033891, 0.624537, -0.606994); // outlier, not projected
668-
669-
pcl::SampleConsensusModelSphere<pcl::PointXYZ> model(input);
670-
pcl::Indices inliers = {0, 2, 3, 5, 6};
671-
672-
pcl::PointCloud<pcl::PointXYZ> projected_truth;
673-
projected_truth.emplace_back(-0.247705, -0.963048, 0.308053);
674-
projected_truth.emplace_back(-0.229419, -0.967278, 0.355062);
675-
projected_truth.emplace_back(-0.338404, -0.828276, 0.471249);
676-
projected_truth.emplace_back(-0.327668, -0.800009, 0.290988);
677-
projected_truth.emplace_back(-0.203158, -0.885065, 0.396900);
678-
679-
pcl::PointCloud<pcl::PointXYZ> projected_points;
680-
model.projectPoints(inliers, model_coefficients, projected_points, false);
681-
EXPECT_EQ(projected_points.size(), 5);
682-
for(int i=0; i<5; ++i)
683-
EXPECT_XYZ_NEAR(projected_points[i], projected_truth[i], 1e-5);
684-
685-
pcl::PointCloud<pcl::PointXYZ> projected_points_all;
686-
model.projectPoints(inliers, model_coefficients, projected_points_all, true);
687-
EXPECT_EQ(projected_points_all.size(), 8);
688-
EXPECT_XYZ_NEAR(projected_points_all[0], projected_truth[0], 1e-5);
689-
EXPECT_XYZ_NEAR(projected_points_all[1], (*input)[1], 1e-5);
690-
EXPECT_XYZ_NEAR(projected_points_all[2], projected_truth[1], 1e-5);
691-
EXPECT_XYZ_NEAR(projected_points_all[3], projected_truth[2], 1e-5);
692-
EXPECT_XYZ_NEAR(projected_points_all[4], (*input)[4], 1e-5);
693-
EXPECT_XYZ_NEAR(projected_points_all[5], projected_truth[3], 1e-5);
694-
EXPECT_XYZ_NEAR(projected_points_all[6], projected_truth[4], 1e-5);
695-
EXPECT_XYZ_NEAR(projected_points_all[7], (*input)[7], 1e-5);
696-
}
697-
698654
TEST (SampleConsensusModelCylinder, projectPoints)
699655
{
700656
Eigen::VectorXf model_coefficients(7);

0 commit comments

Comments
 (0)