From d3ea2afb629da529bf8944e65c668c85a993b3b0 Mon Sep 17 00:00:00 2001 From: ralphieraccoon Date: Wed, 20 Nov 2024 20:35:29 +0000 Subject: [PATCH 1/2] Changed segmentation collinear check precision from float to double. --- .../pcl/sample_consensus/impl/sac_model_circle3d.hpp | 4 ++-- .../pcl/sample_consensus/impl/sac_model_cone.hpp | 2 +- .../pcl/sample_consensus/impl/sac_model_ellipse3d.hpp | 4 ++-- .../pcl/sample_consensus/impl/sac_model_plane.hpp | 4 ++-- .../pcl/sample_consensus/impl/sac_model_torus.hpp | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle3d.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle3d.hpp index f5e691ee2ca..8fd9458a26b 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle3d.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle3d.hpp @@ -65,7 +65,7 @@ pcl::SampleConsensusModelCircle3D::isSampleGood ( // Check if the squared norm of the cross-product is non-zero, otherwise // common_helper_vec, which plays an important role in computeModelCoefficients, // would likely be ill-formed. - if ((p1 - p0).cross(p1 - p2).squaredNorm() < Eigen::NumTraits::dummy_precision ()) + if ((p1 - p0).cross(p1 - p2).squaredNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::isSampleGood] Sample points too similar or collinear!\n"); return (false); @@ -102,7 +102,7 @@ pcl::SampleConsensusModelCircle3D::computeModelCoefficients (const Indic // The same check is implemented in isSampleGood, so be sure to look there too // if you find the need to change something here. - if (common_helper_vec.squaredNorm() < Eigen::NumTraits::dummy_precision ()) + if (common_helper_vec.squaredNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelCircle3D::computeModelCoefficients] Sample points too similar or collinear!\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp index c3d3cd835e9..5895a927d15 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp @@ -87,7 +87,7 @@ pcl::SampleConsensusModelCone::computeModelCoefficients ( Eigen::Vector4f ortho31 = n3.cross3(n1); float denominator = n1.dot(ortho23); - if (std::abs(denominator) < Eigen::NumTraits::dummy_precision ()) + if (std::abs(denominator) < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelCone::computeModelCoefficients] Impossible to compute stable model with these points.\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp index 33740e44904..af3110df2b2 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp @@ -38,7 +38,7 @@ pcl::SampleConsensusModelEllipse3D::isSampleGood ( // Check if the squared norm of the cross-product is non-zero, otherwise // common_helper_vec, which plays an important role in computeModelCoefficients, // would likely be ill-formed. - if ((p1 - p0).cross(p1 - p2).squaredNorm() < Eigen::NumTraits::dummy_precision ()) + if ((p1 - p0).cross(p1 - p2).squaredNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelEllipse3D::isSampleGood] Sample points too similar or collinear!\n"); return (false); @@ -72,7 +72,7 @@ pcl::SampleConsensusModelEllipse3D::computeModelCoefficients (const Indi // The same check is implemented in isSampleGood, so be sure to look there too // if you find the need to change something here. - if (common_helper_vec.squaredNorm() < Eigen::NumTraits::dummy_precision ()) + if (common_helper_vec.squaredNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelEllipse3D::computeModelCoefficients] Sample points too similar or collinear!\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp index be51ff89bae..460a2d9865a 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp @@ -67,7 +67,7 @@ pcl::SampleConsensusModelPlane::isSampleGood (const Indices &samples) co // normalization will fail. One could also interpret this as kind of check // if the triangle spanned by those three points would have an area greater // than zero. - if ((p1 - p0).cross(p2 - p0).stableNorm() < Eigen::NumTraits::dummy_precision ()) + if ((p1 - p0).cross(p2 - p0).stableNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelPlane::isSampleGood] Sample points too similar or collinear!\n"); return (false); @@ -98,7 +98,7 @@ pcl::SampleConsensusModelPlane::computeModelCoefficients ( const float crossNorm = cross.stableNorm(); // Checking for collinearity here - if (crossNorm < Eigen::NumTraits::dummy_precision ()) + if (crossNorm < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelPlane::computeModelCoefficients] Chosen samples are collinear!\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp index dd9e7699c4d..aed07172464 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp @@ -68,15 +68,15 @@ pcl::SampleConsensusModelTorus::isSampleGood( // Required for numeric stability on computeModelCoefficients if (std::abs((n0).cross(n1).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n0).cross(n2).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n0).cross(n3).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n1).cross(n2).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n1).cross(n3).squaredNorm()) < - Eigen::NumTraits::dummy_precision()) { + Eigen::NumTraits::dummy_precision()) { PCL_ERROR("[pcl::SampleConsensusModelEllipse3D::isSampleGood] Sample points " "normals too similar or collinear!\n"); return (false); From 3181dd22ecf5dda7b9930af0a6b19eee8e75f01a Mon Sep 17 00:00:00 2001 From: ralphieraccoon Date: Thu, 21 Nov 2024 13:44:20 +0000 Subject: [PATCH 2/2] Reverted change for cone, ellipse3d, plane and torus. --- .../pcl/sample_consensus/impl/sac_model_cone.hpp | 2 +- .../pcl/sample_consensus/impl/sac_model_ellipse3d.hpp | 4 ++-- .../pcl/sample_consensus/impl/sac_model_plane.hpp | 4 ++-- .../pcl/sample_consensus/impl/sac_model_torus.hpp | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp index 5895a927d15..c3d3cd835e9 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cone.hpp @@ -87,7 +87,7 @@ pcl::SampleConsensusModelCone::computeModelCoefficients ( Eigen::Vector4f ortho31 = n3.cross3(n1); float denominator = n1.dot(ortho23); - if (std::abs(denominator) < Eigen::NumTraits::dummy_precision ()) + if (std::abs(denominator) < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelCone::computeModelCoefficients] Impossible to compute stable model with these points.\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp index af3110df2b2..33740e44904 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_ellipse3d.hpp @@ -38,7 +38,7 @@ pcl::SampleConsensusModelEllipse3D::isSampleGood ( // Check if the squared norm of the cross-product is non-zero, otherwise // common_helper_vec, which plays an important role in computeModelCoefficients, // would likely be ill-formed. - if ((p1 - p0).cross(p1 - p2).squaredNorm() < Eigen::NumTraits::dummy_precision ()) + if ((p1 - p0).cross(p1 - p2).squaredNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelEllipse3D::isSampleGood] Sample points too similar or collinear!\n"); return (false); @@ -72,7 +72,7 @@ pcl::SampleConsensusModelEllipse3D::computeModelCoefficients (const Indi // The same check is implemented in isSampleGood, so be sure to look there too // if you find the need to change something here. - if (common_helper_vec.squaredNorm() < Eigen::NumTraits::dummy_precision ()) + if (common_helper_vec.squaredNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelEllipse3D::computeModelCoefficients] Sample points too similar or collinear!\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp index 460a2d9865a..be51ff89bae 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_plane.hpp @@ -67,7 +67,7 @@ pcl::SampleConsensusModelPlane::isSampleGood (const Indices &samples) co // normalization will fail. One could also interpret this as kind of check // if the triangle spanned by those three points would have an area greater // than zero. - if ((p1 - p0).cross(p2 - p0).stableNorm() < Eigen::NumTraits::dummy_precision ()) + if ((p1 - p0).cross(p2 - p0).stableNorm() < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelPlane::isSampleGood] Sample points too similar or collinear!\n"); return (false); @@ -98,7 +98,7 @@ pcl::SampleConsensusModelPlane::computeModelCoefficients ( const float crossNorm = cross.stableNorm(); // Checking for collinearity here - if (crossNorm < Eigen::NumTraits::dummy_precision ()) + if (crossNorm < Eigen::NumTraits::dummy_precision ()) { PCL_ERROR ("[pcl::SampleConsensusModelPlane::computeModelCoefficients] Chosen samples are collinear!\n"); return (false); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp index aed07172464..dd9e7699c4d 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_torus.hpp @@ -68,15 +68,15 @@ pcl::SampleConsensusModelTorus::isSampleGood( // Required for numeric stability on computeModelCoefficients if (std::abs((n0).cross(n1).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n0).cross(n2).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n0).cross(n3).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n1).cross(n2).squaredNorm()) < - Eigen::NumTraits::dummy_precision() || + Eigen::NumTraits::dummy_precision() || std::abs((n1).cross(n3).squaredNorm()) < - Eigen::NumTraits::dummy_precision()) { + Eigen::NumTraits::dummy_precision()) { PCL_ERROR("[pcl::SampleConsensusModelEllipse3D::isSampleGood] Sample points " "normals too similar or collinear!\n"); return (false);