From 82a5dd8360e5e09dce6781f63ceb6eb538e3fd7d Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 9 Jul 2020 16:55:39 +0200 Subject: [PATCH 001/431] Add more prints in sample_consensus --- .../include/pcl/sample_consensus/impl/lmeds.hpp | 2 ++ .../sample_consensus/impl/sac_model_circle.hpp | 10 ++++++++++ .../sample_consensus/impl/sac_model_circle3d.hpp | 15 +++++++++++++-- .../pcl/sample_consensus/impl/sac_model_cone.hpp | 14 ++++++++++++++ .../sample_consensus/impl/sac_model_cylinder.hpp | 14 ++++++++++++++ .../pcl/sample_consensus/impl/sac_model_line.hpp | 3 +++ .../impl/sac_model_normal_parallel_plane.hpp | 7 +++++++ .../impl/sac_model_parallel_line.hpp | 1 + .../impl/sac_model_parallel_plane.hpp | 1 + .../impl/sac_model_perpendicular_plane.hpp | 2 ++ .../pcl/sample_consensus/impl/sac_model_plane.hpp | 2 ++ .../sample_consensus/impl/sac_model_sphere.hpp | 2 ++ .../pcl/sample_consensus/impl/sac_model_stick.hpp | 3 +++ 13 files changed, 74 insertions(+), 2 deletions(-) diff --git a/sample_consensus/include/pcl/sample_consensus/impl/lmeds.hpp b/sample_consensus/include/pcl/sample_consensus/impl/lmeds.hpp index 3816cdebd8f..b4b146db70e 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/lmeds.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/lmeds.hpp @@ -73,6 +73,7 @@ pcl::LeastMedianSquares::computeModel (int debug_verbosity_level) if (selection.empty ()) { + PCL_ERROR ("[pcl::LeastMedianSquares::computeModel] No samples could be selected!\n"); break; } @@ -81,6 +82,7 @@ pcl::LeastMedianSquares::computeModel (int debug_verbosity_level) { //iterations_++; ++skipped_count; + PCL_DEBUG ("[pcl::LeastMedianSquares::computeModel] The function computeModelCoefficients failed, so continue with next iteration.\n"); continue; } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp index ac25b324d8e..a81046b5dad 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp @@ -102,6 +102,8 @@ pcl::SampleConsensusModelCircle2D::computeModelCoefficients (const Indic // Radius model_coefficients[2] = static_cast (sqrt ((model_coefficients[0] - p0[0]) * (model_coefficients[0] - p0[0]) + (model_coefficients[1] - p0[1]) * (model_coefficients[1] - p0[1]))); + PCL_DEBUG ("[pcl::SampleConsensusModelCircle2D::computeModelCoefficients] Model is (%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2]); return (true); } @@ -328,9 +330,17 @@ pcl::SampleConsensusModelCircle2D::isModelValid (const Eigen::VectorXf & return (false); if (radius_min_ != -std::numeric_limits::max() && model_coefficients[2] < radius_min_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCircle2D::isModelValid] Radius of circle is too small: should be larger than %g, but is %g.\n", + radius_min_, model_coefficients[2]); return (false); + } if (radius_max_ != std::numeric_limits::max() && model_coefficients[2] > radius_max_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCircle2D::isModelValid] Radius of circle is too big: should be smaller than %g, but is %g.\n", + radius_max_, model_coefficients[2]); return (false); + } return (true); } 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 764c6f7e227..68969cf09bc 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 @@ -111,8 +111,11 @@ pcl::SampleConsensusModelCircle3D::computeModelCoefficients (const Indic model_coefficients[4] = static_cast (circle_normal[0]); model_coefficients[5] = static_cast (circle_normal[1]); model_coefficients[6] = static_cast (circle_normal[2]); - - return (true); + + PCL_DEBUG ("[pcl::SampleConsensusModelCircle3D::computeModelCoefficients] Model is (%g,%g,%g,%g,%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], model_coefficients[3], + model_coefficients[4], model_coefficients[5], model_coefficients[6]); + return (true); } ////////////////////////////////////////////////////////////////////////// @@ -441,9 +444,17 @@ pcl::SampleConsensusModelCircle3D::isModelValid (const Eigen::VectorXf & return (false); if (radius_min_ != -DBL_MAX && model_coefficients[3] < radius_min_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCircle3D::isModelValid] Radius of circle is too small: should be larger than %g, but is %g.\n", + radius_min_, model_coefficients[3]); return (false); + } if (radius_max_ != DBL_MAX && model_coefficients[3] > radius_max_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCircle3D::isModelValid] Radius of circle is too big: should be smaller than %g, but is %g.\n", + radius_max_, model_coefficients[3]); return (false); + } return (true); } 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 bd206253144..c93e1cf3f32 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 @@ -134,6 +134,9 @@ pcl::SampleConsensusModelCone::computeModelCoefficients ( if (model_coefficients[6] != std::numeric_limits::max() && model_coefficients[6] > max_angle_) return (false); + PCL_DEBUG ("[pcl::SampleConsensusModelCone::computeModelCoefficients] Model is (%g,%g,%g,%g,%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], model_coefficients[3], + model_coefficients[4], model_coefficients[5], model_coefficients[6]); return (true); } @@ -511,13 +514,24 @@ pcl::SampleConsensusModelCone::isModelValid (const Eigen::Vecto angle_diff = (std::min) (angle_diff, M_PI - angle_diff); // Check whether the current cone model satisfies our angle threshold criterion with respect to the given axis if (angle_diff > eps_angle_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCone::isModelValid] Angle between cone direction and given axis is too large.\n"); return (false); + } } if (model_coefficients[6] != -std::numeric_limits::max() && model_coefficients[6] < min_angle_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCone::isModelValid] The opening angle is too small: should be larger than %g, but is %g.\n", + min_angle_, model_coefficients[6]); return (false); + } if (model_coefficients[6] != std::numeric_limits::max() && model_coefficients[6] > max_angle_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCone::isModelValid] The opening angle is too big: should be smaller than %g, but is %g.\n", + max_angle_, model_coefficients[6]); return (false); + } return (true); } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp index 7b0d25f0475..493ada7dada 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp @@ -128,6 +128,9 @@ pcl::SampleConsensusModelCylinder::computeModelCoefficients ( if (model_coefficients[6] > radius_max_ || model_coefficients[6] < radius_min_) return (false); + PCL_DEBUG ("[pcl::SampleConsensusModelCylinder::computeModelCoefficients] Model is (%g,%g,%g,%g,%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], model_coefficients[3], + model_coefficients[4], model_coefficients[5], model_coefficients[6]); return (true); } @@ -458,13 +461,24 @@ pcl::SampleConsensusModelCylinder::isModelValid (const Eigen::V angle_diff = (std::min) (angle_diff, M_PI - angle_diff); // Check whether the current cylinder model satisfies our angle threshold criterion with respect to the given axis if (angle_diff > eps_angle_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCylinder::isModelValid] Angle between cylinder direction and given axis is too large.\n"); return (false); + } } if (radius_min_ != -std::numeric_limits::max() && model_coefficients[6] < radius_min_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCylinder::isModelValid] Radius is too small: should be larger than %g, but is %g.\n", + radius_min_, model_coefficients[6]); return (false); + } if (radius_max_ != std::numeric_limits::max() && model_coefficients[6] > radius_max_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelCylinder::isModelValid] Radius is too big: should be smaller than %g, but is %g.\n", + radius_max_, model_coefficients[6]); return (false); + } return (true); } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_line.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_line.hpp index 808360442be..4f28bffb982 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_line.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_line.hpp @@ -97,6 +97,9 @@ pcl::SampleConsensusModelLine::computeModelCoefficients ( model_coefficients[5] = input_->points[samples[1]].z - model_coefficients[2]; model_coefficients.template tail<3> ().normalize (); + PCL_DEBUG ("[pcl::SampleConsensusModelLine::computeModelCoefficients] Model is (%g,%g,%g,%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], + model_coefficients[3], model_coefficients[4], model_coefficients[5]); return (true); } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_parallel_plane.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_parallel_plane.hpp index f9066229898..a3640d56361 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_parallel_plane.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_normal_parallel_plane.hpp @@ -59,13 +59,20 @@ pcl::SampleConsensusModelNormalParallelPlane::isModelValid (con coeff.normalize (); if (std::abs (axis_.dot (coeff)) < cos_angle_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelNormalParallelPlane::isModelValid] Angle between plane normal and given axis is too large.\n"); return (false); + } } if (eps_dist_ > 0.0) { if (std::abs (-model_coefficients[3] - distance_from_origin_) > eps_dist_) + { + PCL_DEBUG ("[pcl::SampleConsensusModelNormalParallelPlane::isModelValid] Distance of plane to origin is wrong: expected %g, but is %g, difference is larger than %g.\n", + distance_from_origin_, -model_coefficients[3], eps_dist_); return (false); + } } return (true); diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_line.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_line.hpp index b6d74a4688e..ede7c2de4be 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_line.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_line.hpp @@ -107,6 +107,7 @@ pcl::SampleConsensusModelParallelLine::isModelValid (const Eigen::Vector // Check whether the current line model satisfies our angle threshold criterion with respect to the given axis if (angle_diff > eps_angle_) { + PCL_DEBUG ("[pcl::SampleConsensusModelParallelLine::isModelValid] Angle between line direction and given axis is too large.\n"); return (false); } } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_plane.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_plane.hpp index e2db128690a..44b7765b84c 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_plane.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_parallel_plane.hpp @@ -107,6 +107,7 @@ pcl::SampleConsensusModelParallelPlane::isModelValid (const Eigen::Vecto Eigen::Vector4f axis (axis_[0], axis_[1], axis_[2], 0.0f); if (std::abs (axis.dot (coeff)) > sin_angle_) { + PCL_DEBUG ("[pcl::SampleConsensusModelParallelPlane::isModelValid] Angle between plane normal and given axis is too large.\n"); return (false); } } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_perpendicular_plane.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_perpendicular_plane.hpp index 9f04f4310bb..372f28b8fff 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_perpendicular_plane.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_perpendicular_plane.hpp @@ -109,6 +109,8 @@ pcl::SampleConsensusModelPerpendicularPlane::isModelValid (const Eigen:: // Check whether the current plane model satisfies our angle threshold criterion with respect to the given axis if (angle_diff > eps_angle_) { + PCL_DEBUG ("[pcl::SampleConsensusModelPerpendicularPlane::isModelValid] Angle between plane normal and given axis should be smaller than %g, but is %g.\n", + eps_angle_, angle_diff); 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 80a6d8a28ad..55427207a2d 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 @@ -108,6 +108,8 @@ pcl::SampleConsensusModelPlane::computeModelCoefficients ( // ... + d = 0 model_coefficients[3] = -1.0f * (model_coefficients.template head<4>().dot (p0.matrix ())); + PCL_DEBUG ("[pcl::SampleConsensusModelPlane::computeModelCoefficients] Model is (%g,%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], model_coefficients[3]); return (true); } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp index b18a9a3a0ba..7da616056db 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp @@ -123,6 +123,8 @@ pcl::SampleConsensusModelSphere::computeModelCoefficients ( model_coefficients[1] * model_coefficients[1] + model_coefficients[2] * model_coefficients[2] - m15 / m11); + PCL_DEBUG ("[pcl::SampleConsensusModelSphere::computeModelCoefficients] Model is (%g,%g,%g,%g)\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], model_coefficients[3]); return (true); } diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_stick.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_stick.hpp index bdbfc4e7f10..19313b443c2 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_stick.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_stick.hpp @@ -95,6 +95,9 @@ pcl::SampleConsensusModelStick::computeModelCoefficients ( // model_coefficients.template segment<3> (3).normalize (); // We don't care about model_coefficients[6] which is the width (radius) of the stick + PCL_DEBUG ("[pcl::SampleConsensusModelStick::computeModelCoefficients] Model is (%g,%g,%g,%g,%g,%g).\n", + model_coefficients[0], model_coefficients[1], model_coefficients[2], + model_coefficients[3], model_coefficients[4], model_coefficients[5]); return (true); } From d65df2ec07bf5018334a6c50cf920a43fb6c95e5 Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Sat, 25 Apr 2020 10:31:04 +0000 Subject: [PATCH 002/431] add tests for CropHull applied suggestion from @kunaltyagi delete unused (knowingly falling) tests CropHull test refactor: callback -> SetUp/TearDown & vector of data CropHull test refactor. using TYPED_TEST_SUITE --- test/filters/CMakeLists.txt | 8 +- test/filters/test_crop_hull.cpp | 297 ++++++++++++++++++++++++++++++++ 2 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 test/filters/test_crop_hull.cpp diff --git a/test/filters/CMakeLists.txt b/test/filters/CMakeLists.txt index df60939a849..c618bd4bb65 100644 --- a/test/filters/CMakeLists.txt +++ b/test/filters/CMakeLists.txt @@ -1,7 +1,7 @@ set(SUBSYS_NAME tests_filters) set(SUBSYS_DESC "Point cloud library filters module unit tests") PCL_SET_TEST_DEPENDENCIES(SUBSYS_DEPS filters) -set(OPT_DEPS io features segmentation) +set(OPT_DEPS io features segmentation surface) set(DEFAULT ON) set(build TRUE) @@ -37,6 +37,12 @@ PCL_ADD_TEST(filters_convolution test_convolution FILES test_convolution.cpp LINK_WITH pcl_gtest pcl_filters) +if (BUILD_surface AND QHULL_FOUND) + PCL_ADD_TEST(filters_crop_hull test_crop_hull + FILES test_crop_hull.cpp + LINK_WITH pcl_gtest pcl_surface pcl_filters) +endif() + if(BUILD_io) PCL_ADD_TEST(filters_bilateral test_filters_bilateral FILES test_bilateral.cpp diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp new file mode 100644 index 00000000000..2c91095629c --- /dev/null +++ b/test/filters/test_crop_hull.cpp @@ -0,0 +1,297 @@ +/* + * Software License Agreement (BSD License) + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2012-, Open Perception, Inc. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the copyright holder(s) nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $Id: test_filters.cpp 7683 2012-10-23 02:49:03Z rusu $ + * + */ + +#include +#include + +#include + +#include +#include +#include +#include + + +namespace +{ + bool randomBool() + { + static std::default_random_engine gen; + static std::uniform_int_distribution<> int_distr(0, 1); + return int_distr(gen); + } + + struct TestData + { + TestData(pcl::Indices const & insideIndices, pcl::PointCloud::ConstPtr inputCloud) + : inputCloud(inputCloud), + insideMask(inputCloud->size(), false), + insideIndices(insideIndices), + insideCloud(new pcl::PointCloud), + outsideCloud(new pcl::PointCloud) + { + pcl::copyPointCloud(*inputCloud, insideIndices, *insideCloud); + for (pcl::index_t idx : insideIndices) { + insideMask[idx] = true; + } + for (size_t i = 0; i < inputCloud->size(); ++i) { + if (!insideMask[i]) { + outsideIndices.push_back(i); + } + } + pcl::copyPointCloud(*inputCloud, outsideIndices, *outsideCloud); + } + + pcl::PointCloud::ConstPtr inputCloud; + std::vector insideMask; + pcl::Indices insideIndices, outsideIndices; + pcl::PointCloud::Ptr insideCloud, outsideCloud; + }; + + + std::vector + createTestDataSuite( + std::function insidePointGenerator, + std::function outsidePointGenerator) + { + std::vector testDataSuite; + size_t const chunkSize = 1000; + pcl::PointCloud::Ptr insideCloud(new pcl::PointCloud); + pcl::PointCloud::Ptr outsideCloud(new pcl::PointCloud); + pcl::PointCloud::Ptr mixedCloud(new pcl::PointCloud); + pcl::Indices insideIndicesForInsideCloud; + pcl::Indices insideIndicesForOutsideCloud; // empty indices, cause outsideCloud don't contains any inside point + pcl::Indices insideIndicesForMixedCloud; + for (size_t i = 0; i < chunkSize; ++i) + { + insideIndicesForInsideCloud.push_back(i); + insideCloud->push_back(insidePointGenerator()); + outsideCloud->push_back(outsidePointGenerator()); + if (randomBool()) { + insideIndicesForMixedCloud.push_back(i); + mixedCloud->push_back(insidePointGenerator()); + } + else { + mixedCloud->push_back(outsidePointGenerator()); + } + } + testDataSuite.emplace_back(std::move(insideIndicesForInsideCloud), insideCloud); + testDataSuite.emplace_back(std::move(insideIndicesForOutsideCloud), outsideCloud); + testDataSuite.emplace_back(std::move(insideIndicesForMixedCloud), mixedCloud); + return testDataSuite; + } + + + template + class PCLCropHullTestFixture : public ::testing::Test + { + public: + PCLCropHullTestFixture() + : gen(12345u), + rd(0.0f, 1.0f) + { + baseOffsetList.emplace_back(0, 0, 0); + baseOffsetList.emplace_back(5, 1, 10); + baseOffsetList.emplace_back(1, 5, 10); + baseOffsetList.emplace_back(1, 10, 5); + baseOffsetList.emplace_back(10, 1, 5); + baseOffsetList.emplace_back(10, 5, 1); + } + protected: + + void SetUp() override + { + data.clear(); + pcl::PointCloud::Ptr inputCloud (new pcl::PointCloud); + for (pcl::PointXYZ const & baseOffset : baseOffsetList) + { + pcl::copyPointCloud(*CropHullTestTraits::getInputCloud(), *inputCloud); + for (pcl::PointXYZ & p : *inputCloud) { + p.getVector3fMap() += baseOffset.getVector3fMap(); + } + auto insidePointGenerator = [this, &baseOffset] () { + pcl::PointXYZ p(rd(gen), rd(gen), rd(gen)); + p.getVector3fMap() += baseOffset.getVector3fMap(); + return p; + }; + auto outsidePointGenerator = [this, &baseOffset] () { + pcl::PointXYZ p(rd(gen) + 2., rd(gen) + 2., rd(gen) + 2.); + p.getVector3fMap() += baseOffset.getVector3fMap(); + return p; + }; + pcl::CropHull cropHullFilter = createDefaultCropHull(inputCloud); + std::vector testDataSuite = createTestDataSuite(insidePointGenerator, outsidePointGenerator); + data.emplace_back(cropHullFilter, testDataSuite); + } + } + + std::vector, std::vector>> data; + + private: + pcl::CropHull createDefaultCropHull (pcl::PointCloud::ConstPtr inputCloud) const + { + //pcl::CropHull cropHullFilter(true); + pcl::CropHull cropHullFilter; + pcl::ConvexHull convexHull; + convexHull.setDimension(3); + convexHull.setInputCloud(inputCloud); + pcl::PointCloud::Ptr hullCloudPtr(new pcl::PointCloud); + std::vector hullPolygons; + convexHull.reconstruct(*hullCloudPtr, hullPolygons); + cropHullFilter.setHullIndices(hullPolygons); + cropHullFilter.setHullCloud(hullCloudPtr); + cropHullFilter.setDim(CropHullTestTraits::getDim()); + return cropHullFilter; + } + + mutable std::mt19937 gen; + mutable std::uniform_real_distribution rd; + pcl::PointCloud baseOffsetList; + }; + + + struct CropHullTestTraits2d + { + static pcl::PointCloud::ConstPtr getInputCloud() + { + static pcl::PointCloud::Ptr inputCloud (new pcl::PointCloud); + if (inputCloud->empty()) { + for (const float i: {0.f, 1.f}) + for (const float j: {0.f, 1.f}) + for (const float k: {0.f, -0.1f}) + inputCloud->emplace_back(i, j, k); + } + return inputCloud; + } + static int getDim() { + return 2; + } + }; + + + struct CropHullTestTraits3d + { + static pcl::PointCloud::ConstPtr getInputCloud() + { + static pcl::PointCloud::Ptr inputCloud (new pcl::PointCloud); + if (inputCloud->empty()) { + for (const float i: {0.f, 1.f}) + for (const float j: {0.f, 1.f}) + for (const float k: {0.f, 1.f}) + inputCloud->emplace_back(i, j, k); + } + return inputCloud; + } + static int getDim() { + return 3; + } + }; +} +using CropHullTestTypes = ::testing::Types; +TYPED_TEST_SUITE(PCLCropHullTestFixture, CropHullTestTypes); + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// since test input cloud has same distribution for all dimensions, this test also check problem from issue #3960 // +TYPED_TEST (PCLCropHullTestFixture, simple_test) +{ + for (auto & entry : this->data) + { + auto & cropHullFilter = entry.first; + for (TestData const & testData : entry.second) + { + cropHullFilter.setInputCloud(testData.inputCloud); + pcl::Indices filteredIndices; + cropHullFilter.filter(filteredIndices); + pcl::test::EXPECT_EQ_VECTORS(testData.insideIndices, filteredIndices); + } + } +} + + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// this test will pass only for 2d case // +using PCLCropHullTestFixture2d = PCLCropHullTestFixture; +TEST_F (PCLCropHullTestFixture2d, test_crop_inside) +{ + for (auto & entry : this->data) + { + auto & cropHullFilter = entry.first; + for (TestData const & testData : entry.second) + { + cropHullFilter.setInputCloud(testData.inputCloud); + cropHullFilter.setCropOutside(false); + pcl::Indices filteredIndices; + cropHullFilter.filter(filteredIndices); + pcl::test::EXPECT_EQ_VECTORS(testData.outsideIndices, filteredIndices); + } + } +} + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +TYPED_TEST (PCLCropHullTestFixture, test_cloud_filtering) +{ + for (auto & entry : this->data) + { + auto & cropHullFilter = entry.first; + for (TestData const & testData : entry.second) + { + cropHullFilter.setInputCloud(testData.inputCloud); + pcl::PointCloud filteredCloud; + cropHullFilter.filter(filteredCloud); + ASSERT_EQ (testData.insideCloud->size(), filteredCloud.size()); + for (pcl::index_t i = 0; i < testData.insideCloud->size(); ++i) + { + EXPECT_XYZ_NEAR(testData.insideCloud->at(i), filteredCloud[i], 1e-5); + } + } + } +} + + + +/* ---[ */ +int +main (int argc, char** argv) +{ + // Testing + testing::InitGoogleTest (&argc, argv); + return (RUN_ALL_TESTS ()); +} +/* ]--- */ From 01f83ff9a27f23eaba556cf677b7b5fbe188daf4 Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Sat, 25 Apr 2020 10:34:54 +0000 Subject: [PATCH 003/431] fixup bug from issue 3960 --- filters/include/pcl/filters/impl/crop_hull.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/filters/include/pcl/filters/impl/crop_hull.hpp b/filters/include/pcl/filters/impl/crop_hull.hpp index 2a784c107bf..cdceb0ac899 100644 --- a/filters/include/pcl/filters/impl/crop_hull.hpp +++ b/filters/include/pcl/filters/impl/crop_hull.hpp @@ -104,16 +104,19 @@ pcl::CropHull::getHullCloudRange () -std::numeric_limits::max (), -std::numeric_limits::max () ); - for (std::size_t index = 0; index < indices_->size (); index++) + for (pcl::Vertices const & poly : hull_polygons_) { - Eigen::Vector3f pt = (*input_)[(*indices_)[index]].getVector3fMap (); - for (int i = 0; i < 3; i++) + for (std::uint32_t const & idx : poly.vertices) { - if (pt[i] < cloud_min[i]) cloud_min[i] = pt[i]; - if (pt[i] > cloud_max[i]) cloud_max[i] = pt[i]; + Eigen::Vector3f pt = hull_cloud_->points[idx].getVector3fMap (); + for (int i = 0; i < 3; i++) + { + if (pt[i] < cloud_min[i]) cloud_min[i] = pt[i]; + if (pt[i] > cloud_max[i]) cloud_max[i] = pt[i]; + } } } - + return (cloud_max - cloud_min); } From 3254e525895bd49bcabfffc1564142f4ae92b573 Mon Sep 17 00:00:00 2001 From: DaniilSNikulin <31708320+DaniilSNikulin@users.noreply.github.com> Date: Thu, 7 May 2020 19:43:38 +0300 Subject: [PATCH 004/431] Update filters/include/pcl/filters/impl/crop_hull.hpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sérgio Agostinho --- filters/include/pcl/filters/impl/crop_hull.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filters/include/pcl/filters/impl/crop_hull.hpp b/filters/include/pcl/filters/impl/crop_hull.hpp index cdceb0ac899..12e68c88ea8 100644 --- a/filters/include/pcl/filters/impl/crop_hull.hpp +++ b/filters/include/pcl/filters/impl/crop_hull.hpp @@ -108,7 +108,7 @@ pcl::CropHull::getHullCloudRange () { for (std::uint32_t const & idx : poly.vertices) { - Eigen::Vector3f pt = hull_cloud_->points[idx].getVector3fMap (); + Eigen::Vector3f pt = (*hull_cloud_)[idx].getVector3fMap (); for (int i = 0; i < 3; i++) { if (pt[i] < cloud_min[i]) cloud_min[i] = pt[i]; From 3241e7aea1a76e33ecb55dffbe98f4573beaa3a0 Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Thu, 7 May 2020 18:00:37 +0000 Subject: [PATCH 005/431] CropHull test refactor according pcl style guide --- test/filters/test_crop_hull.cpp | 390 +++++++++++++++++--------------- 1 file changed, 209 insertions(+), 181 deletions(-) diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp index 2c91095629c..41206497775 100644 --- a/test/filters/test_crop_hull.cpp +++ b/test/filters/test_crop_hull.cpp @@ -37,11 +37,11 @@ * */ +#include + #include #include -#include - #include #include #include @@ -50,179 +50,206 @@ namespace { - bool randomBool() - { - static std::default_random_engine gen; - static std::uniform_int_distribution<> int_distr(0, 1); - return int_distr(gen); - } - struct TestData +bool +getRandomBool () +{ + static std::default_random_engine gen; + static std::uniform_int_distribution<> int_distr(0, 1); + return int_distr(gen); +} + +struct TestData +{ + TestData(pcl::Indices const & insideIndices, pcl::PointCloud::ConstPtr input_cloud) + : input_cloud_(input_cloud), + inside_mask_(input_cloud_->size(), false), + inside_indices_(insideIndices), + inside_cloud_(new pcl::PointCloud), + outside_cloud_(new pcl::PointCloud) { - TestData(pcl::Indices const & insideIndices, pcl::PointCloud::ConstPtr inputCloud) - : inputCloud(inputCloud), - insideMask(inputCloud->size(), false), - insideIndices(insideIndices), - insideCloud(new pcl::PointCloud), - outsideCloud(new pcl::PointCloud) - { - pcl::copyPointCloud(*inputCloud, insideIndices, *insideCloud); - for (pcl::index_t idx : insideIndices) { - insideMask[idx] = true; - } - for (size_t i = 0; i < inputCloud->size(); ++i) { - if (!insideMask[i]) { - outsideIndices.push_back(i); - } + pcl::copyPointCloud(*input_cloud_, inside_indices_, *inside_cloud_); + for (pcl::index_t idx : inside_indices_) { + inside_mask_[idx] = true; + } + for (size_t i = 0; i < input_cloud_->size(); ++i) { + if (!inside_mask_[i]) { + outside_indices_.push_back(i); } - pcl::copyPointCloud(*inputCloud, outsideIndices, *outsideCloud); } + pcl::copyPointCloud(*input_cloud_, outside_indices_, *outside_cloud_); + } - pcl::PointCloud::ConstPtr inputCloud; - std::vector insideMask; - pcl::Indices insideIndices, outsideIndices; - pcl::PointCloud::Ptr insideCloud, outsideCloud; - }; + pcl::PointCloud::ConstPtr input_cloud_; + std::vector inside_mask_; + pcl::Indices inside_indices_, outside_indices_; + pcl::PointCloud::Ptr inside_cloud_, outside_cloud_; +}; - std::vector - createTestDataSuite( - std::function insidePointGenerator, - std::function outsidePointGenerator) +std::vector +createTestDataSuite( + std::function inside_point_generator, + std::function outside_point_generator) +{ + std::vector test_data_suite; + size_t const chunk_size = 1000; + pcl::PointCloud::Ptr inside_cloud(new pcl::PointCloud); + pcl::PointCloud::Ptr outside_cloud(new pcl::PointCloud); + pcl::PointCloud::Ptr mixed_cloud(new pcl::PointCloud); + pcl::Indices inside_indices_for_inside_cloud; + pcl::Indices inside_indices_for_outside_cloud; // empty indices, cause outside_cloud don't contains any inside point + pcl::Indices inside_indices_for_mixed_cloud; + for (size_t i = 0; i < chunk_size; ++i) { - std::vector testDataSuite; - size_t const chunkSize = 1000; - pcl::PointCloud::Ptr insideCloud(new pcl::PointCloud); - pcl::PointCloud::Ptr outsideCloud(new pcl::PointCloud); - pcl::PointCloud::Ptr mixedCloud(new pcl::PointCloud); - pcl::Indices insideIndicesForInsideCloud; - pcl::Indices insideIndicesForOutsideCloud; // empty indices, cause outsideCloud don't contains any inside point - pcl::Indices insideIndicesForMixedCloud; - for (size_t i = 0; i < chunkSize; ++i) - { - insideIndicesForInsideCloud.push_back(i); - insideCloud->push_back(insidePointGenerator()); - outsideCloud->push_back(outsidePointGenerator()); - if (randomBool()) { - insideIndicesForMixedCloud.push_back(i); - mixedCloud->push_back(insidePointGenerator()); - } - else { - mixedCloud->push_back(outsidePointGenerator()); - } + inside_indices_for_inside_cloud.push_back(i); + inside_cloud->push_back(inside_point_generator()); + outside_cloud->push_back(outside_point_generator()); + if (getRandomBool()) { + inside_indices_for_mixed_cloud.push_back(i); + mixed_cloud->push_back(inside_point_generator()); + } + else { + mixed_cloud->push_back(outside_point_generator()); } - testDataSuite.emplace_back(std::move(insideIndicesForInsideCloud), insideCloud); - testDataSuite.emplace_back(std::move(insideIndicesForOutsideCloud), outsideCloud); - testDataSuite.emplace_back(std::move(insideIndicesForMixedCloud), mixedCloud); - return testDataSuite; } + test_data_suite.emplace_back(std::move(inside_indices_for_inside_cloud), inside_cloud); + test_data_suite.emplace_back(std::move(inside_indices_for_outside_cloud), outside_cloud); + test_data_suite.emplace_back(std::move(inside_indices_for_mixed_cloud), mixed_cloud); + return test_data_suite; +} - template - class PCLCropHullTestFixture : public ::testing::Test - { - public: - PCLCropHullTestFixture() - : gen(12345u), - rd(0.0f, 1.0f) - { - baseOffsetList.emplace_back(0, 0, 0); - baseOffsetList.emplace_back(5, 1, 10); - baseOffsetList.emplace_back(1, 5, 10); - baseOffsetList.emplace_back(1, 10, 5); - baseOffsetList.emplace_back(10, 1, 5); - baseOffsetList.emplace_back(10, 5, 1); - } - protected: +template +class PCLCropHullTestFixture : public ::testing::Test +{ + public: + PCLCropHullTestFixture() + : gen_(12345u), + rd_(0.0f, 1.0f) + { + baseOffsetList_.emplace_back(0, 0, 0); + baseOffsetList_.emplace_back(5, 1, 10); + baseOffsetList_.emplace_back(1, 5, 10); + baseOffsetList_.emplace_back(1, 10, 5); + baseOffsetList_.emplace_back(10, 1, 5); + baseOffsetList_.emplace_back(10, 5, 1); + } + protected: - void SetUp() override + void + SetUp () override + { + data_.clear(); + pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); + for (pcl::PointXYZ const & baseOffset : baseOffsetList_) { - data.clear(); - pcl::PointCloud::Ptr inputCloud (new pcl::PointCloud); - for (pcl::PointXYZ const & baseOffset : baseOffsetList) - { - pcl::copyPointCloud(*CropHullTestTraits::getInputCloud(), *inputCloud); - for (pcl::PointXYZ & p : *inputCloud) { - p.getVector3fMap() += baseOffset.getVector3fMap(); - } - auto insidePointGenerator = [this, &baseOffset] () { - pcl::PointXYZ p(rd(gen), rd(gen), rd(gen)); - p.getVector3fMap() += baseOffset.getVector3fMap(); - return p; - }; - auto outsidePointGenerator = [this, &baseOffset] () { - pcl::PointXYZ p(rd(gen) + 2., rd(gen) + 2., rd(gen) + 2.); - p.getVector3fMap() += baseOffset.getVector3fMap(); - return p; - }; - pcl::CropHull cropHullFilter = createDefaultCropHull(inputCloud); - std::vector testDataSuite = createTestDataSuite(insidePointGenerator, outsidePointGenerator); - data.emplace_back(cropHullFilter, testDataSuite); + pcl::copyPointCloud(*CropHullTestTraits::getInputCloud(), *input_cloud); + for (pcl::PointXYZ & p : *input_cloud) { + p.getVector3fMap() += baseOffset.getVector3fMap(); } + auto inside_point_generator = [this, &baseOffset] () { + pcl::PointXYZ p(rd_(gen_), rd_(gen_), rd_(gen_)); + p.getVector3fMap() += baseOffset.getVector3fMap(); + return p; + }; + auto outside_point_generator = [this, &baseOffset] () { + pcl::PointXYZ p(rd_(gen_) + 2., rd_(gen_) + 2., rd_(gen_) + 2.); + p.getVector3fMap() += baseOffset.getVector3fMap(); + return p; + }; + pcl::CropHull crop_hull_filter = createDefaultCropHull(input_cloud); + std::vector test_data_suite = createTestDataSuite(inside_point_generator, outside_point_generator); + data_.emplace_back(crop_hull_filter, test_data_suite); } + } - std::vector, std::vector>> data; + std::vector, std::vector>> data_; - private: - pcl::CropHull createDefaultCropHull (pcl::PointCloud::ConstPtr inputCloud) const - { - //pcl::CropHull cropHullFilter(true); - pcl::CropHull cropHullFilter; - pcl::ConvexHull convexHull; - convexHull.setDimension(3); - convexHull.setInputCloud(inputCloud); - pcl::PointCloud::Ptr hullCloudPtr(new pcl::PointCloud); - std::vector hullPolygons; - convexHull.reconstruct(*hullCloudPtr, hullPolygons); - cropHullFilter.setHullIndices(hullPolygons); - cropHullFilter.setHullCloud(hullCloudPtr); - cropHullFilter.setDim(CropHullTestTraits::getDim()); - return cropHullFilter; - } + private: + pcl::CropHull + createDefaultCropHull (pcl::PointCloud::ConstPtr input_cloud) const + { + //pcl::CropHull crop_hull_filter(true); + pcl::CropHull crop_hull_filter; + pcl::ConvexHull convex_hull; + convex_hull.setDimension(3); + convex_hull.setInputCloud(input_cloud); + pcl::PointCloud::Ptr hull_cloud_ptr(new pcl::PointCloud); + std::vector hull_polygons; + convex_hull.reconstruct(*hull_cloud_ptr, hull_polygons); + crop_hull_filter.setHullIndices(hull_polygons); + crop_hull_filter.setHullCloud(hull_cloud_ptr); + crop_hull_filter.setDim(CropHullTestTraits::getDim()); + return crop_hull_filter; + } - mutable std::mt19937 gen; - mutable std::uniform_real_distribution rd; - pcl::PointCloud baseOffsetList; - }; + mutable std::mt19937 gen_; + mutable std::uniform_real_distribution rd_; + pcl::PointCloud baseOffsetList_; +}; - struct CropHullTestTraits2d - { - static pcl::PointCloud::ConstPtr getInputCloud() - { - static pcl::PointCloud::Ptr inputCloud (new pcl::PointCloud); - if (inputCloud->empty()) { - for (const float i: {0.f, 1.f}) - for (const float j: {0.f, 1.f}) - for (const float k: {0.f, -0.1f}) - inputCloud->emplace_back(i, j, k); - } - return inputCloud; - } - static int getDim() { - return 2; - } - }; +struct CropHullTestTraits2d +{ + static pcl::PointCloud::ConstPtr + getInputCloud(); + static int + getDim(); +}; - struct CropHullTestTraits3d - { - static pcl::PointCloud::ConstPtr getInputCloud() - { - static pcl::PointCloud::Ptr inputCloud (new pcl::PointCloud); - if (inputCloud->empty()) { - for (const float i: {0.f, 1.f}) - for (const float j: {0.f, 1.f}) - for (const float k: {0.f, 1.f}) - inputCloud->emplace_back(i, j, k); - } - return inputCloud; - } - static int getDim() { - return 3; - } - }; + +struct CropHullTestTraits3d +{ + static pcl::PointCloud::ConstPtr + getInputCloud(); + + static int + getDim(); +}; + + +pcl::PointCloud::ConstPtr +CropHullTestTraits2d::getInputCloud () +{ + static pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); + if (input_cloud->empty()) { + for (const float i: {0.f, 1.f}) + for (const float j: {0.f, 1.f}) + for (const float k: {0.f, -0.1f}) + input_cloud->emplace_back(i, j, k); + } + return input_cloud; +} + +int +CropHullTestTraits2d::getDim () +{ + return 2; +} + + +pcl::PointCloud::ConstPtr +CropHullTestTraits3d::getInputCloud () +{ + static pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); + if (input_cloud->empty()) { + for (const float i: {0.f, 1.f}) + for (const float j: {0.f, 1.f}) + for (const float k: {0.f, 1.f}) + input_cloud->emplace_back(i, j, k); + } + return input_cloud; } + +int +CropHullTestTraits3d::getDim () +{ + return 3; +} + +} // end of anonymous namespace using CropHullTestTypes = ::testing::Types; TYPED_TEST_SUITE(PCLCropHullTestFixture, CropHullTestTypes); @@ -231,55 +258,56 @@ TYPED_TEST_SUITE(PCLCropHullTestFixture, CropHullTestTypes); // since test input cloud has same distribution for all dimensions, this test also check problem from issue #3960 // TYPED_TEST (PCLCropHullTestFixture, simple_test) { - for (auto & entry : this->data) + for (auto & entry : this->data_) { - auto & cropHullFilter = entry.first; - for (TestData const & testData : entry.second) + auto & crop_hull_filter = entry.first; + for (TestData const & test_data : entry.second) { - cropHullFilter.setInputCloud(testData.inputCloud); - pcl::Indices filteredIndices; - cropHullFilter.filter(filteredIndices); - pcl::test::EXPECT_EQ_VECTORS(testData.insideIndices, filteredIndices); + crop_hull_filter.setInputCloud(test_data.input_cloud_); + pcl::Indices filtered_indices; + crop_hull_filter.filter(filtered_indices); + pcl::test::EXPECT_EQ_VECTORS(test_data.inside_indices_, filtered_indices); } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// this test will pass only for 2d case // -using PCLCropHullTestFixture2d = PCLCropHullTestFixture; -TEST_F (PCLCropHullTestFixture2d, test_crop_inside) +TYPED_TEST (PCLCropHullTestFixture, test_cloud_filtering) { - for (auto & entry : this->data) + for (auto & entry : this->data_) { - auto & cropHullFilter = entry.first; - for (TestData const & testData : entry.second) + auto & crop_hull_filter = entry.first; + for (TestData const & test_data : entry.second) { - cropHullFilter.setInputCloud(testData.inputCloud); - cropHullFilter.setCropOutside(false); - pcl::Indices filteredIndices; - cropHullFilter.filter(filteredIndices); - pcl::test::EXPECT_EQ_VECTORS(testData.outsideIndices, filteredIndices); + crop_hull_filter.setInputCloud(test_data.input_cloud_); + pcl::PointCloud filteredCloud; + crop_hull_filter.filter(filteredCloud); + ASSERT_EQ (test_data.inside_cloud_->size(), filteredCloud.size()); + for (pcl::index_t i = 0; i < test_data.inside_cloud_->size(); ++i) + { + EXPECT_XYZ_NEAR(test_data.inside_cloud_->at(i), filteredCloud[i], 1e-5); + } } } } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -TYPED_TEST (PCLCropHullTestFixture, test_cloud_filtering) +// this test will pass only for 2d case // +using PCLCropHullTestFixture2d = PCLCropHullTestFixture; +TEST_F (PCLCropHullTestFixture2d, test_crop_inside) { - for (auto & entry : this->data) + for (auto & entry : this->data_) { - auto & cropHullFilter = entry.first; - for (TestData const & testData : entry.second) + auto & crop_hull_filter = entry.first; + for (TestData const & test_data : entry.second) { - cropHullFilter.setInputCloud(testData.inputCloud); - pcl::PointCloud filteredCloud; - cropHullFilter.filter(filteredCloud); - ASSERT_EQ (testData.insideCloud->size(), filteredCloud.size()); - for (pcl::index_t i = 0; i < testData.insideCloud->size(); ++i) - { - EXPECT_XYZ_NEAR(testData.insideCloud->at(i), filteredCloud[i], 1e-5); - } + crop_hull_filter.setInputCloud(test_data.input_cloud_); + crop_hull_filter.setCropOutside(false); + pcl::Indices filtered_indices; + crop_hull_filter.filter(filtered_indices); + pcl::test::EXPECT_EQ_VECTORS(test_data.outside_indices_, filtered_indices); } } } From 8eaabfb8ef24b5ed5a5ae7f44ef7878a9fc43f1f Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Sat, 25 Apr 2020 10:31:04 +0000 Subject: [PATCH 006/431] add tests for CropHull applied suggestion from @kunaltyagi delete unused (knowingly falling) tests CropHull test refactor: callback -> SetUp/TearDown & vector of data CropHull test refactor. using TYPED_TEST_SUITE --- test/filters/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/filters/CMakeLists.txt b/test/filters/CMakeLists.txt index c618bd4bb65..ed427dec9db 100644 --- a/test/filters/CMakeLists.txt +++ b/test/filters/CMakeLists.txt @@ -33,15 +33,14 @@ PCL_ADD_TEST(filters_uniform_sampling test_uniform_sampling FILES test_uniform_sampling.cpp LINK_WITH pcl_gtest pcl_common pcl_filters) + PCL_ADD_TEST(filters_convolution test_convolution FILES test_convolution.cpp LINK_WITH pcl_gtest pcl_filters) -if (BUILD_surface AND QHULL_FOUND) - PCL_ADD_TEST(filters_crop_hull test_crop_hull - FILES test_crop_hull.cpp - LINK_WITH pcl_gtest pcl_surface pcl_filters) -endif() +PCL_ADD_TEST(filters_crop_hull test_crop_hull + FILES test_crop_hull.cpp + LINK_WITH pcl_gtest pcl_filters) if(BUILD_io) PCL_ADD_TEST(filters_bilateral test_filters_bilateral From 082eede2a64ad6f32a4bdd64866a588dd2689475 Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Mon, 27 Jul 2020 16:52:15 +0000 Subject: [PATCH 007/431] delete [surface] module from dependecies for tests --- .../include/pcl/filters/impl/crop_hull.hpp | 7 +- test/filters/CMakeLists.txt | 7 +- test/filters/test_crop_hull.cpp | 106 ++++++++++-------- 3 files changed, 62 insertions(+), 58 deletions(-) diff --git a/filters/include/pcl/filters/impl/crop_hull.hpp b/filters/include/pcl/filters/impl/crop_hull.hpp index 12e68c88ea8..7b913ba6bf0 100644 --- a/filters/include/pcl/filters/impl/crop_hull.hpp +++ b/filters/include/pcl/filters/impl/crop_hull.hpp @@ -109,11 +109,8 @@ pcl::CropHull::getHullCloudRange () for (std::uint32_t const & idx : poly.vertices) { Eigen::Vector3f pt = (*hull_cloud_)[idx].getVector3fMap (); - for (int i = 0; i < 3; i++) - { - if (pt[i] < cloud_min[i]) cloud_min[i] = pt[i]; - if (pt[i] > cloud_max[i]) cloud_max[i] = pt[i]; - } + cloud_min = cloud_min.cwiseMin(pt); + cloud_max = cloud_max.cwiseMax(pt); } } diff --git a/test/filters/CMakeLists.txt b/test/filters/CMakeLists.txt index ed427dec9db..1cbb324938b 100644 --- a/test/filters/CMakeLists.txt +++ b/test/filters/CMakeLists.txt @@ -1,7 +1,7 @@ set(SUBSYS_NAME tests_filters) set(SUBSYS_DESC "Point cloud library filters module unit tests") PCL_SET_TEST_DEPENDENCIES(SUBSYS_DEPS filters) -set(OPT_DEPS io features segmentation surface) +set(OPT_DEPS io features segmentation) set(DEFAULT ON) set(build TRUE) @@ -33,10 +33,9 @@ PCL_ADD_TEST(filters_uniform_sampling test_uniform_sampling FILES test_uniform_sampling.cpp LINK_WITH pcl_gtest pcl_common pcl_filters) - PCL_ADD_TEST(filters_convolution test_convolution - FILES test_convolution.cpp - LINK_WITH pcl_gtest pcl_filters) + FILES test_convolution.cpp + LINK_WITH pcl_gtest pcl_filters) PCL_ADD_TEST(filters_crop_hull test_crop_hull FILES test_crop_hull.cpp diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp index 41206497775..774c7a26581 100644 --- a/test/filters/test_crop_hull.cpp +++ b/test/filters/test_crop_hull.cpp @@ -1,49 +1,19 @@ /* - * Software License Agreement (BSD License) + * SPDX-License-Identifier: BSD-3-Clause * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012-, Open Perception, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of the copyright holder(s) nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: test_filters.cpp 7683 2012-10-23 02:49:03Z rusu $ + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2010-2011, Willow Garage, Inc. + * Copyright (c) 2012-, Open Perception, Inc. * */ #include +#include #include #include #include -#include #include #include @@ -144,7 +114,7 @@ class PCLCropHullTestFixture : public ::testing::Test pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); for (pcl::PointXYZ const & baseOffset : baseOffsetList_) { - pcl::copyPointCloud(*CropHullTestTraits::getInputCloud(), *input_cloud); + pcl::copyPointCloud(*CropHullTestTraits::getHullCloud(), *input_cloud); for (pcl::PointXYZ & p : *input_cloud) { p.getVector3fMap() += baseOffset.getVector3fMap(); } @@ -154,7 +124,9 @@ class PCLCropHullTestFixture : public ::testing::Test return p; }; auto outside_point_generator = [this, &baseOffset] () { - pcl::PointXYZ p(rd_(gen_) + 2., rd_(gen_) + 2., rd_(gen_) + 2.); + std::array pt; + std::generate(pt.begin(), pt.end(), [this] {return rd_(gen_) + 2. * (getRandomBool() ? -1. : 1.);}); + pcl::PointXYZ p(pt[0], pt[1], pt[2]); p.getVector3fMap() += baseOffset.getVector3fMap(); return p; }; @@ -172,14 +144,8 @@ class PCLCropHullTestFixture : public ::testing::Test { //pcl::CropHull crop_hull_filter(true); pcl::CropHull crop_hull_filter; - pcl::ConvexHull convex_hull; - convex_hull.setDimension(3); - convex_hull.setInputCloud(input_cloud); - pcl::PointCloud::Ptr hull_cloud_ptr(new pcl::PointCloud); - std::vector hull_polygons; - convex_hull.reconstruct(*hull_cloud_ptr, hull_polygons); - crop_hull_filter.setHullIndices(hull_polygons); - crop_hull_filter.setHullCloud(hull_cloud_ptr); + crop_hull_filter.setHullCloud(input_cloud->makeShared()); + crop_hull_filter.setHullIndices(CropHullTestTraits::getHullPolygons()); crop_hull_filter.setDim(CropHullTestTraits::getDim()); return crop_hull_filter; } @@ -193,7 +159,10 @@ class PCLCropHullTestFixture : public ::testing::Test struct CropHullTestTraits2d { static pcl::PointCloud::ConstPtr - getInputCloud(); + getHullCloud(); + + static std::vector + getHullPolygons(); static int getDim(); @@ -203,15 +172,34 @@ struct CropHullTestTraits2d struct CropHullTestTraits3d { static pcl::PointCloud::ConstPtr - getInputCloud(); + getHullCloud(); + + static std::vector + getHullPolygons(); static int getDim(); }; +static std::vector> cube_elements = { + {0, 2, 1}, // l + {1, 2, 3}, // l + {3, 2, 6}, // f + {6, 2, 4}, // bt + {4, 2, 0}, // bt + {3, 7, 1}, // t + {1, 7, 5}, // t + {5, 7, 4}, // r + {4, 7, 6}, // r + {6, 7, 3}, // f + {5, 1, 4}, // back + {4, 1, 0} // back +}; + + pcl::PointCloud::ConstPtr -CropHullTestTraits2d::getInputCloud () +CropHullTestTraits2d::getHullCloud () { static pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); if (input_cloud->empty()) { @@ -223,6 +211,16 @@ CropHullTestTraits2d::getInputCloud () return input_cloud; } +std::vector +CropHullTestTraits2d::getHullPolygons () +{ + std::vector polygons(12); + for (size_t i = 0; i < 12; ++i) { + polygons[i].vertices = cube_elements[i]; + } + return polygons; +} + int CropHullTestTraits2d::getDim () { @@ -231,7 +229,7 @@ CropHullTestTraits2d::getDim () pcl::PointCloud::ConstPtr -CropHullTestTraits3d::getInputCloud () +CropHullTestTraits3d::getHullCloud () { static pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); if (input_cloud->empty()) { @@ -243,6 +241,16 @@ CropHullTestTraits3d::getInputCloud () return input_cloud; } +std::vector +CropHullTestTraits3d::getHullPolygons () +{ + std::vector polygons(12); + for (size_t i = 0; i < 12; ++i) { + polygons[i].vertices = cube_elements[i]; + } + return polygons; +} + int CropHullTestTraits3d::getDim () { From d6644d71d1cde12d0f7baafd2cc3687a168ca58b Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Tue, 28 Jul 2020 11:52:52 +0000 Subject: [PATCH 008/431] delete implicit comparison pcl::index_t and std::size_t --- test/filters/test_crop_hull.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp index 774c7a26581..1d818cb1fd4 100644 --- a/test/filters/test_crop_hull.cpp +++ b/test/filters/test_crop_hull.cpp @@ -292,7 +292,8 @@ TYPED_TEST (PCLCropHullTestFixture, test_cloud_filtering) pcl::PointCloud filteredCloud; crop_hull_filter.filter(filteredCloud); ASSERT_EQ (test_data.inside_cloud_->size(), filteredCloud.size()); - for (pcl::index_t i = 0; i < test_data.inside_cloud_->size(); ++i) + pcl::index_t cloud_size = test_data.inside_cloud_->size(); + for (pcl::index_t i = 0; i < cloud_size; ++i) { EXPECT_XYZ_NEAR(test_data.inside_cloud_->at(i), filteredCloud[i], 1e-5); } From b0661d65e45269e9072b1aa6571040933f87fe36 Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Tue, 28 Jul 2020 14:05:34 +0000 Subject: [PATCH 009/431] add explicit include header --- test/filters/test_crop_hull.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp index 1d818cb1fd4..94fe9effbbe 100644 --- a/test/filters/test_crop_hull.cpp +++ b/test/filters/test_crop_hull.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include From ddee39af6ecd8c45a5f74d27187c188b10edbb4e Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Mon, 10 Aug 2020 13:54:13 +0000 Subject: [PATCH 010/431] create multiple seeds for random point generator --- test/filters/test_crop_hull.cpp | 87 ++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 23 deletions(-) diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp index 94fe9effbbe..0b534f1e59a 100644 --- a/test/filters/test_crop_hull.cpp +++ b/test/filters/test_crop_hull.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -22,13 +23,6 @@ namespace { -bool -getRandomBool () -{ - static std::default_random_engine gen; - static std::uniform_int_distribution<> int_distr(0, 1); - return int_distr(gen); -} struct TestData { @@ -76,7 +70,7 @@ createTestDataSuite( inside_indices_for_inside_cloud.push_back(i); inside_cloud->push_back(inside_point_generator()); outside_cloud->push_back(outside_point_generator()); - if (getRandomBool()) { + if (i % 2) { inside_indices_for_mixed_cloud.push_back(i); mixed_cloud->push_back(inside_point_generator()); } @@ -91,13 +85,14 @@ createTestDataSuite( } -template +template class PCLCropHullTestFixture : public ::testing::Test { public: + using CropHullTestTraits = typename std::tuple_element<0, TupleType>::type; + using RandomGeneratorType = typename std::tuple_element<1, TupleType>::type; + PCLCropHullTestFixture() - : gen_(12345u), - rd_(0.0f, 1.0f) { baseOffsetList_.emplace_back(0, 0, 0); baseOffsetList_.emplace_back(5, 1, 10); @@ -120,13 +115,17 @@ class PCLCropHullTestFixture : public ::testing::Test p.getVector3fMap() += baseOffset.getVector3fMap(); } auto inside_point_generator = [this, &baseOffset] () { - pcl::PointXYZ p(rd_(gen_), rd_(gen_), rd_(gen_)); + pcl::PointXYZ p(rg_(), rg_(), rg_()); p.getVector3fMap() += baseOffset.getVector3fMap(); return p; }; auto outside_point_generator = [this, &baseOffset] () { std::array pt; - std::generate(pt.begin(), pt.end(), [this] {return rd_(gen_) + 2. * (getRandomBool() ? -1. : 1.);}); + std::generate(pt.begin(), pt.end(), + [this] { + float v = rg_(); + return v + std::copysign(0.51, v); + }); pcl::PointXYZ p(pt[0], pt[1], pt[2]); p.getVector3fMap() += baseOffset.getVector3fMap(); return p; @@ -151,8 +150,7 @@ class PCLCropHullTestFixture : public ::testing::Test return crop_hull_filter; } - mutable std::mt19937 gen_; - mutable std::uniform_real_distribution rd_; + RandomGeneratorType rg_; pcl::PointCloud baseOffsetList_; }; @@ -183,6 +181,23 @@ struct CropHullTestTraits3d }; +template struct RandomGenerator +{ + public: + RandomGenerator() + : gen_(seed), rd_(-0.5f, 0.5f) + {} + + float operator()() { + return rd_(gen_); + } + + private: + std::mt19937 gen_; + std::uniform_real_distribution rd_; +}; + + static std::vector> cube_elements = { {0, 2, 1}, // l {1, 2, 3}, // l @@ -204,8 +219,8 @@ CropHullTestTraits2d::getHullCloud () { static pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); if (input_cloud->empty()) { - for (const float i: {0.f, 1.f}) - for (const float j: {0.f, 1.f}) + for (const float i: {-0.5f, 0.5f}) + for (const float j: {-0.5f, .5f}) for (const float k: {0.f, -0.1f}) input_cloud->emplace_back(i, j, k); } @@ -234,9 +249,9 @@ CropHullTestTraits3d::getHullCloud () { static pcl::PointCloud::Ptr input_cloud (new pcl::PointCloud); if (input_cloud->empty()) { - for (const float i: {0.f, 1.f}) - for (const float j: {0.f, 1.f}) - for (const float k: {0.f, 1.f}) + for (const float i: {-0.5f, 0.5f}) + for (const float j: {-0.5f, 0.5f}) + for (const float k: {-0.5f, 0.5f}) input_cloud->emplace_back(i, j, k); } return input_cloud; @@ -259,7 +274,24 @@ CropHullTestTraits3d::getDim () } } // end of anonymous namespace -using CropHullTestTypes = ::testing::Types; +using CropHullTestTraits2dList = std::tuple< + std::tuple>, + std::tuple>, + std::tuple> + >; +using CropHullTestTraits3dList = std::tuple< + std::tuple>, + std::tuple>, + std::tuple> + >; +using CropHullTestTypes = ::testing::Types< + std::tuple_element<0, CropHullTestTraits2dList>::type, + std::tuple_element<1, CropHullTestTraits2dList>::type, + std::tuple_element<2, CropHullTestTraits2dList>::type, + std::tuple_element<0, CropHullTestTraits3dList>::type, + std::tuple_element<1, CropHullTestTraits3dList>::type, + std::tuple_element<2, CropHullTestTraits3dList>::type + >; TYPED_TEST_SUITE(PCLCropHullTestFixture, CropHullTestTypes); @@ -305,8 +337,17 @@ TYPED_TEST (PCLCropHullTestFixture, test_cloud_filtering) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // this test will pass only for 2d case // -using PCLCropHullTestFixture2d = PCLCropHullTestFixture; -TEST_F (PCLCropHullTestFixture2d, test_crop_inside) +template +struct PCLCropHullTestFixture2dCrutch : PCLCropHullTestFixture +{}; +using CropHullTestTraits2dTypes = ::testing::Types< + std::tuple_element<0, CropHullTestTraits2dList>::type, + std::tuple_element<1, CropHullTestTraits2dList>::type, + std::tuple_element<2, CropHullTestTraits2dList>::type + >; +TYPED_TEST_SUITE(PCLCropHullTestFixture2dCrutch, CropHullTestTraits2dTypes); + +TYPED_TEST (PCLCropHullTestFixture2dCrutch, test_crop_inside) { for (auto & entry : this->data_) { From 3e6e3110271b8fd952bb342a10906785b1f3ba89 Mon Sep 17 00:00:00 2001 From: Oleg Gubanov Date: Wed, 9 Sep 2020 16:54:13 -0400 Subject: [PATCH 011/431] Add PCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES cmake option --- cmake/pcl_options.cmake | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cmake/pcl_options.cmake b/cmake/pcl_options.cmake index 52b590f974f..13a2c261a66 100644 --- a/cmake/pcl_options.cmake +++ b/cmake/pcl_options.cmake @@ -1,20 +1,33 @@ # Options for building PCL. +# By default, PCL restricts the dependency search to only shared or only static libraries, +# depending on whether PCL itself is built as a shared or static library. +# This restriction is undesirable when a dependency is available +# only as a shared library while building PCL as a static library, or vice versa. +# In such cases, the user may prefer to use the found dependency anyway. +# For example, the user may prefer to build PCL as a static library +# using a shared OpenGL library provided by the system. +# This option allows to override the restriction imposed by default. +option(PCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES, "Do not force PCL dependencies to be all shared or all static." OFF) + # Build shared libraries by default. option(PCL_SHARED_LIBS "Build shared libraries." ON) if(PCL_SHARED_LIBS) set(PCL_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) set(PCL_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) set(PCL_LIB_TYPE "SHARED") -# set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_IMPORT_LIBRARY_SUFFIX}) + if(NOT PCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_IMPORT_LIBRARY_SUFFIX}) + endif() endif() else() set(PCL_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}) set(PCL_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) set(PCL_LIB_TYPE "STATIC") - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + if(NOT PCL_ALLOW_BOTH_SHARED_AND_STATIC_DEPENDENCIES) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + endif() endif() mark_as_advanced(PCL_SHARED_LIBS) From 1d2c4ae3fde73f02441cfd9c1ff90235afc17077 Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Mon, 2 Nov 2020 23:01:54 +0100 Subject: [PATCH 012/431] Refactor cmake find script oft libusb --- CMakeLists.txt | 7 +-- PCLConfig.cmake.in | 14 +----- apps/3d_rec_framework/CMakeLists.txt | 4 -- apps/CMakeLists.txt | 2 +- cmake/Modules/FindOpenNI.cmake | 27 +--------- cmake/Modules/FindOpenNI2.cmake | 27 +--------- cmake/Modules/Findlibusb-1.0.cmake | 72 -------------------------- cmake/Modules/Findlibusb.cmake | 75 ++++++++++++++++++++++++++++ io/CMakeLists.txt | 8 +-- 9 files changed, 88 insertions(+), 148 deletions(-) delete mode 100644 cmake/Modules/Findlibusb-1.0.cmake create mode 100644 cmake/Modules/Findlibusb.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b7e7e63a15e..181f5c13cdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,13 +304,10 @@ if(NOT PCL_SHARED_LIBS OR ((WIN32 AND NOT MINGW) AND NOT PCL_BUILD_WITH_FLANN_DY endif() find_package(FLANN 1.7.0 REQUIRED) -# libusb-1.0 +# libusb option(WITH_LIBUSB "Build USB RGBD-Camera drivers" TRUE) if(WITH_LIBUSB) - find_package(libusb-1.0) - if(LIBUSB_1_FOUND) - include_directories(SYSTEM "${LIBUSB_1_INCLUDE_DIR}") - endif() + find_package(libusb) endif() # Dependencies for different grabbers diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in index 18961730bdd..c615fc793f5 100644 --- a/PCLConfig.cmake.in +++ b/PCLConfig.cmake.in @@ -255,17 +255,7 @@ macro(find_VTK) endmacro() macro(find_libusb) - if(NOT WIN32) - find_path(LIBUSB_1_INCLUDE_DIR - NAMES libusb-1.0/libusb.h - PATHS /usr/include /usr/local/include /opt/local/include /sw/include - PATH_SUFFIXES libusb-1.0) - - find_library(LIBUSB_1_LIBRARY - NAMES usb-1.0 - PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib) - find_package_handle_standard_args(libusb-1.0 LIBUSB_1_LIBRARY LIBUSB_1_INCLUDE_DIR) - endif() + find_package(libusb) endmacro() macro(find_glew) @@ -310,7 +300,7 @@ macro(find_external_library _component _lib _is_optional) find_rssdk2() elseif("${_lib}" STREQUAL "vtk") find_VTK() - elseif("${_lib}" STREQUAL "libusb-1.0") + elseif("${_lib}" STREQUAL "libusb") find_libusb() elseif("${_lib}" STREQUAL "glew") find_glew() diff --git a/apps/3d_rec_framework/CMakeLists.txt b/apps/3d_rec_framework/CMakeLists.txt index ec6c56d8fa7..7cf62687366 100644 --- a/apps/3d_rec_framework/CMakeLists.txt +++ b/apps/3d_rec_framework/CMakeLists.txt @@ -112,10 +112,6 @@ target_link_libraries("${LIB_NAME}" pcl_apps pcl_common pcl_io pcl_filters pcl_v if(WITH_OPENNI) target_link_libraries("${LIB_NAME}" ${OPENNI_LIBRARIES}) - if(NOT WIN32) - find_package(libusb-1.0 REQUIRED) - target_link_libraries("${LIB_NAME}" ${LIBUSB_1_LIBRARIES}) - endif() endif() PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSUBSYS_NAME} DESC ${SUBSUBSYS_DESC}) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 853dac2d8ef..0258864c420 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(pcl_pyramid_surface_matching pcl_common pcl_io pcl_feature PCL_ADD_EXECUTABLE(pcl_statistical_multiscale_interest_region_extraction_example COMPONENT ${SUBSYS_NAME} SOURCES src/statistical_multiscale_interest_region_extraction_example.cpp) target_link_libraries(pcl_statistical_multiscale_interest_region_extraction_example pcl_common pcl_io pcl_features pcl_filters) -if(LIBUSB_1_FOUND) +if(LIBUSB_FOUND) PCL_ADD_EXECUTABLE(pcl_dinast_grabber COMPONENT ${SUBSYS_NAME} SOURCES src/dinast_grabber_example.cpp) target_link_libraries(pcl_dinast_grabber pcl_common pcl_visualization pcl_io) endif() diff --git a/cmake/Modules/FindOpenNI.cmake b/cmake/Modules/FindOpenNI.cmake index 09a6081138a..3a94cdacbcc 100644 --- a/cmake/Modules/FindOpenNI.cmake +++ b/cmake/Modules/FindOpenNI.cmake @@ -11,30 +11,6 @@ # OPENNI_DEFINITIONS Compiler flags for OpenNI find_package(PkgConfig QUIET) - -# Find LibUSB -if(NOT WIN32) - pkg_check_modules(PC_USB_10 libusb-1.0) - find_path(USB_10_INCLUDE_DIR libusb-1.0/libusb.h - HINTS ${PC_USB_10_INCLUDEDIR} ${PC_USB_10_INCLUDE_DIRS} "${USB_10_ROOT}" "$ENV{USB_10_ROOT}" - PATH_SUFFIXES libusb-1.0) - - find_library(USB_10_LIBRARY - NAMES usb-1.0 - HINTS ${PC_USB_10_LIBDIR} ${PC_USB_10_LIBRARY_DIRS} "${USB_10_ROOT}" "$ENV{USB_10_ROOT}" - PATH_SUFFIXES lib) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(USB_10 DEFAULT_MSG USB_10_LIBRARY USB_10_INCLUDE_DIR) - - if(NOT USB_10_FOUND) - message(STATUS "OpenNI disabled because libusb-1.0 not found.") - return() - else() - include_directories(SYSTEM ${USB_10_INCLUDE_DIR}) - endif() -endif() - pkg_check_modules(PC_OPENNI QUIET libopenni) set(OPENNI_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER}) @@ -76,7 +52,8 @@ if(OPENNI_INCLUDE_DIR AND OPENNI_LIBRARY) # Libraries if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(OPENNI_LIBRARIES ${OPENNI_LIBRARY} ${LIBUSB_1_LIBRARIES}) + find_package(libusb REQUIRED) + set(OPENNI_LIBRARIES ${OPENNI_LIBRARY} libusb::libusb) else() set(OPENNI_LIBRARIES ${OPENNI_LIBRARY}) endif() diff --git a/cmake/Modules/FindOpenNI2.cmake b/cmake/Modules/FindOpenNI2.cmake index 10263311293..1e3dc40eadd 100644 --- a/cmake/Modules/FindOpenNI2.cmake +++ b/cmake/Modules/FindOpenNI2.cmake @@ -11,30 +11,6 @@ # OPENNI2_DEFINITIONS Compiler flags for OpenNI2 find_package(PkgConfig QUIET) - -# Find LibUSB -if(NOT WIN32) - pkg_check_modules(PC_USB_10 libusb-1.0) - find_path(USB_10_INCLUDE_DIR libusb-1.0/libusb.h - HINTS ${PC_USB_10_INCLUDEDIR} ${PC_USB_10_INCLUDE_DIRS} "${USB_10_ROOT}" "$ENV{USB_10_ROOT}" - PATH_SUFFIXES libusb-1.0) - - find_library(USB_10_LIBRARY - NAMES usb-1.0 - HINTS ${PC_USB_10_LIBDIR} ${PC_USB_10_LIBRARY_DIRS} "${USB_10_ROOT}" "$ENV{USB_10_ROOT}" - PATH_SUFFIXES lib) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(USB_10 DEFAULT_MSG USB_10_LIBRARY USB_10_INCLUDE_DIR) - - if(NOT USB_10_FOUND) - message(STATUS "OpenNI 2 disabled because libusb-1.0 not found.") - return() - else() - include_directories(SYSTEM ${USB_10_INCLUDE_DIR}) - endif() -endif() - pkg_check_modules(PC_OPENNI2 QUIET libopenni2) set(OPENNI2_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER}) @@ -66,7 +42,8 @@ if(OPENNI2_INCLUDE_DIR AND OPENNI2_LIBRARY) # Libraries if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY} ${LIBUSB_1_LIBRARIES}) + find_package(libusb REQUIRED) + set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY} libusb::libusb) else() set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY}) endif() diff --git a/cmake/Modules/Findlibusb-1.0.cmake b/cmake/Modules/Findlibusb-1.0.cmake deleted file mode 100644 index 564eb8e300e..00000000000 --- a/cmake/Modules/Findlibusb-1.0.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# - Try to find libusb-1.0 -# Once done this will define -# -# LIBUSB_1_FOUND - system has libusb -# LIBUSB_1_INCLUDE_DIRS - the libusb include directory -# LIBUSB_1_LIBRARIES - Link these to use libusb -# LIBUSB_1_DEFINITIONS - Compiler switches required for using libusb -# -# Adapted from cmake-modules Google Code project -# -# Copyright (c) 2006 Andreas Schneider -# -# (Changes for libusb) Copyright (c) 2008 Kyle Machulis -# -# Point Cloud Library (PCL) - www.pointclouds.org -# Copyright (c) 2012, Willow Garage, Inc. (use of FindPackageHandleStandardArgs) -# -# Redistribution and use is allowed according to the terms of the New BSD license. -# -# CMake-Modules Project New BSD License -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of the CMake-Modules Project nor the names of its -# contributors may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -if(LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) - # in cache already - set(LIBUSB_FOUND TRUE) - set(LIBUSB_1_FOUND TRUE) -else() - find_path(LIBUSB_1_INCLUDE_DIR - NAMES libusb-1.0/libusb.h - PATHS /usr/include /usr/local/include /opt/local/include /sw/include - PATH_SUFFIXES libusb-1.0) - - # We need to look for libusb-1.0 too because find_library does not attempt to find - # library files with a "lib" prefix implicitly on Windows - find_library(LIBUSB_1_LIBRARY - NAMES usb-1.0 libusb-1.0 - PATHS /usr/lib /usr/local/lib /opt/local/lib /sw/lib) - - set(LIBUSB_1_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIR}) - set(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(libusb-1.0 DEFAULT_MSG LIBUSB_1_LIBRARY LIBUSB_1_INCLUDE_DIR) - - # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view - mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES) -endif() diff --git a/cmake/Modules/Findlibusb.cmake b/cmake/Modules/Findlibusb.cmake new file mode 100644 index 00000000000..8d4b58a203b --- /dev/null +++ b/cmake/Modules/Findlibusb.cmake @@ -0,0 +1,75 @@ +#.rst: +# Findlibusb +# -------- +# +# Try to find libusb library and headers. +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines the :prop_tgt:`IMPORTED` targets: +# +# ``libusb::libusb`` +# Defined if the system has libusb. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module sets the following variables: +# +# :: +# +# LIBUSB_FOUND True in case libusb is found, otherwise false +# LIBUSB_ROOT Path to the root of found libusb installation +# +# Example usage +# ^^^^^^^^^^^^^ +# +# :: +# +# find_package(libusb REQUIRED) +# +# add_executable(foo foo.cc) +# target_link_libraries(foo libusb::libusb) +# + +# Early return if libusb target is already defined. This makes it safe to run +# this script multiple times. +if(TARGET libusb::libusb) + return() +endif() + +find_package(PkgConfig QUIET) +if(libusb_FIND_VERSION) + pkg_check_modules(PC_LIBUSB libusb-1.0>=${libusb_FIND_VERSION}) +else() + pkg_check_modules(PC_LIBUSB libusb-1.0) +endif() + +if(PC_LIBUSB_FOUND) + set(LIBUSB_INCLUDE_DIR ${PC_LIBUSB_INCLUDEDIR}) + set(LIBUSB_LIBRARIES ${PC_LIBUSB_LIBRARIES}) +else() + find_path(LIBUSB_INCLUDE_DIR + NAMES + libusb-1.0/libusb.h + ) + find_library(LIBUSB_LIBRARIES + NAMES + usb-1.0 + libusb + ) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR) + +mark_as_advanced(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) + +if(LIBUSB_FOUND) + add_library(libusb::libusb INTERFACE IMPORTED) + set_target_properties(libusb::libusb PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}") + set_target_properties(libusb::libusb PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${PC_LIBUSB_CFLAGS_OTHER}") + set_target_properties(libusb::libusb PROPERTIES INTERFACE_LINK_OPTIONS "${PC_LIBUSB_LDFLAGS_OTHER}") + set_target_properties(libusb::libusb PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBUSB_LIBRARIES}") +endif() diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt index 4c90e312221..bb88357d5af 100644 --- a/io/CMakeLists.txt +++ b/io/CMakeLists.txt @@ -7,7 +7,7 @@ PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON) if(WIN32) PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk rssdk rssdk2 pcap png vtk) else() - PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk pcap png vtk libusb-1.0) + PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk pcap png vtk libusb) endif() PCL_ADD_DOC("${SUBSYS_NAME}") @@ -169,7 +169,7 @@ if(WITH_RSSDK2) ) endif() -if(LIBUSB_1_FOUND) +if(LIBUSB_FOUND) set(DINAST_GRABBER_INCLUDES include/pcl/io/dinast_grabber.h ) @@ -337,8 +337,8 @@ if(PNG_FOUND) target_link_libraries("${LIB_NAME}" ${PNG_LIBRARIES}) endif() -if(LIBUSB_1_FOUND) - target_link_libraries("${LIB_NAME}" ${LIBUSB_1_LIBRARIES}) +if(LIBUSB_FOUND) + target_link_libraries("${LIB_NAME}" libusb::libusb) endif() if(WITH_OPENNI2) From ef7fbea3b7e45cc2ee995bc7bf82583bdea0c8cc Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Fri, 20 Nov 2020 16:23:33 +0000 Subject: [PATCH 013/431] Added fuzzer --- test/fuzz/read_fuzzer.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/fuzz/read_fuzzer.cc diff --git a/test/fuzz/read_fuzzer.cc b/test/fuzz/read_fuzzer.cc new file mode 100644 index 00000000000..300f6b68f40 --- /dev/null +++ b/test/fuzz/read_fuzzer.cc @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + pcl::PCLPointCloud2 cloud_blob, cloud_blob2; + pcl::PLYReader reader; + char filename[256]; + sprintf(filename, "/tmp/libfuzzer.%d", getpid()); + + FILE *fp = fopen(filename, "wb"); + if (!fp) + return 0; + fwrite(data, size, 1, fp); + fclose(fp); + + reader.read (filename, cloud_blob2); + unlink(filename); + return 0; +} From 0c259cf795a2402df67ed504eee95ad0e86f6b88 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 24 Nov 2020 11:10:06 +0000 Subject: [PATCH 014/431] Added build.sh and Dockerfile from oss-fuzz --- test/fuzz/Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++++++ test/fuzz/build.sh | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 test/fuzz/Dockerfile create mode 100644 test/fuzz/build.sh diff --git a/test/fuzz/Dockerfile b/test/fuzz/Dockerfile new file mode 100644 index 00000000000..763648123c0 --- /dev/null +++ b/test/fuzz/Dockerfile @@ -0,0 +1,47 @@ +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +RUN apt-get update && apt-get install -y make cmake autoconf \ + automake libtool gettext pkg-config build-essential \ + mercurial wget libeigen3-dev libflann-dev python python-dev + +# VTK deps +RUN apt-get update && apt-get install -y \ + libavcodec-dev libavformat-dev libavutil-dev libboost-dev \ + libdouble-conversion-dev libeigen3-dev libexpat1-dev \ + libfontconfig-dev libfreetype6-dev libgdal-dev libglew-dev \ + libhdf5-dev libjpeg-dev libjsoncpp-dev liblz4-dev liblzma-dev \ + libnetcdf-dev libnetcdf-cxx-legacy-dev libogg-dev libpng-dev \ + libpython3-dev libqt5opengl5-dev libqt5x11extras5-dev libsqlite3-dev \ + libswscale-dev libtheora-dev libtiff-dev libxml2-dev libxt-dev \ + qtbase5-dev qttools5-dev zlib1g-dev + +# Install and build boost from source so we can have it use libc++ +RUN wget https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz && \ + tar xzf boost_1_70_0.tar.gz && \ + cd boost_1_70_0 && \ + ./bootstrap.sh --with-toolset=clang && \ + ./b2 clean && \ + ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" -j$(nproc) install && \ + cd .. && \ + rm -rf boost_1_70_0] + + +RUN git clone --depth 1 https://github.com/PointCloudLibrary/pcl + +WORKDIR $SRC/ +COPY build.sh $SRC/ diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh new file mode 100644 index 00000000000..494abe13e4a --- /dev/null +++ b/test/fuzz/build.sh @@ -0,0 +1,38 @@ +#!/bin/bash -eu +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# Build PCL +cd pcl +mkdir build && cd build +cmake -DWITH_OPENGL=FALSE -DWITH_PCAP=FALSE \ + -DWITH_VTK=FALSE -DPCL_SHARED_LIBS:BOOL=OFF .. +make + +# Build fuzzers +cd ../test/fuzz + +$CXX $CXXFLAGS -DPCLAPI_EXPORTS \ + -I/src/pcl/build/include -I/src/pcl/common/include \ + -I/src/pcl/dssdk/include \ + -I/src/pcl/io/include -isystem /usr/include/eigen3 \ + -O2 -g -DNDEBUG -fPIC -std=c++14 \ + -o read_fuzzer.o -c read_fuzzer.cc + +$CXX $CXXFLAGS $LIB_FUZZING_ENGINE read_fuzzer.o \ + ../../build/lib/libpcl_io.a ../../build/lib/libpcl_io_ply.a \ + ../../build/lib/libpcl_common.a \ + /usr/local/lib/libboost_filesystem.a -o $OUT/read_fuzzer -lm From 7e3529db04bf6986184c748901b4995f38650f59 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 24 Nov 2020 11:46:26 +0000 Subject: [PATCH 015/431] Changed license headers --- test/fuzz/Dockerfile | 15 ++++----------- test/fuzz/build.sh | 16 +++++----------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/test/fuzz/Dockerfile b/test/fuzz/Dockerfile index 763648123c0..28fad3958b4 100644 --- a/test/fuzz/Dockerfile +++ b/test/fuzz/Dockerfile @@ -1,18 +1,11 @@ -# Copyright 2020 Google Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# SPDX-License-Identifier: BSD-3-Clause # -# http://www.apache.org/licenses/LICENSE-2.0 +# Point Cloud Library (PCL) - www.pointclouds.org +# Copyright (c) 2020-, Open Perception # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# All rights reserved # -################################################################################ FROM gcr.io/oss-fuzz-base/base-builder RUN apt-get update && apt-get install -y make cmake autoconf \ diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index 494abe13e4a..43bb2e48087 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -1,19 +1,13 @@ #!/bin/bash -eu -# Copyright 2020 Google Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# SPDX-License-Identifier: BSD-3-Clause # -# http://www.apache.org/licenses/LICENSE-2.0 +# Point Cloud Library (PCL) - www.pointclouds.org +# Copyright (c) 2020-, Open Perception # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# All rights reserved # -################################################################################ + # Build PCL cd pcl From 583b50cfdb551ced374cc5cbcfb41f1bad230560 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 30 Nov 2020 10:27:49 -0800 Subject: [PATCH 016/431] Add unit test for VoxelGrid setMinimumPointsNumberPerVoxel --- test/filters/test_filters.cpp | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/test/filters/test_filters.cpp b/test/filters/test_filters.cpp index 114a96f9c90..28025d4231a 100644 --- a/test/filters/test_filters.cpp +++ b/test/filters/test_filters.cpp @@ -1326,6 +1326,107 @@ TEST (VoxelGridCovariance, Filters) EXPECT_NEAR (leaves[2]->getMean ()[2], 0.0508024, 1e-4); } +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +TEST (VoxelGridMinPoints, Filters) +{ + // Setup input with 4 clusters, single point at 0,0,0 and 1,1,1 with 5 point cluster around 0.11,0.11,0.11 and 6 point cluster around 0.31,0.31,0.31 + PointCloud::Ptr input(new PointCloud()); + + input->emplace_back(0.0f, 0.0f, 0.0f); + std::vector offsets {0.001, 0.002, 0.003, -0.001, -0.002, -0.003}; + for (unsigned int i=0; i<5; ++i) { + input->emplace_back(0.11f+offsets[i], 0.11f+offsets[i], 0.11f+offsets[i],200,0,0); + input->emplace_back(0.31f+offsets[i], 0.31f+offsets[i], 0.31f+offsets[i],0,127,127); + } + input->emplace_back(0.31f+offsets[5], 0.31f+offsets[5], 0.31f+offsets[5],0,127,127); + input->emplace_back(1.0f, 1.0f, 1.0f); + + // Test the PointCloud VoxelGrid filter method + PointCloud outputMin4; + VoxelGrid grid; + // Run filter on input with MinimumPoints threshold at 4 + grid.setLeafSize (0.02f, 0.02f, 0.02f); + grid.setInputCloud (input); + grid.setMinimumPointsNumberPerVoxel(4); + grid.setDownsampleAllData(true); + grid.filter (outputMin4); + + // Verify 2 clusters (0.11 and 0.31) passed threshold and verify their location and color + EXPECT_EQ (outputMin4.size (), 2); + // Offset noise applied by offsets vec are 1e-3 magnitude, so check within 1e-2 + EXPECT_NEAR (outputMin4[0].x, input->at(1).x, 1e-2); + EXPECT_NEAR (outputMin4[0].y, input->at(1).y, 1e-2); + EXPECT_NEAR (outputMin4[0].z, input->at(1).z, 1e-2); + EXPECT_NEAR (outputMin4[0].r, input->at(1).r, 1); + + EXPECT_NEAR (outputMin4[1].x, input->at(2).x, 1e-2); + EXPECT_NEAR (outputMin4[1].y, input->at(2).y, 1e-2); + EXPECT_NEAR (outputMin4[1].z, input->at(2).z, 1e-2); + EXPECT_NEAR (outputMin4[1].g, input->at(2).g, 1); + EXPECT_NEAR (outputMin4[1].b, input->at(2).b, 1); + + // Run filter again on input with MinimumPoints threshold at 6 + PointCloud outputMin6; + grid.setMinimumPointsNumberPerVoxel(6); + grid.setDownsampleAllData(false); + grid.filter (outputMin6); + + // Verify 1 cluster (0.31) passed threshold and verify location + EXPECT_EQ (outputMin6.size (), 1); + + EXPECT_NEAR (outputMin6[0].x, input->at(2).x, 1e-2); + EXPECT_NEAR (outputMin6[0].y, input->at(2).y, 1e-2); + EXPECT_NEAR (outputMin6[0].z, input->at(2).z, 1e-2); + + // Test the pcl::PCLPointCloud2 VoxelGrid filter method + PCLPointCloud2 output_pc2; + VoxelGrid grid_pc2; + PCLPointCloud2::Ptr input_pc2(new PCLPointCloud2()); + + // Use same input as above converted to PCLPointCloud2 + toPCLPointCloud2(*input, *input_pc2); + + // Run filter on input with MinimumPoints threshold at 4 + grid_pc2.setLeafSize (0.02f, 0.02f, 0.02f); + grid_pc2.setInputCloud (input_pc2); + grid_pc2.setMinimumPointsNumberPerVoxel(4); + grid_pc2.setDownsampleAllData(true); + grid_pc2.filter (output_pc2); + + // Convert back to PointXYZRGB for easier data access + PointCloud::Ptr out_pc( new pcl::PointCloud ); + pcl::fromPCLPointCloud2( output_pc2, *out_pc ); + + // Verify 2 clusters (0.11 and 0.31) passed threshold and verify their location and color + // PCLPointCloud2 output should be same as PointCloudXYZRGB, account for floating point rounding error with 1e-4 + EXPECT_EQ (out_pc->points.size (), outputMin4.size()); + + EXPECT_NEAR (out_pc->at(0).x, outputMin4[0].x, 1e-4); + EXPECT_NEAR (out_pc->at(0).y, outputMin4[0].y, 1e-4); + EXPECT_NEAR (out_pc->at(0).z, outputMin4[0].z, 1e-4); + EXPECT_NEAR (out_pc->at(0).r, outputMin4[0].r, 1); + + EXPECT_NEAR (out_pc->at(1).x, outputMin4[1].x, 1e-4); + EXPECT_NEAR (out_pc->at(1).y, outputMin4[1].y, 1e-4); + EXPECT_NEAR (out_pc->at(1).z, outputMin4[1].z, 1e-4); + EXPECT_NEAR (out_pc->at(1).g, outputMin4[1].g, 1); + EXPECT_NEAR (out_pc->at(1).b, outputMin4[1].b, 1); + + // Run filter again on input with MinimumPoints threshold at 6 + grid_pc2.setMinimumPointsNumberPerVoxel(6); + grid_pc2.setDownsampleAllData(false); + grid_pc2.filter (output_pc2); + + // Convert back to PointXYZRGB for easier data access + pcl::fromPCLPointCloud2( output_pc2, *out_pc ); + + // Verify 1 cluster (0.31) passed threshold and verify location + EXPECT_EQ (out_pc->points.size (), outputMin6.size()); + + EXPECT_NEAR (out_pc->at(0).x, outputMin6[0].x, 1e-4); + EXPECT_NEAR (out_pc->at(0).y, outputMin6[0].y, 1e-4); + EXPECT_NEAR (out_pc->at(0).z, outputMin6[0].z, 1e-4); +} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TEST (ProjectInliers, Filters) { From 7a7210dd77e21209829b85fe5d01c987dd5fccdb Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 30 Nov 2020 10:28:54 -0800 Subject: [PATCH 017/431] Fix VoxelGrid to apply setMinimumPointsNumberPerVoxel threshold --- filters/src/voxel_grid.cpp | 124 ++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 70 deletions(-) diff --git a/filters/src/voxel_grid.cpp b/filters/src/voxel_grid.cpp index 7ad23fa7416..7e1726a8a2e 100644 --- a/filters/src/voxel_grid.cpp +++ b/filters/src/voxel_grid.cpp @@ -42,6 +42,7 @@ #include #include #include +#include using Array4size_t = Eigen::Array; @@ -385,12 +386,22 @@ pcl::VoxelGrid::applyFilter (PCLPointCloud2 &output) // we need to skip all the same, adjacenent idx values std::size_t total = 0; std::size_t index = 0; + // first_and_last_indices_vector[i] represents the index in index_vector of the first point in + // index_vector belonging to the voxel which corresponds to the i-th output point, + // and of the first point not belonging to. + std::vector > first_and_last_indices_vector; + // Worst case size + first_and_last_indices_vector.reserve (index_vector.size ()); while (index < index_vector.size ()) { std::size_t i = index + 1; while (i < index_vector.size () && index_vector[i].idx == index_vector[index].idx) ++i; - ++total; + if ((i - index) >= min_points_per_voxel_) + { + ++total; + first_and_last_indices_vector.emplace_back(index, i); + } index = i; } @@ -436,93 +447,66 @@ pcl::VoxelGrid::applyFilter (PCLPointCloud2 &output) xyz_offset = Array4size_t (0, 4, 8, 12); index=0; - Eigen::VectorXf centroid = Eigen::VectorXf::Zero (centroid_size); Eigen::VectorXf temporary = Eigen::VectorXf::Zero (centroid_size); + const std::array field_indices {x_idx_, y_idx_, z_idx_}; - for (std::size_t cp = 0; cp < index_vector.size ();) + for (const auto &cp : first_and_last_indices_vector) { - std::size_t point_offset = index_vector[cp].cloud_point_index * input_->point_step; - // Do we need to process all the fields? - if (!downsample_all_data_) - { - memcpy (&pt[0], &input_->data[point_offset+input_->fields[x_idx_].offset], sizeof (float)); - memcpy (&pt[1], &input_->data[point_offset+input_->fields[y_idx_].offset], sizeof (float)); - memcpy (&pt[2], &input_->data[point_offset+input_->fields[z_idx_].offset], sizeof (float)); - centroid[0] = pt[0]; - centroid[1] = pt[1]; - centroid[2] = pt[2]; - centroid[3] = 0; - } - else + // calculate centroid - sum values from all input points, that have the same idx value in index_vector array + index_t first_index = cp.first; + index_t last_index = cp.second; + + // index is centroid final position in resulting PointCloud + if (save_leaf_layout_) + leaf_layout_[index_vector[first_index].idx] = index; + + //Limit downsampling to coords + if (!downsample_all_data_) { - // ---[ RGB special case - // fill extra r/g/b centroid field - if (rgba_index >= 0) + Eigen::Vector4f centroid (Eigen::Vector4f::Zero ()); + + for (index_t li = first_index; li < last_index; ++li) { - pcl::RGB rgb; - memcpy (&rgb, &input_->data[point_offset + input_->fields[rgba_index].offset], sizeof (RGB)); - centroid[centroid_size-4] = rgb.r; - centroid[centroid_size-3] = rgb.g; - centroid[centroid_size-2] = rgb.b; - centroid[centroid_size-1] = rgb.a; + std::size_t point_offset = index_vector[li].cloud_point_index * input_->point_step; + for (uint8_t ind=0; ind<3; ++ind) + { + memcpy (&pt[ind], &input_->data[point_offset+input_->fields[field_indices[ind]].offset], sizeof (float)); + } + centroid += pt; } - // Copy all the fields - for (std::size_t d = 0; d < input_->fields.size (); ++d) - memcpy (¢roid[d], &input_->data[point_offset + input_->fields[d].offset], field_sizes_[d]); - } - std::size_t i = cp + 1; - while (i < index_vector.size () && index_vector[i].idx == index_vector[cp].idx) - { - std::size_t point_offset = index_vector[i].cloud_point_index * input_->point_step; - if (!downsample_all_data_) + centroid /= static_cast (last_index - first_index); + for (uint8_t ind=0; ind<3; ++ind) { - memcpy (&pt[0], &input_->data[point_offset+input_->fields[x_idx_].offset], sizeof (float)); - memcpy (&pt[1], &input_->data[point_offset+input_->fields[y_idx_].offset], sizeof (float)); - memcpy (&pt[2], &input_->data[point_offset+input_->fields[z_idx_].offset], sizeof (float)); - centroid[0] += pt[0]; - centroid[1] += pt[1]; - centroid[2] += pt[2]; + memcpy (&output.data[xyz_offset[ind]], ¢roid[ind], sizeof (float)); } - else - { + xyz_offset += output.point_step; + } + else + { + + Eigen::VectorXf centroid = Eigen::VectorXf::Zero (centroid_size); + // fill in the accumulator with leaf points + for (index_t li = first_index; li < last_index; ++li) { + std::size_t point_offset = index_vector[li].cloud_point_index * input_->point_step; // ---[ RGB special case // fill extra r/g/b centroid field if (rgba_index >= 0) { - pcl::RGB rgb; - memcpy (&rgb, &input_->data[point_offset + input_->fields[rgba_index].offset], sizeof (RGB)); - temporary[centroid_size-4] = rgb.r; - temporary[centroid_size-3] = rgb.g; - temporary[centroid_size-2] = rgb.b; - temporary[centroid_size-1] = rgb.a; + pcl::RGB rgb; + memcpy (&rgb, &input_->data[point_offset + input_->fields[rgba_index].offset], sizeof (RGB)); + temporary[centroid_size-4] = rgb.r; + temporary[centroid_size-3] = rgb.g; + temporary[centroid_size-2] = rgb.b; + temporary[centroid_size-1] = rgb.a; } // Copy all the fields for (std::size_t d = 0; d < input_->fields.size (); ++d) memcpy (&temporary[d], &input_->data[point_offset + input_->fields[d].offset], field_sizes_[d]); centroid += temporary; } - ++i; - } - - // Save leaf layout information for fast access to cells relative to current position - if (save_leaf_layout_) - leaf_layout_[index_vector[cp].idx] = static_cast (index); - - // Normalize the centroid - centroid /= static_cast (i - cp); - - // Do we need to process all the fields? - if (!downsample_all_data_) - { - // Copy the data - memcpy (&output.data[xyz_offset[0]], ¢roid[0], sizeof (float)); - memcpy (&output.data[xyz_offset[1]], ¢roid[1], sizeof (float)); - memcpy (&output.data[xyz_offset[2]], ¢roid[2], sizeof (float)); - xyz_offset += output.point_step; - } - else - { + centroid /= static_cast (last_index - first_index); + std::size_t point_offset = index * output.point_step; // Copy all the fields for (std::size_t d = 0; d < output.fields.size (); ++d) @@ -537,7 +521,7 @@ pcl::VoxelGrid::applyFilter (PCLPointCloud2 &output) memcpy (&output.data[point_offset + output.fields[rgba_index].offset], &rgb, sizeof (float)); } } - cp = i; + ++index; } } From 3e36075bea07f777dda601ab4b06a2f3fa0f2d56 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 8 Dec 2020 16:39:37 +0000 Subject: [PATCH 018/431] Removed installation of non-needed modules --- test/fuzz/build.sh | 47 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index 43bb2e48087..9550afa0813 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -1,20 +1,53 @@ #!/bin/bash -eu +# Copyright 2018 Google Inc. # -# SPDX-License-Identifier: BSD-3-Clause +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# Point Cloud Library (PCL) - www.pointclouds.org -# Copyright (c) 2020-, Open Perception +# http://www.apache.org/licenses/LICENSE-2.0 # -# All rights reserved +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # +################################################################################ +mkdir pcl/test/fuzz +cp $SRC/read_fuzzer.cc pcl/test/fuzz/ # Build PCL cd pcl mkdir build && cd build -cmake -DWITH_OPENGL=FALSE -DWITH_PCAP=FALSE \ - -DWITH_VTK=FALSE -DPCL_SHARED_LIBS:BOOL=OFF .. -make +pwd +cmake -DWITH_OPENGL=FALSE \ + -DWITH_PCAP=FALSE \ + -DWITH_VTK=FALSE \ + -DPCL_SHARED_LIBS:BOOL=OFF \ + -DWITH_LIBUSB=FALSE \ + -DWITH_QT=FALSE \ + -DBUILD_features=OFF \ + -DBUILD_filters=OFF \ + -DBUILD_geometry=OFF \ + -DBUILD_kdtree=OFF \ + -DBUILD_keypoints=OFF \ + -DBUILD_ml=OFF \ + -DBUILD_outofcore=OFF \ + -DBUILD_people=OFF \ + -DBUILD_recognition=OFF \ + -DBUILD_registration=OFF \ + -DBUILD_sample_consensus=OFF \ + -DBUILD_search=OFF \ + -DBUILD_segmentation=OFF \ + -DBUILD_stereo=OFF \ + -DBUILD_surface=OFF \ + -DBUILD_tracking=OFF \ + -DBUILD_visualization=OFF \ + .. + +make -j$(nproc) # Build fuzzers cd ../test/fuzz From 980843b85bcc725f8d12fac6e6964d5877e89ba5 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 8 Dec 2020 16:43:53 +0000 Subject: [PATCH 019/431] Refactoring --- test/fuzz/build.sh | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index 9550afa0813..a8ec1163a71 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -1,22 +1,11 @@ -#!/bin/bash -eu -# Copyright 2018 Google Inc. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# SPDX-License-Identifier: BSD-3-Clause # -# http://www.apache.org/licenses/LICENSE-2.0 +# Point Cloud Library (PCL) - www.pointclouds.org +# Copyright (c) 2020-, Open Perception # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# All rights reserved # -################################################################################ - -mkdir pcl/test/fuzz -cp $SRC/read_fuzzer.cc pcl/test/fuzz/ # Build PCL cd pcl From d48dc64ac9cf473112abde20f6ad14b65558dfda Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 8 Dec 2020 16:50:57 +0000 Subject: [PATCH 020/431] Changed fuzzer from .cc to .cpp --- test/fuzz/build.sh | 3 ++- test/fuzz/{read_fuzzer.cc => read_fuzzer.cpp} | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename test/fuzz/{read_fuzzer.cc => read_fuzzer.cpp} (100%) diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index a8ec1163a71..da5325c04e7 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -1,3 +1,4 @@ +#!/bin/bash -eu # # SPDX-License-Identifier: BSD-3-Clause # @@ -46,7 +47,7 @@ $CXX $CXXFLAGS -DPCLAPI_EXPORTS \ -I/src/pcl/dssdk/include \ -I/src/pcl/io/include -isystem /usr/include/eigen3 \ -O2 -g -DNDEBUG -fPIC -std=c++14 \ - -o read_fuzzer.o -c read_fuzzer.cc + -o read_fuzzer.o -c read_fuzzer.cpp $CXX $CXXFLAGS $LIB_FUZZING_ENGINE read_fuzzer.o \ ../../build/lib/libpcl_io.a ../../build/lib/libpcl_io_ply.a \ diff --git a/test/fuzz/read_fuzzer.cc b/test/fuzz/read_fuzzer.cpp similarity index 100% rename from test/fuzz/read_fuzzer.cc rename to test/fuzz/read_fuzzer.cpp From aad573c4f99f1c1d05deee403763abc37a1f08ad Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 8 Dec 2020 17:03:50 +0000 Subject: [PATCH 021/431] Added seed corpus for fuzzer --- test/fuzz/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index da5325c04e7..bdd3d067e7d 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -53,3 +53,5 @@ $CXX $CXXFLAGS $LIB_FUZZING_ENGINE read_fuzzer.o \ ../../build/lib/libpcl_io.a ../../build/lib/libpcl_io_ply.a \ ../../build/lib/libpcl_common.a \ /usr/local/lib/libboost_filesystem.a -o $OUT/read_fuzzer -lm + +zip $OUT/read_fuzzer_seed_corpus.zip $SRC/pcl/test/cube.ply From d77f0e7684dfd2ad45a7ff9ba12d765653911ba0 Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Tue, 8 Dec 2020 17:09:47 +0000 Subject: [PATCH 022/431] Removed Dockerfile. Should be placed on OSS-fuzz's repo --- test/fuzz/Dockerfile | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 test/fuzz/Dockerfile diff --git a/test/fuzz/Dockerfile b/test/fuzz/Dockerfile deleted file mode 100644 index 28fad3958b4..00000000000 --- a/test/fuzz/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Point Cloud Library (PCL) - www.pointclouds.org -# Copyright (c) 2020-, Open Perception -# -# All rights reserved -# - -FROM gcr.io/oss-fuzz-base/base-builder -RUN apt-get update && apt-get install -y make cmake autoconf \ - automake libtool gettext pkg-config build-essential \ - mercurial wget libeigen3-dev libflann-dev python python-dev - -# VTK deps -RUN apt-get update && apt-get install -y \ - libavcodec-dev libavformat-dev libavutil-dev libboost-dev \ - libdouble-conversion-dev libeigen3-dev libexpat1-dev \ - libfontconfig-dev libfreetype6-dev libgdal-dev libglew-dev \ - libhdf5-dev libjpeg-dev libjsoncpp-dev liblz4-dev liblzma-dev \ - libnetcdf-dev libnetcdf-cxx-legacy-dev libogg-dev libpng-dev \ - libpython3-dev libqt5opengl5-dev libqt5x11extras5-dev libsqlite3-dev \ - libswscale-dev libtheora-dev libtiff-dev libxml2-dev libxt-dev \ - qtbase5-dev qttools5-dev zlib1g-dev - -# Install and build boost from source so we can have it use libc++ -RUN wget https://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz && \ - tar xzf boost_1_70_0.tar.gz && \ - cd boost_1_70_0 && \ - ./bootstrap.sh --with-toolset=clang && \ - ./b2 clean && \ - ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" -j$(nproc) install && \ - cd .. && \ - rm -rf boost_1_70_0] - - -RUN git clone --depth 1 https://github.com/PointCloudLibrary/pcl - -WORKDIR $SRC/ -COPY build.sh $SRC/ From 5423526330501ed35ece7a382cccb5908a0c7c1d Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Mon, 14 Dec 2020 11:21:35 +0000 Subject: [PATCH 023/431] Changed name of fuzzer --- test/fuzz/build.sh | 8 ++++---- test/fuzz/{read_fuzzer.cpp => ply_reader_fuzzer.cpp} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename test/fuzz/{read_fuzzer.cpp => ply_reader_fuzzer.cpp} (100%) diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index bdd3d067e7d..5e40eabd8a4 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -47,11 +47,11 @@ $CXX $CXXFLAGS -DPCLAPI_EXPORTS \ -I/src/pcl/dssdk/include \ -I/src/pcl/io/include -isystem /usr/include/eigen3 \ -O2 -g -DNDEBUG -fPIC -std=c++14 \ - -o read_fuzzer.o -c read_fuzzer.cpp + -o ply_reader_fuzzer.o -c ply_reader_fuzzer.cpp -$CXX $CXXFLAGS $LIB_FUZZING_ENGINE read_fuzzer.o \ +$CXX $CXXFLAGS $LIB_FUZZING_ENGINE ply_reader_fuzzer.o \ ../../build/lib/libpcl_io.a ../../build/lib/libpcl_io_ply.a \ ../../build/lib/libpcl_common.a \ - /usr/local/lib/libboost_filesystem.a -o $OUT/read_fuzzer -lm + /usr/local/lib/libboost_filesystem.a -o $OUT/ply_reader_fuzzer -lm -zip $OUT/read_fuzzer_seed_corpus.zip $SRC/pcl/test/cube.ply +zip $OUT/ply_reader_fuzzer_seed_corpus.zip $SRC/pcl/test/cube.ply diff --git a/test/fuzz/read_fuzzer.cpp b/test/fuzz/ply_reader_fuzzer.cpp similarity index 100% rename from test/fuzz/read_fuzzer.cpp rename to test/fuzz/ply_reader_fuzzer.cpp From 928d47f0a744b0e9b3c9447fe978e1c91f4ee5bb Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Mon, 14 Dec 2020 11:29:34 +0000 Subject: [PATCH 024/431] Added minor documentation in build.sh --- test/fuzz/build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/fuzz/build.sh b/test/fuzz/build.sh index 5e40eabd8a4..747809f7e7e 100644 --- a/test/fuzz/build.sh +++ b/test/fuzz/build.sh @@ -8,6 +8,14 @@ # All rights reserved # +# This script is run inside OSS-fuzz's docker image +# and builds PCL's fuzzers to run continuously +# through OSS-fuzz. +# In the OSS-fuzz docker image PCL is located at $SRC/pcl. + +# The Dockerfile that builds PCL can be found here: +# (url pending) + # Build PCL cd pcl mkdir build && cd build From 7b1e3557b6099a331bd77843ecfae08c36979cfb Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Mon, 14 Dec 2020 11:30:46 +0000 Subject: [PATCH 025/431] removed unused cloud_blob --- test/fuzz/ply_reader_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzz/ply_reader_fuzzer.cpp b/test/fuzz/ply_reader_fuzzer.cpp index 300f6b68f40..d30cdc86e54 100644 --- a/test/fuzz/ply_reader_fuzzer.cpp +++ b/test/fuzz/ply_reader_fuzzer.cpp @@ -6,7 +6,7 @@ #include extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - pcl::PCLPointCloud2 cloud_blob, cloud_blob2; + pcl::PCLPointCloud2 cloud_blob; pcl::PLYReader reader; char filename[256]; sprintf(filename, "/tmp/libfuzzer.%d", getpid()); @@ -17,7 +17,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { fwrite(data, size, 1, fp); fclose(fp); - reader.read (filename, cloud_blob2); + reader.read (filename, cloud_blob); unlink(filename); return 0; } From 8af2f4d41a51d26fb43b3dde9a0aac8da86ca664 Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Mon, 21 Dec 2020 20:23:58 +0100 Subject: [PATCH 026/431] Use UNKNOWN IMPORTED instead of INTERFACE IMPORTED, as we targeting to a artifact in case we get values not from PkgConfig. Therefore PkgConfig is only used to get a hint where to find libusb, but ignoring compiler flags. --- cmake/Modules/Findlibusb.cmake | 44 ++++++++++++++++------------------ 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/cmake/Modules/Findlibusb.cmake b/cmake/Modules/Findlibusb.cmake index 8d4b58a203b..90277400000 100644 --- a/cmake/Modules/Findlibusb.cmake +++ b/cmake/Modules/Findlibusb.cmake @@ -41,35 +41,33 @@ endif() find_package(PkgConfig QUIET) if(libusb_FIND_VERSION) - pkg_check_modules(PC_LIBUSB libusb-1.0>=${libusb_FIND_VERSION}) + pkg_check_modules(PC_libusb libusb-1.0>=${libusb_FIND_VERSION}) else() - pkg_check_modules(PC_LIBUSB libusb-1.0) + pkg_check_modules(PC_libusb libusb-1.0) endif() -if(PC_LIBUSB_FOUND) - set(LIBUSB_INCLUDE_DIR ${PC_LIBUSB_INCLUDEDIR}) - set(LIBUSB_LIBRARIES ${PC_LIBUSB_LIBRARIES}) -else() - find_path(LIBUSB_INCLUDE_DIR - NAMES - libusb-1.0/libusb.h - ) - find_library(LIBUSB_LIBRARIES - NAMES - usb-1.0 - libusb - ) -endif() +find_path(libusb_INCLUDE_DIR + NAMES + libusb-1.0/libusb.h + PATHS + ${PC_libusb_INCLUDEDIR} +) + +find_library(libusb_LIBRARIES + NAMES + usb-1.0 + libusb + PATHS + ${PC_libusb_LIBRARY_DIRS} +) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR) +find_package_handle_standard_args(libusb DEFAULT_MSG libusb_LIBRARIES libusb_INCLUDE_DIR) -mark_as_advanced(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) +mark_as_advanced(libusb_INCLUDE_DIRS libusb_LIBRARIES) if(LIBUSB_FOUND) - add_library(libusb::libusb INTERFACE IMPORTED) - set_target_properties(libusb::libusb PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}") - set_target_properties(libusb::libusb PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${PC_LIBUSB_CFLAGS_OTHER}") - set_target_properties(libusb::libusb PROPERTIES INTERFACE_LINK_OPTIONS "${PC_LIBUSB_LDFLAGS_OTHER}") - set_target_properties(libusb::libusb PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBUSB_LIBRARIES}") + add_library(libusb::libusb UNKNOWN IMPORTED) + set_target_properties(libusb::libusb PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${libusb_INCLUDE_DIR}") + set_target_properties(libusb::libusb PROPERTIES IMPORTED_LOCATION "${libusb_LIBRARIES}") endif() From 265772392ee937a242b0c023cfa77880df4d2e08 Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Tue, 29 Dec 2020 00:34:37 +0100 Subject: [PATCH 027/431] [CMake] Parse version of OpenNI(2) --- cmake/Modules/FindOpenNI.cmake | 14 +++++++++++++- cmake/Modules/FindOpenNI2.cmake | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindOpenNI.cmake b/cmake/Modules/FindOpenNI.cmake index 09a6081138a..042cb2d15b9 100644 --- a/cmake/Modules/FindOpenNI.cmake +++ b/cmake/Modules/FindOpenNI.cmake @@ -85,12 +85,24 @@ if(OPENNI_INCLUDE_DIR AND OPENNI_LIBRARY) endif() +if(EXISTS "${OPENNI_INCLUDE_DIR}/XnVersion.h") + file(STRINGS "${OPENNI_INCLUDE_DIR}/XnVersion.h" _contents REGEX "^#define[ \t]+XN_[A-Z]+_VERSION[ \t]+[0-9]+") + if(_contents) + string(REGEX REPLACE ".*#define[ \t]+XN_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" OPENNI_VERSION_MAJOR "${_contents}") + string(REGEX REPLACE ".*#define[ \t]+XN_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" OPENNI_VERSION_MINOR "${_contents}") + string(REGEX REPLACE ".*#define[ \t]+XN_MAINTENANCE_VERSION[ \t]+([0-9]+).*" "\\1" OPENNI_VERSION_PATCH "${_contents}") + string(REGEX REPLACE ".*#define[ \t]+XN_BUILD_VERSION[ \t]+([0-9]+).*" "\\1" OPENNI_VERSION_BUILD "${_contents}") + set(OPENNI_VERSION "${OPENNI_VERSION_MAJOR}.${OPENNI_VERSION_MINOR}.${OPENNI_VERSION_PATCH}.${OPENNI_VERSION_BUILD}") + endif() +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(OpenNI FOUND_VAR OPENNI_FOUND REQUIRED_VARS OPENNI_LIBRARIES OPENNI_INCLUDE_DIRS + VERSION_VAR OPENNI_VERSION ) if(OPENNI_FOUND) - message(STATUS "OpenNI found (include: ${OPENNI_INCLUDE_DIRS}, lib: ${OPENNI_LIBRARIES})") + message(STATUS "OpenNI found (version: ${OPENNI_VERSION}, include: ${OPENNI_INCLUDE_DIRS}, lib: ${OPENNI_LIBRARIES})") endif() diff --git a/cmake/Modules/FindOpenNI2.cmake b/cmake/Modules/FindOpenNI2.cmake index 10263311293..e1adc40f17d 100644 --- a/cmake/Modules/FindOpenNI2.cmake +++ b/cmake/Modules/FindOpenNI2.cmake @@ -78,12 +78,24 @@ if(OPENNI2_INCLUDE_DIR AND OPENNI2_LIBRARY) endif() +if(EXISTS "${OPENNI2_INCLUDE_DIR}/OniVersion.h") + file(STRINGS "${OPENNI2_INCLUDE_DIR}/OniVersion.h" _contents REGEX "^#define[ \t]+ONI_VERSION_[A-Z]+[ \t]+[0-9]+") + if(_contents) + string(REGEX REPLACE ".*#define[ \t]+ONI_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" OPENNI2_VERSION_MAJOR "${_contents}") + string(REGEX REPLACE ".*#define[ \t]+ONI_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" OPENNI2_VERSION_MINOR "${_contents}") + string(REGEX REPLACE ".*#define[ \t]+ONI_VERSION_MAINTENANCE[ \t]+([0-9]+).*" "\\1" OPENNI2_VERSION_PATCH "${_contents}") + string(REGEX REPLACE ".*#define[ \t]+ONI_VERSION_BUILD[ \t]+([0-9]+).*" "\\1" OPENNI2_VERSION_BUILD "${_contents}") + set(OPENNI2_VERSION "${OPENNI2_VERSION_MAJOR}.${OPENNI2_VERSION_MINOR}.${OPENNI2_VERSION_PATCH}.${OPENNI2_VERSION_BUILD}") + endif() +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(OpenNI2 FOUND_VAR OPENNI2_FOUND REQUIRED_VARS OPENNI2_LIBRARIES OPENNI2_INCLUDE_DIRS + VERSION_VAR OPENNI2_VERSION ) if(OPENNI2_FOUND) - message(STATUS "OpenNI2 found (include: ${OPENNI2_INCLUDE_DIRS}, lib: ${OPENNI2_LIBRARIES})") + message(STATUS "OpenNI2 found (version: ${OPENNI2_VERSION}, include: ${OPENNI2_INCLUDE_DIRS}, lib: ${OPENNI2_LIBRARIES})") endif() From 803ce8ef970d78eb84e01f68af58205dc9f8db8f Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 6 Feb 2021 17:29:41 +0100 Subject: [PATCH 028/431] Add pcl log stream macros PCL_INFO_STREAM, PCL_ERROR_STREAM, and more. Similar to ROS_INFO_STREAM etc --- common/include/pcl/console/print.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/include/pcl/console/print.h b/common/include/pcl/console/print.h index 59617714fe3..d4e94f31d98 100644 --- a/common/include/pcl/console/print.h +++ b/common/include/pcl/console/print.h @@ -43,6 +43,18 @@ #include #include +// Use e.g. like this: +// PCL_INFO_STREAM("Info: this is a point: " << pcl::PointXYZ(1.0, 2.0, 3.0) << std::endl); +// PCL_ERROR_STREAM("Error: an Eigen vector: " << std::endl << Eigen::Vector3f(1.0, 2.0, 3.0) << std::endl); +#define PCL_LOG_STREAM(LEVEL, STREAM, CSTR, ATTR, FG, ARGS) if(pcl::console::isVerbosityLevelEnabled(pcl::console::LEVEL)) { fflush(stdout); pcl::console::change_text_color(CSTR, pcl::console::ATTR, pcl::console::FG); STREAM << ARGS; pcl::console::reset_text_color(CSTR); } +#define PCL_ALWAYS_STREAM(ARGS) PCL_LOG_STREAM(L_ALWAYS, std::cout, stdout, TT_RESET, TT_WHITE, ARGS) +#define PCL_ERROR_STREAM(ARGS) PCL_LOG_STREAM(L_ERROR, std::cerr, stderr, TT_BRIGHT, TT_RED, ARGS) +#define PCL_WARN_STREAM(ARGS) PCL_LOG_STREAM(L_WARN, std::cerr, stderr, TT_BRIGHT, TT_YELLOW, ARGS) +#define PCL_INFO_STREAM(ARGS) PCL_LOG_STREAM(L_INFO, std::cout, stdout, TT_RESET, TT_WHITE, ARGS) +#define PCL_DEBUG_STREAM(ARGS) PCL_LOG_STREAM(L_DEBUG, std::cout, stdout, TT_RESET, TT_GREEN, ARGS) +#define PCL_VERBOSE_STREAM(ARGS) PCL_LOG_STREAM(L_VERBOSE, std::cout, stdout, TT_RESET, TT_WHITE, ARGS) + + #define PCL_ALWAYS(...) pcl::console::print (pcl::console::L_ALWAYS, __VA_ARGS__) #define PCL_ERROR(...) pcl::console::print (pcl::console::L_ERROR, __VA_ARGS__) #define PCL_WARN(...) pcl::console::print (pcl::console::L_WARN, __VA_ARGS__) From b65b82c057b2baf9d8b7b37fcb62a18340691a20 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Mon, 8 Mar 2021 15:43:51 +0100 Subject: [PATCH 029/431] Use more pcl::Indices in features, segmentation, tracking, ... --- .../src/cloudEditorWidget.cpp | 2 +- .../multiscale_feature_persistence_example.cpp | 2 +- apps/src/openni_change_viewer.cpp | 6 +++--- apps/src/test_search.cpp | 4 ++-- features/include/pcl/features/fpfh.h | 6 +++--- features/include/pcl/features/gfpfh.h | 2 +- .../include/pcl/features/impl/boundary.hpp | 2 +- features/include/pcl/features/impl/fpfh.hpp | 4 ++-- features/include/pcl/features/impl/gfpfh.hpp | 4 ++-- features/include/pcl/features/impl/ppfrgb.hpp | 2 +- ...l_multiscale_interest_region_extraction.hpp | 2 +- .../impl/smoothed_surfaces_keypoint.hpp | 2 +- .../pcl/outofcore/impl/octree_base_node.hpp | 10 +++++----- outofcore/include/pcl/outofcore/octree_base.h | 4 ++-- .../include/pcl/outofcore/octree_base_node.h | 2 +- .../main_ground_based_people_detection.cpp | 2 +- .../impl/ground_based_people_detection_app.hpp | 2 +- .../pcl/people/impl/head_based_subcluster.hpp | 13 ++++++------- .../include/pcl/people/impl/height_map_2d.hpp | 6 +++--- .../pcl/segmentation/impl/cpc_segmentation.hpp | 2 +- .../pcl/segmentation/impl/extract_clusters.hpp | 2 +- .../segmentation/impl/min_cut_segmentation.hpp | 2 +- .../pcl/segmentation/impl/region_growing.hpp | 6 +++--- .../segmentation/impl/region_growing_rgb.hpp | 12 ++++++------ .../impl/supervoxel_clustering.hpp | 4 ++-- .../pcl/segmentation/impl/unary_classifier.hpp | 4 ++-- .../include/pcl/segmentation/region_growing.h | 6 +++--- .../pcl/segmentation/region_growing_rgb.h | 2 +- .../pcl/segmentation/unary_classifier.h | 4 ++-- .../simplification_remove_unused_vertices.cpp | 2 +- test/filters/test_filters.cpp | 8 ++++---- test/filters/test_sampling.cpp | 10 +++++----- test/search/test_flann_search.cpp | 8 ++++---- test/search/test_kdtree.cpp | 8 ++++---- test/search/test_octree.cpp | 13 +++++-------- test/search/test_organized.cpp | 2 +- test/search/test_organized_index.cpp | 10 +++++----- test/search/test_search.cpp | 18 +++++++++--------- tools/octree_viewer.cpp | 2 +- tools/pcd_viewer.cpp | 2 +- ...prox_nearest_pair_point_cloud_coherence.hpp | 2 +- .../impl/kld_adaptive_particle_filter_omp.hpp | 2 +- .../nearest_pair_point_cloud_coherence.hpp | 2 +- .../pcl/tracking/impl/particle_filter.hpp | 12 ++++++------ .../pcl/tracking/impl/particle_filter_omp.hpp | 2 +- .../include/pcl/tracking/particle_filter.h | 4 ++-- 46 files changed, 112 insertions(+), 116 deletions(-) diff --git a/apps/point_cloud_editor/src/cloudEditorWidget.cpp b/apps/point_cloud_editor/src/cloudEditorWidget.cpp index b9a1ba19586..c3fcfa61766 100644 --- a/apps/point_cloud_editor/src/cloudEditorWidget.cpp +++ b/apps/point_cloud_editor/src/cloudEditorWidget.cpp @@ -534,7 +534,7 @@ CloudEditorWidget::loadFilePCD(const std::string &filename) if (pcl::io::loadPCDFile(filename, tmp) == -1) throw; pcl_cloud_ptr = PclCloudPtr(new Cloud3D(tmp)); - std::vector index; + pcl::Indices index; pcl::removeNaNFromPointCloud(*pcl_cloud_ptr, *pcl_cloud_ptr, index); Statistics::clear(); cloud_ptr_ = CloudPtr(new Cloud(*pcl_cloud_ptr, true)); diff --git a/apps/src/multiscale_feature_persistence_example.cpp b/apps/src/multiscale_feature_persistence_example.cpp index 372c4cf428b..5ae97db8dcc 100644 --- a/apps/src/multiscale_feature_persistence_example.cpp +++ b/apps/src/multiscale_feature_persistence_example.cpp @@ -108,7 +108,7 @@ main(int argc, char** argv) feature_persistence.setDistanceMetric(pcl::CS); PointCloud::Ptr output_features(new PointCloud()); - auto output_indices = pcl::make_shared>(); + auto output_indices = pcl::make_shared(); feature_persistence.determinePersistentFeatures(*output_features, output_indices); PCL_INFO("persistent features cloud size: %zu\n", diff --git a/apps/src/openni_change_viewer.cpp b/apps/src/openni_change_viewer.cpp index 68616234524..b07a4e860e5 100644 --- a/apps/src/openni_change_viewer.cpp +++ b/apps/src/openni_change_viewer.cpp @@ -70,7 +70,7 @@ class OpenNIChangeViewer { octree->addPointsFromInputCloud(); std::cerr << octree->getLeafCount() << " -- "; - std::vector newPointIdxVector; + pcl::Indices newPointIdxVector; // get a vector of new points, which did not exist in previous buffer octree->getPointIndicesFromNewVoxels(newPointIdxVector, noise_filter_); @@ -84,7 +84,7 @@ class OpenNIChangeViewer { filtered_cloud.reset(new pcl::PointCloud(*cloud)); filtered_cloud->points.reserve(newPointIdxVector.size()); - for (const int& idx : newPointIdxVector) + for (const auto& idx : newPointIdxVector) (*filtered_cloud)[idx].rgba = 255 << 16; if (!viewer.wasStopped()) @@ -96,7 +96,7 @@ class OpenNIChangeViewer { filtered_cloud->points.reserve(newPointIdxVector.size()); - for (const int& idx : newPointIdxVector) + for (const auto& idx : newPointIdxVector) filtered_cloud->points.push_back((*cloud)[idx]); if (!viewer.wasStopped()) diff --git a/apps/src/test_search.cpp b/apps/src/test_search.cpp index da14b536a32..e561ce51d70 100644 --- a/apps/src/test_search.cpp +++ b/apps/src/test_search.cpp @@ -55,9 +55,9 @@ main(int argc, char** argv) query.y = 0.5; query.z = 0.5; - std::vector kd_indices; + pcl::Indices kd_indices; std::vector kd_distances; - std::vector bf_indices; + pcl::Indices bf_indices; std::vector bf_distances; double start, stop; diff --git a/features/include/pcl/features/fpfh.h b/features/include/pcl/features/fpfh.h index 53030add9a7..f2e742750b9 100644 --- a/features/include/pcl/features/fpfh.h +++ b/features/include/pcl/features/fpfh.h @@ -129,8 +129,8 @@ namespace pcl */ void computePointSPFHSignature (const pcl::PointCloud &cloud, - const pcl::PointCloud &normals, int p_idx, int row, - const std::vector &indices, + const pcl::PointCloud &normals, pcl::index_t p_idx, int row, + const pcl::Indices &indices, Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3); /** \brief Weight the SPFH (Simple Point Feature Histograms) individual histograms to create the final FPFH @@ -146,7 +146,7 @@ namespace pcl weightPointSPFHSignature (const Eigen::MatrixXf &hist_f1, const Eigen::MatrixXf &hist_f2, const Eigen::MatrixXf &hist_f3, - const std::vector &indices, + const pcl::Indices &indices, const std::vector &dists, Eigen::VectorXf &fpfh_histogram); diff --git a/features/include/pcl/features/gfpfh.h b/features/include/pcl/features/gfpfh.h index d42f4b7ccd9..02ee2af55ba 100644 --- a/features/include/pcl/features/gfpfh.h +++ b/features/include/pcl/features/gfpfh.h @@ -133,7 +133,7 @@ namespace pcl /** \brief Return the dominant label of a set of points. */ std::uint32_t - getDominantLabel (const std::vector& indices); + getDominantLabel (const pcl::Indices& indices); /** \brief Compute the fixed-length histograms of transitions. */ void computeTransitionHistograms (const std::vector< std::vector >& label_histograms, diff --git a/features/include/pcl/features/impl/boundary.hpp b/features/include/pcl/features/impl/boundary.hpp index 198751368d0..a127c6d2191 100644 --- a/features/include/pcl/features/impl/boundary.hpp +++ b/features/include/pcl/features/impl/boundary.hpp @@ -50,7 +50,7 @@ template bool pcl::BoundaryEstimation::isBoundaryPoint ( const pcl::PointCloud &cloud, int q_idx, - const std::vector &indices, + const pcl::Indices &indices, const Eigen::Vector4f &u, const Eigen::Vector4f &v, const float angle_threshold) { diff --git a/features/include/pcl/features/impl/fpfh.hpp b/features/include/pcl/features/impl/fpfh.hpp index e97ee3fecb1..41b0772d8b5 100644 --- a/features/include/pcl/features/impl/fpfh.hpp +++ b/features/include/pcl/features/impl/fpfh.hpp @@ -63,7 +63,7 @@ pcl::FPFHEstimation::computePairFeatures ( template void pcl::FPFHEstimation::computePointSPFHSignature ( const pcl::PointCloud &cloud, const pcl::PointCloud &normals, - int p_idx, int row, const pcl::Indices &indices, + pcl::index_t p_idx, int row, const pcl::Indices &indices, Eigen::MatrixXf &hist_f1, Eigen::MatrixXf &hist_f2, Eigen::MatrixXf &hist_f3) { Eigen::Vector4f pfh_tuple; @@ -109,7 +109,7 @@ pcl::FPFHEstimation::computePointSPFHSignature ( template void pcl::FPFHEstimation::weightPointSPFHSignature ( const Eigen::MatrixXf &hist_f1, const Eigen::MatrixXf &hist_f2, const Eigen::MatrixXf &hist_f3, - const std::vector &indices, const std::vector &dists, Eigen::VectorXf &fpfh_histogram) + const pcl::Indices &indices, const std::vector &dists, Eigen::VectorXf &fpfh_histogram) { assert (indices.size () == dists.size ()); // @TODO: use arrays diff --git a/features/include/pcl/features/impl/gfpfh.hpp b/features/include/pcl/features/impl/gfpfh.hpp index 11d47369339..06be4cf84fb 100644 --- a/features/include/pcl/features/impl/gfpfh.hpp +++ b/features/include/pcl/features/impl/gfpfh.hpp @@ -103,7 +103,7 @@ pcl::GFPFHEstimation::computeFeature (PointCloudOu std::vector histogram; for (std::size_t k = 0; k < intersected_cells.size (); ++k) { - std::vector indices; + pcl::Indices indices; octree.voxelSearch (intersected_cells[k], indices); int label = emptyLabel (); if (!indices.empty ()) @@ -251,7 +251,7 @@ pcl::GFPFHEstimation::computeHIKDistance (const st ////////////////////////////////////////////////////////////////////////////////////////////// template std::uint32_t -pcl::GFPFHEstimation::getDominantLabel (const std::vector& indices) +pcl::GFPFHEstimation::getDominantLabel (const pcl::Indices& indices) { std::vector counts (getNumberOfClasses () + 1, 0); for (const auto &nn_index : indices) diff --git a/features/include/pcl/features/impl/ppfrgb.hpp b/features/include/pcl/features/impl/ppfrgb.hpp index 67b174e9acb..87f74548a62 100644 --- a/features/include/pcl/features/impl/ppfrgb.hpp +++ b/features/include/pcl/features/impl/ppfrgb.hpp @@ -125,7 +125,7 @@ pcl::PPFRGBRegionEstimation::computeFeature (Point output.resize (indices_->size ()); for (std::size_t index_i = 0; index_i < indices_->size (); ++index_i) { - int i = (*indices_)[index_i]; + auto i = (*indices_)[index_i]; pcl::Indices nn_indices; std::vector nn_distances; tree_->radiusSearch (i, static_cast (search_radius_), nn_indices, nn_distances); diff --git a/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp b/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp index 50ae066c745..6f31a148a67 100644 --- a/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp +++ b/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp @@ -235,7 +235,7 @@ pcl::StatisticalMultiscaleInterestRegionExtraction::extractExtrema (std: (is_max[scale_i - 1][point_i] && is_max[scale_i][point_i] && is_max[scale_i + 1][point_i])) { // add the point to the result vector - IndicesPtr region (new std::vector); + IndicesPtr region (new pcl::Indices); region->push_back (static_cast (point_i)); // and also add its scale-sized geodesic neighborhood diff --git a/keypoints/include/pcl/keypoints/impl/smoothed_surfaces_keypoint.hpp b/keypoints/include/pcl/keypoints/impl/smoothed_surfaces_keypoint.hpp index 57afe607c87..2c1a3dff2ca 100644 --- a/keypoints/include/pcl/keypoints/impl/smoothed_surfaces_keypoint.hpp +++ b/keypoints/include/pcl/keypoints/impl/smoothed_surfaces_keypoint.hpp @@ -95,7 +95,7 @@ pcl::SmoothedSurfacesKeypoint::detectKeypoints (PointCloudT &ou // Find minima and maxima in differences inside the input cloud typename pcl::search::Search::Ptr input_tree = cloud_trees_.back (); - for (int point_i = 0; point_i < static_cast (input_->size ()); ++point_i) + for (pcl::index_t point_i = 0; point_i < static_cast (input_->size ()); ++point_i) { pcl::Indices nn_indices; std::vector nn_distances; diff --git a/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp b/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp index d16efe8a3ee..d5dffc42910 100644 --- a/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp +++ b/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp @@ -511,7 +511,7 @@ namespace pcl //indices to store the points for each bin //these lists will be used to copy data to new point clouds and pass down recursively - std::vector < std::vector > indices; + std::vector < pcl::Indices > indices; indices.resize (8); this->sortOctantIndices (input_cloud, indices, node_metadata_->getVoxelCenter ()); @@ -766,7 +766,7 @@ namespace pcl PCL_DEBUG ("[pcl::outofcore::OutofcoreOctreeBaseNode::%s] Remaining points are %u\n",__FUNCTION__, remaining_points->width*remaining_points->height); //subdivide remaining data by destination octant - std::vector > indices; + std::vector indices; indices.resize (8); this->sortOctantIndices (remaining_points, indices, node_metadata_->getVoxelCenter ()); @@ -1451,7 +1451,7 @@ namespace pcl Eigen::Vector4f min_pt ( static_cast ( min_bb[0] ), static_cast ( min_bb[1] ), static_cast ( min_bb[2] ), 1.0f); Eigen::Vector4f max_pt ( static_cast ( max_bb[0] ), static_cast ( max_bb[1] ) , static_cast( max_bb[2] ), 1.0f ); - std::vector indices; + pcl::Indices indices; pcl::getPointsInBox ( *tmp_cloud, min_pt, max_pt, indices ); PCL_DEBUG ( "[pcl::outofcore::OutofcoreOctreeBaseNode::%s] Points in box: %d\n", __FUNCTION__, indices.size () ); @@ -1614,7 +1614,7 @@ namespace pcl pcl::ExtractIndices extractor; extractor.setInputCloud (tmp_blob); - pcl::IndicesPtr downsampled_cloud_indices (new std::vector ()); + pcl::IndicesPtr downsampled_cloud_indices (new pcl::Indices ()); random_sampler.filter (*downsampled_cloud_indices); extractor.setIndices (downsampled_cloud_indices); extractor.filter (*downsampled_points); @@ -1973,7 +1973,7 @@ namespace pcl //////////////////////////////////////////////////////////////////////////////// template void - OutofcoreOctreeBaseNode::sortOctantIndices (const pcl::PCLPointCloud2::Ptr &input_cloud, std::vector< std::vector > &indices, const Eigen::Vector3d &mid_xyz) + OutofcoreOctreeBaseNode::sortOctantIndices (const pcl::PCLPointCloud2::Ptr &input_cloud, std::vector< pcl::Indices > &indices, const Eigen::Vector3d &mid_xyz) { if (indices.size () < 8) indices.resize (8); diff --git a/outofcore/include/pcl/outofcore/octree_base.h b/outofcore/include/pcl/outofcore/octree_base.h index 6c62cb67f40..5cac314f833 100644 --- a/outofcore/include/pcl/outofcore/octree_base.h +++ b/outofcore/include/pcl/outofcore/octree_base.h @@ -180,8 +180,8 @@ namespace pcl using PointCloud = pcl::PointCloud; - using IndicesPtr = shared_ptr >; - using IndicesConstPtr = shared_ptr >; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloudPtr = typename PointCloud::Ptr; using PointCloudConstPtr = typename PointCloud::ConstPtr; diff --git a/outofcore/include/pcl/outofcore/octree_base_node.h b/outofcore/include/pcl/outofcore/octree_base_node.h index c65d8491d19..dfe1002f316 100644 --- a/outofcore/include/pcl/outofcore/octree_base_node.h +++ b/outofcore/include/pcl/outofcore/octree_base_node.h @@ -519,7 +519,7 @@ namespace pcl * This could be overloaded with a parallelized implementation */ void - sortOctantIndices (const pcl::PCLPointCloud2::Ptr &input_cloud, std::vector< std::vector > &indices, const Eigen::Vector3d &mid_xyz); + sortOctantIndices (const pcl::PCLPointCloud2::Ptr &input_cloud, std::vector< pcl::Indices > &indices, const Eigen::Vector3d &mid_xyz); /** \brief Enlarges the shortest two sidelengths of the * bounding box to a cubic shape; operation is done in diff --git a/people/apps/main_ground_based_people_detection.cpp b/people/apps/main_ground_based_people_detection.cpp index d79b442d594..4a9f4e8f66f 100644 --- a/people/apps/main_ground_based_people_detection.cpp +++ b/people/apps/main_ground_based_people_detection.cpp @@ -179,7 +179,7 @@ int main (int argc, char** argv) // Ground plane estimation: Eigen::VectorXf ground_coeffs; ground_coeffs.resize(4); - std::vector clicked_points_indices; + pcl::Indices clicked_points_indices; for (std::size_t i = 0; i < clicked_points_3d->size(); i++) clicked_points_indices.push_back(i); pcl::SampleConsensusModelPlane model_plane(clicked_points_3d); diff --git a/people/include/pcl/people/impl/ground_based_people_detection_app.hpp b/people/include/pcl/people/impl/ground_based_people_detection_app.hpp index 36fd3141a3b..cc7b23b9038 100644 --- a/people/include/pcl/people/impl/ground_based_people_detection_app.hpp +++ b/people/include/pcl/people/impl/ground_based_people_detection_app.hpp @@ -359,7 +359,7 @@ pcl::people::GroundBasedPeopleDetectionApp::compute (std::vector); + pcl::IndicesPtr inliers(new pcl::Indices); typename pcl::SampleConsensusModelPlane::Ptr ground_model (new pcl::SampleConsensusModelPlane (cloud_filtered_)); ground_model->selectWithinDistance(ground_coeffs_transformed_, 2 * voxel_size_, *inliers); no_ground_cloud_ = PointCloudPtr (new PointCloud); diff --git a/people/include/pcl/people/impl/head_based_subcluster.hpp b/people/include/pcl/people/impl/head_based_subcluster.hpp index ee4536215ae..46c8aa1e76d 100644 --- a/people/include/pcl/people/impl/head_based_subcluster.hpp +++ b/people/include/pcl/people/impl/head_based_subcluster.hpp @@ -177,10 +177,9 @@ pcl::people::HeadBasedSubclustering::mergeClustersCloseInFloorCoordinate if (!used_clusters[cluster]) // if this cluster has not been used yet { used_clusters[cluster] = true; - for(std::vector::const_iterator points_iterator = input_clusters[cluster].getIndices().indices.begin(); - points_iterator != input_clusters[cluster].getIndices().indices.end(); ++points_iterator) + for(const auto& points_iterator : input_clusters[cluster].getIndices().indices) { - point_indices.indices.push_back(*points_iterator); + point_indices.indices.push_back(points_iterator); } } } @@ -200,7 +199,7 @@ pcl::people::HeadBasedSubclustering::createSubClusters (pcl::people::Per Eigen::Vector3f head_ground_coeffs = ground_coeffs_.head(3); // ground plane normal (precomputed for speed) Eigen::Matrix3Xf maxima_projected(3,maxima_number); // matrix containing the projection of maxima onto the ground plane Eigen::VectorXi subclusters_number_of_points(maxima_number); // subclusters number of points - std::vector > sub_clusters_indices; // vector of vectors with the cluster indices for every maximum + std::vector sub_clusters_indices; // vector of vectors with the cluster indices for every maximum sub_clusters_indices.resize(maxima_number); // resize to number of maxima // Project maxima on the ground plane: @@ -214,9 +213,9 @@ pcl::people::HeadBasedSubclustering::createSubClusters (pcl::people::Per } // Associate cluster points to one of the maximum: - for(std::vector::const_iterator points_iterator = cluster.getIndices().indices.begin(); points_iterator != cluster.getIndices().indices.end(); ++points_iterator) + for(const auto& points_iterator : cluster.getIndices().indices) { - PointT* current_point = &(*cloud_)[*points_iterator]; // current point cloud point + PointT* current_point = &(*cloud_)[points_iterator]; // current point cloud point Eigen::Vector3f p_current_eigen(current_point->x, current_point->y, current_point->z); // conversion to eigen float t = p_current_eigen.dot(head_ground_coeffs) / normalize_factor; // height from the ground p_current_eigen -= head_ground_coeffs * t; // projection of the point on the groundplane @@ -228,7 +227,7 @@ pcl::people::HeadBasedSubclustering::createSubClusters (pcl::people::Per if (((p_current_eigen - maxima_projected.col(i)).norm()) < heads_minimum_distance_) { correspondence_detected = true; - sub_clusters_indices[i].push_back(*points_iterator); + sub_clusters_indices[i].push_back(points_iterator); subclusters_number_of_points(i)++; } else diff --git a/people/include/pcl/people/impl/height_map_2d.hpp b/people/include/pcl/people/impl/height_map_2d.hpp index e179b464469..de9852c3b0f 100644 --- a/people/include/pcl/people/impl/height_map_2d.hpp +++ b/people/include/pcl/people/impl/height_map_2d.hpp @@ -85,9 +85,9 @@ pcl::people::HeightMap2D::compute (pcl::people::PersonCluster& c buckets_.resize(std::size_t((cluster.getMax()(1) - cluster.getMin()(1)) / bin_size_) + 1, 0); buckets_cloud_indices_.resize(buckets_.size(), 0); - for(std::vector::const_iterator pit = cluster.getIndices().indices.begin(); pit != cluster.getIndices().indices.end(); ++pit) + for(const auto& pit : cluster.getIndices().indices) { - PointT* p = &(*cloud_)[*pit]; + PointT* p = &(*cloud_)[pit]; int index; if (!vertical_) // camera horizontal index = int((p->x - cluster.getMin()(0)) / bin_size_); @@ -103,7 +103,7 @@ pcl::people::HeightMap2D::compute (pcl::people::PersonCluster& c if ((heightp * 60) > buckets_[index]) // compare the height of the new point with the existing one { buckets_[index] = heightp * 60; // maximum height - buckets_cloud_indices_[index] = *pit; // point cloud index of the point with maximum height + buckets_cloud_indices_[index] = pit; // point cloud index of the point with maximum height } } } diff --git a/segmentation/include/pcl/segmentation/impl/cpc_segmentation.hpp b/segmentation/include/pcl/segmentation/impl/cpc_segmentation.hpp index 1f92f39a7ba..030d85944c2 100644 --- a/segmentation/include/pcl/segmentation/impl/cpc_segmentation.hpp +++ b/segmentation/include/pcl/segmentation/impl/cpc_segmentation.hpp @@ -295,7 +295,7 @@ pcl::CPCSegmentation::WeightedRandomSampleConsensus::computeModel (int) iterations_ = 0; best_score_ = -std::numeric_limits::max (); - std::vector selection; + pcl::Indices selection; Eigen::VectorXf model_coefficients; unsigned skipped_count = 0; diff --git a/segmentation/include/pcl/segmentation/impl/extract_clusters.hpp b/segmentation/include/pcl/segmentation/impl/extract_clusters.hpp index e42ad0e5c58..2b840b81b9e 100644 --- a/segmentation/include/pcl/segmentation/impl/extract_clusters.hpp +++ b/segmentation/include/pcl/segmentation/impl/extract_clusters.hpp @@ -259,6 +259,6 @@ pcl::EuclideanClusterExtraction::extract (std::vector &clu #define PCL_INSTANTIATE_EuclideanClusterExtraction(T) template class PCL_EXPORTS pcl::EuclideanClusterExtraction; #define PCL_INSTANTIATE_extractEuclideanClusters(T) template void PCL_EXPORTS pcl::extractEuclideanClusters(const pcl::PointCloud &, const typename pcl::search::Search::Ptr &, float , std::vector &, unsigned int, unsigned int); -#define PCL_INSTANTIATE_extractEuclideanClusters_indices(T) template void PCL_EXPORTS pcl::extractEuclideanClusters(const pcl::PointCloud &, const std::vector &, const typename pcl::search::Search::Ptr &, float , std::vector &, unsigned int, unsigned int); +#define PCL_INSTANTIATE_extractEuclideanClusters_indices(T) template void PCL_EXPORTS pcl::extractEuclideanClusters(const pcl::PointCloud &, const pcl::Indices &, const typename pcl::search::Search::Ptr &, float , std::vector &, unsigned int, unsigned int); #endif // PCL_EXTRACT_CLUSTERS_IMPL_H_ diff --git a/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp b/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp index aa09db0ccde..abdfb81093a 100644 --- a/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp +++ b/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp @@ -342,7 +342,7 @@ pcl::MinCutSegmentation::buildGraph () addEdge (point_index, static_cast (sink_), sink_weight); } - std::vector neighbours; + pcl::Indices neighbours; std::vector distances; search_->setInputCloud (input_, indices_); for (std::size_t i_point = 0; i_point < number_of_indices; i_point++) diff --git a/segmentation/include/pcl/segmentation/impl/region_growing.hpp b/segmentation/include/pcl/segmentation/impl/region_growing.hpp index 7761776ced2..b14c5b42f5d 100644 --- a/segmentation/include/pcl/segmentation/impl/region_growing.hpp +++ b/segmentation/include/pcl/segmentation/impl/region_growing.hpp @@ -343,7 +343,7 @@ template void pcl::RegionGrowing::findPointNeighbours () { int point_number = static_cast (indices_->size ()); - std::vector neighbours; + pcl::Indices neighbours; std::vector distances; point_neighbours_.resize (input_->size (), neighbours); @@ -480,7 +480,7 @@ pcl::RegionGrowing::growRegion (int initial_seed, int segment_n ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template bool -pcl::RegionGrowing::validatePoint (int initial_seed, int point, int nghbr, bool& is_a_seed) const +pcl::RegionGrowing::validatePoint (pcl::index_t initial_seed, pcl::index_t point, pcl::index_t nghbr, bool& is_a_seed) const { is_a_seed = true; @@ -567,7 +567,7 @@ pcl::RegionGrowing::assembleRegions () ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template void -pcl::RegionGrowing::getSegmentFromPoint (int index, pcl::PointIndices& cluster) +pcl::RegionGrowing::getSegmentFromPoint (pcl::index_t index, pcl::PointIndices& cluster) { cluster.indices.clear (); diff --git a/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp b/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp index 519c5d46d83..718c5e96ce9 100644 --- a/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp +++ b/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp @@ -273,7 +273,7 @@ template void pcl::RegionGrowingRGB::findPointNeighbours () { int point_number = static_cast (indices_->size ()); - std::vector neighbours; + pcl::Indices neighbours; std::vector distances; point_neighbours_.resize (input_->size (), neighbours); @@ -294,14 +294,14 @@ pcl::RegionGrowingRGB::findPointNeighbours () template void pcl::RegionGrowingRGB::findSegmentNeighbours () { - std::vector neighbours; + pcl::Indices neighbours; std::vector distances; segment_neighbours_.resize (number_of_segments_, neighbours); segment_distances_.resize (number_of_segments_, distances); for (int i_seg = 0; i_seg < number_of_segments_; i_seg++) { - std::vector nghbrs; + pcl::Indices nghbrs; std::vector dist; findRegionsKNN (i_seg, region_neighbour_number_, nghbrs, dist); segment_neighbours_[i_seg].swap (nghbrs); @@ -311,7 +311,7 @@ pcl::RegionGrowingRGB::findSegmentNeighbours () ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template void -pcl::RegionGrowingRGB::findRegionsKNN (int index, int nghbr_number, std::vector& nghbrs, std::vector& dist) +pcl::RegionGrowingRGB::findRegionsKNN (pcl::index_t index, int nghbr_number, pcl::Indices& nghbrs, std::vector& dist) { std::vector distances; float max_dist = std::numeric_limits::max (); @@ -606,7 +606,7 @@ pcl::RegionGrowingRGB::assembleRegions (std::vector bool -pcl::RegionGrowingRGB::validatePoint (int initial_seed, int point, int nghbr, bool& is_a_seed) const +pcl::RegionGrowingRGB::validatePoint (pcl::index_t initial_seed, pcl::index_t point, pcl::index_t nghbr, bool& is_a_seed) const { is_a_seed = true; @@ -685,7 +685,7 @@ pcl::RegionGrowingRGB::validatePoint (int initial_seed, int poi ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template void -pcl::RegionGrowingRGB::getSegmentFromPoint (int index, pcl::PointIndices& cluster) +pcl::RegionGrowingRGB::getSegmentFromPoint (pcl::index_t index, pcl::PointIndices& cluster) { cluster.indices.clear (); diff --git a/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp b/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp index 26a7ca5e431..86de624f388 100644 --- a/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp +++ b/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp @@ -381,7 +381,7 @@ pcl::SupervoxelClustering::selectInitialSupervoxelSeeds (Indices &seed_i std::vector seed_indices_orig; seed_indices_orig.resize (num_seeds, 0); seed_indices.clear (); - std::vector closest_index; + pcl::Indices closest_index; std::vector distance; closest_index.resize(1,0); distance.resize(1,0); @@ -397,7 +397,7 @@ pcl::SupervoxelClustering::selectInitialSupervoxelSeeds (Indices &seed_i seed_indices_orig[i] = closest_index[0]; } - std::vector neighbors; + pcl::Indices neighbors; std::vector sqr_distances; seed_indices.reserve (seed_indices_orig.size ()); float search_radius = 0.5f*seed_resolution_; diff --git a/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp b/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp index cf0e9b05bd9..133d27d28fd 100644 --- a/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp +++ b/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp @@ -273,7 +273,7 @@ pcl::UnaryClassifier::kmeansClustering (pcl::PointCloud void pcl::UnaryClassifier::queryFeatureDistances (std::vector::Ptr> &trained_features, pcl::PointCloud::Ptr query_features, - std::vector &indi, + pcl::Indices &indi, std::vector &dist) { // estimate the total number of row's needed @@ -328,7 +328,7 @@ pcl::UnaryClassifier::queryFeatureDistances (std::vector void -pcl::UnaryClassifier::assignLabels (std::vector &indi, +pcl::UnaryClassifier::assignLabels (pcl::Indices &indi, std::vector &dist, int n_feature_means, float feature_threshold, diff --git a/segmentation/include/pcl/segmentation/region_growing.h b/segmentation/include/pcl/segmentation/region_growing.h index 7f70084ca71..4def2b04766 100644 --- a/segmentation/include/pcl/segmentation/region_growing.h +++ b/segmentation/include/pcl/segmentation/region_growing.h @@ -212,7 +212,7 @@ namespace pcl * \param[out] cluster cluster to which the point belongs. */ virtual void - getSegmentFromPoint (int index, pcl::PointIndices& cluster); + getSegmentFromPoint (pcl::index_t index, pcl::PointIndices& cluster); /** \brief If the cloud was successfully segmented, then function * returns colored cloud. Otherwise it returns an empty pointer. @@ -268,7 +268,7 @@ namespace pcl * \param[out] is_a_seed this value is set to true if the point with index 'nghbr' can serve as the seed */ virtual bool - validatePoint (int initial_seed, int point, int nghbr, bool& is_a_seed) const; + validatePoint (pcl::index_t initial_seed, pcl::index_t point, pcl::index_t nghbr, bool& is_a_seed) const; /** \brief This function simply assembles the regions from list of point labels. * Each cluster is an array of point indices. @@ -312,7 +312,7 @@ namespace pcl NormalPtr normals_; /** \brief Contains neighbours of each point. */ - std::vector > point_neighbours_; + std::vector point_neighbours_; /** \brief Point labels that tells to which segment each point belongs. */ std::vector point_labels_; diff --git a/segmentation/include/pcl/segmentation/region_growing_rgb.h b/segmentation/include/pcl/segmentation/region_growing_rgb.h index dff7fa50a28..c2db41ae0cb 100644 --- a/segmentation/include/pcl/segmentation/region_growing_rgb.h +++ b/segmentation/include/pcl/segmentation/region_growing_rgb.h @@ -267,7 +267,7 @@ namespace pcl std::vector< std::vector > point_distances_; /** \brief Stores the neighboures for the corresponding segments. */ - std::vector< std::vector > segment_neighbours_; + std::vector< pcl::Indices > segment_neighbours_; /** \brief Stores distances for the segment neighbours from segment_neighbours_ */ std::vector< std::vector > segment_distances_; diff --git a/segmentation/include/pcl/segmentation/unary_classifier.h b/segmentation/include/pcl/segmentation/unary_classifier.h index a1713c1e8b4..d34116a5e11 100644 --- a/segmentation/include/pcl/segmentation/unary_classifier.h +++ b/segmentation/include/pcl/segmentation/unary_classifier.h @@ -85,11 +85,11 @@ namespace pcl void queryFeatureDistances (std::vector::Ptr> &trained_features, pcl::PointCloud::Ptr query_features, - std::vector &indi, + pcl::Indices &indi, std::vector &dist); void - assignLabels (std::vector &indi, + assignLabels (pcl::Indices &indi, std::vector &dist, int n_feature_means, float feature_threshold, diff --git a/surface/src/simplification_remove_unused_vertices.cpp b/surface/src/simplification_remove_unused_vertices.cpp index 692e2ce3042..fa2d2b4c176 100644 --- a/surface/src/simplification_remove_unused_vertices.cpp +++ b/surface/src/simplification_remove_unused_vertices.cpp @@ -43,7 +43,7 @@ #include void -pcl::surface::SimplificationRemoveUnusedVertices::simplify(const pcl::PolygonMesh& input, pcl::PolygonMesh& output, std::vector& indices) +pcl::surface::SimplificationRemoveUnusedVertices::simplify(const pcl::PolygonMesh& input, pcl::PolygonMesh& output, pcl::Indices& indices) { if (input.polygons.empty ()) return; diff --git a/test/filters/test_filters.cpp b/test/filters/test_filters.cpp index 13b191e9a21..1986293dde3 100644 --- a/test/filters/test_filters.cpp +++ b/test/filters/test_filters.cpp @@ -2161,7 +2161,7 @@ TEST (NormalRefinement, Filters) // Search parameters const int k = 5; - std::vector > k_indices; + std::vector k_indices; std::vector > k_sqr_distances; // Estimated and refined normal containers @@ -2175,7 +2175,7 @@ TEST (NormalRefinement, Filters) // Search for neighbors pcl::search::KdTree kdtree; kdtree.setInputCloud (cloud_organized_nonan.makeShared ()); - kdtree.nearestKSearch (cloud_organized_nonan, std::vector (), k, k_indices, k_sqr_distances); + kdtree.nearestKSearch (cloud_organized_nonan, pcl::Indices (), k, k_indices, k_sqr_distances); /* * Estimate normals @@ -2225,7 +2225,7 @@ TEST (NormalRefinement, Filters) seg.segment (*inliers, *coefficients); // Read out SAC model - const std::vector& idx_table = inliers->indices; + const auto& idx_table = inliers->indices; float a = coefficients->values[0]; float b = coefficients->values[1]; float c = coefficients->values[2]; @@ -2255,7 +2255,7 @@ TEST (NormalRefinement, Filters) int num_nans = 0; // Loop - for (const int &idx : idx_table) + for (const auto &idx : idx_table) { float tmp; diff --git a/test/filters/test_sampling.cpp b/test/filters/test_sampling.cpp index f6267076a80..d7e10701683 100644 --- a/test/filters/test_sampling.cpp +++ b/test/filters/test_sampling.cpp @@ -69,7 +69,7 @@ TEST (CovarianceSampling, Filters) // Conditioning number should be loosely close to the expected number. Adopting 10% of the reference value EXPECT_NEAR (113.29773, cond_num_walls, 10.); - IndicesPtr walls_indices (new std::vector ()); + IndicesPtr walls_indices (new pcl::Indices ()); covariance_sampling.filter (*walls_indices); covariance_sampling.setIndices (walls_indices); double cond_num_walls_sampled = covariance_sampling.computeConditionNumber (); @@ -89,7 +89,7 @@ TEST (CovarianceSampling, Filters) // Conditioning number should be loosely close to the expected number. Adopting 10% of the reference value EXPECT_NEAR (cond_num_turtle, 20661.7663, 2e4); - IndicesPtr turtle_indices (new std::vector ()); + IndicesPtr turtle_indices (new pcl::Indices ()); covariance_sampling.filter (*turtle_indices); covariance_sampling.setIndices (turtle_indices); double cond_num_turtle_sampled = covariance_sampling.computeConditionNumber (); @@ -154,7 +154,7 @@ TEST (RandomSample, Filters) sample.setSample (10); // Indices - std::vector indices; + pcl::Indices indices; sample.filter (indices); EXPECT_EQ (int (indices.size ()), 10); @@ -218,7 +218,7 @@ TEST (RandomSample, Filters) sample2.setSample (10); // Indices - std::vector indices2; + pcl::Indices indices2; sample2.filter (indices2); EXPECT_EQ (int (indices2.size ()), 10); @@ -268,7 +268,7 @@ main (int argc, char** argv) ne.compute (*cloud_walls_normals); copyPointCloud (*cloud_walls, *cloud_walls_normals); - std::vector aux_indices; + pcl::Indices aux_indices; removeNaNFromPointCloud (*cloud_walls_normals, *cloud_walls_normals, aux_indices); removeNaNNormalsFromPointCloud (*cloud_walls_normals, *cloud_walls_normals, aux_indices); diff --git a/test/search/test_flann_search.cpp b/test/search/test_flann_search.cpp index 3a24fe17f98..72428f86ae1 100644 --- a/test/search/test_flann_search.cpp +++ b/test/search/test_flann_search.cpp @@ -143,8 +143,8 @@ TEST (PCL, FlannSearch_differentPointT) std::vector< std::vector< float > > dists; - std::vector< std::vector< int > > indices; - FlannSearch.nearestKSearchT (cloud_rgb, std::vector (),no_of_neighbors,indices,dists); + std::vector< pcl::Indices > indices; + FlannSearch.nearestKSearchT (cloud_rgb, pcl::Indices (),no_of_neighbors,indices,dists); pcl::Indices k_indices; k_indices.resize (no_of_neighbors); @@ -184,8 +184,8 @@ TEST (PCL, FlannSearch_multipointKnnSearch) FlannSearch.setInputCloud (cloud_big.makeShared ()); std::vector< std::vector< float > > dists; - std::vector< std::vector< int > > indices; - FlannSearch.nearestKSearch (cloud_big, std::vector(),no_of_neighbors,indices,dists); + std::vector< pcl::Indices > indices; + FlannSearch.nearestKSearch (cloud_big, pcl::Indices(),no_of_neighbors,indices,dists); pcl::Indices k_indices; k_indices.resize (no_of_neighbors); diff --git a/test/search/test_kdtree.cpp b/test/search/test_kdtree.cpp index 8aab7c91514..571f9760f0a 100644 --- a/test/search/test_kdtree.cpp +++ b/test/search/test_kdtree.cpp @@ -137,8 +137,8 @@ TEST (PCL, KdTree_differentPointT) copyPointCloud (cloud_big, cloud_rgb); std::vector< std::vector< float > > dists; - std::vector< std::vector< int > > indices; - kdtree.nearestKSearchT (cloud_rgb, std::vector (),no_of_neighbors,indices,dists); + std::vector< pcl::Indices > indices; + kdtree.nearestKSearchT (cloud_rgb, pcl::Indices (),no_of_neighbors,indices,dists); pcl::Indices k_indices; k_indices.resize (no_of_neighbors); @@ -175,8 +175,8 @@ TEST (PCL, KdTree_multipointKnnSearch) kdtree.setInputCloud (cloud_big.makeShared ()); std::vector< std::vector< float > > dists; - std::vector< std::vector< int > > indices; - kdtree.nearestKSearch (cloud_big, std::vector (),no_of_neighbors,indices,dists); + std::vector< pcl::Indices > indices; + kdtree.nearestKSearch (cloud_big, pcl::Indices (),no_of_neighbors,indices,dists); pcl::Indices k_indices; k_indices.resize (no_of_neighbors); diff --git a/test/search/test_octree.cpp b/test/search/test_octree.cpp index 453e3b608a2..225dbf9152c 100644 --- a/test/search/test_octree.cpp +++ b/test/search/test_octree.cpp @@ -318,7 +318,7 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) } } - std::vector cloudNWRSearch; + pcl::Indices cloudNWRSearch; std::vector cloudNWRRadius; // execute octree radius search @@ -328,18 +328,15 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) ASSERT_EQ ( cloudNWRRadius.size() , cloudSearchBruteforce.size()); // check if result from octree radius search can be also found in bruteforce search - std::vector::const_iterator current = cloudNWRSearch.begin(); - while (current != cloudNWRSearch.end()) + for (const auto& current : cloudNWRSearch) { pointDist = sqrt ( - ((*cloudIn)[*current].x-searchPoint.x) * ((*cloudIn)[*current].x-searchPoint.x) + - ((*cloudIn)[*current].y-searchPoint.y) * ((*cloudIn)[*current].y-searchPoint.y) + - ((*cloudIn)[*current].z-searchPoint.z) * ((*cloudIn)[*current].z-searchPoint.z) + ((*cloudIn)[current].x-searchPoint.x) * ((*cloudIn)[current].x-searchPoint.x) + + ((*cloudIn)[current].y-searchPoint.y) * ((*cloudIn)[current].y-searchPoint.y) + + ((*cloudIn)[current].z-searchPoint.z) * ((*cloudIn)[current].z-searchPoint.z) ); ASSERT_EQ ( (pointDist<=searchRadius) , true); - - ++current; } // check if result limitation works diff --git a/test/search/test_organized.cpp b/test/search/test_organized.cpp index 3a407c4016d..f31e77365c8 100644 --- a/test/search/test_organized.cpp +++ b/test/search/test_organized.cpp @@ -84,7 +84,7 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Nearest_K_Neighbour_Search) // create organized search search::OrganizedNeighbor organizedNeighborSearch; - std::vector k_indices; + pcl::Indices k_indices; std::vector k_sqr_distances; std::vector k_indices_bruteforce; diff --git a/test/search/test_organized_index.cpp b/test/search/test_organized_index.cpp index cf821b82fad..88aedce6a31 100644 --- a/test/search/test_organized_index.cpp +++ b/test/search/test_organized_index.cpp @@ -179,7 +179,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search_Kinec // create organized search search::OrganizedNeighbor organizedNeighborSearch; - std::vector k_indices; + pcl::Indices k_indices; std::vector k_sqr_distances; std::vector k_indices_bruteforce; @@ -308,7 +308,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) } } - std::vector cloudNWRSearch; + pcl::Indices cloudNWRSearch; std::vector cloudNWRRadius; organizedNeighborSearch.setInputCloud (cloudIn); @@ -405,7 +405,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ } } - std::vector cloudNWRSearch; + pcl::Indices cloudNWRSearch; std::vector cloudNWRRadius; double check_time = getTime(); @@ -462,10 +462,10 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ double searchRadius = 1.0 * (test_id*1.0/10*1.0); double sum_time = 0, sum_time2 = 0; - std::vector cloudNWRSearch; + pcl::Indices cloudNWRSearch; std::vector cloudNWRRadius; - std::vector cloudNWRSearch2; + pcl::Indices cloudNWRSearch2; std::vector cloudNWRRadius2; for (int iter = 0; iter < 100; iter++) diff --git a/test/search/test_search.cpp b/test/search/test_search.cpp index 557acbd5c5f..f72b06156d9 100644 --- a/test/search/test_search.cpp +++ b/test/search/test_search.cpp @@ -103,10 +103,10 @@ std::uniform_int_distribution rand_uint(0, 10); std::uniform_real_distribution rand_float (0.0f, 1.0f); /** \brief used by the *_VIEW_* tests to use only a subset of points from the point cloud*/ -std::vector unorganized_input_indices; +pcl::Indices unorganized_input_indices; /** \brief used by the *_VIEW_* tests to use only a subset of points from the point cloud*/ -std::vector organized_input_indices; +pcl::Indices organized_input_indices; /** \brief instance of brute force search method to be tested*/ pcl::search::BruteForce brute_force; @@ -136,7 +136,7 @@ std::vector organized_sparse_query_indices; * @param name name of the search method that returned these distances * @return true if indices are unique, false otherwise */ -bool testUniqueness (const std::vector& indices, const std::string& name) +bool testUniqueness (const pcl::Indices& indices, const std::string& name) { bool uniqueness = true; for (unsigned idx1 = 1; idx1 < indices.size () && uniqueness; ++idx1) @@ -191,7 +191,7 @@ bool testOrder (const std::vector& distances, const std::string& name) * @return true if result is valid, false otherwise */ template bool -testResultValidity (const typename PointCloud::ConstPtr point_cloud, const std::vector& indices_mask, const std::vector& nan_mask, const std::vector& indices, const std::vector& /*input_indices*/, const std::string& name) +testResultValidity (const typename PointCloud::ConstPtr point_cloud, const std::vector& indices_mask, const std::vector& nan_mask, const pcl::Indices& indices, const pcl::Indices& /*input_indices*/, const std::string& name) { bool validness = true; for (const auto &index : indices) @@ -282,9 +282,9 @@ bool compareResults (const std::vector& indices1, const std::vector& */ template void testKNNSearch (typename PointCloud::ConstPtr point_cloud, std::vector*> search_methods, - const std::vector& query_indices, const std::vector& input_indices = std::vector () ) + const pcl::Indices& query_indices, const pcl::Indices& input_indices = pcl::Indices () ) { - std::vector< std::vector >indices (search_methods.size ()); + std::vector< pcl::Indices >indices (search_methods.size ()); std::vector< std::vector >distances (search_methods.size ()); std::vector passed (search_methods.size (), true); @@ -361,9 +361,9 @@ testKNNSearch (typename PointCloud::ConstPtr point_cloud, std::vector void testRadiusSearch (typename PointCloud::ConstPtr point_cloud, std::vector*> search_methods, - const std::vector& query_indices, const std::vector& input_indices = std::vector ()) + const pcl::Indices& query_indices, const pcl::Indices& input_indices = pcl::Indices ()) { - std::vector< std::vector >indices (search_methods.size ()); + std::vector< pcl::Indices >indices (search_methods.size ()); std::vector< std::vector >distances (search_methods.size ()); std::vector passed (search_methods.size (), true); std::vector indices_mask (point_cloud->size (), true); @@ -558,7 +558,7 @@ void createQueryIndices (std::vector& query_indices, PointCloud:: * \param indices * \param max_index highest accented index usually given by cloud->size () - 1 */ -void createIndices (std::vector& indices, unsigned max_index) +void createIndices (pcl::Indices& indices, unsigned max_index) { // ~10% of the input cloud for (unsigned idx = 0; idx <= max_index; ++idx) diff --git a/tools/octree_viewer.cpp b/tools/octree_viewer.cpp index 3fed3787bab..8b7bbe95b28 100644 --- a/tools/octree_viewer.cpp +++ b/tools/octree_viewer.cpp @@ -212,7 +212,7 @@ class OctreeViewer } //remove NaN Points - std::vector nanIndexes; + pcl::Indices nanIndexes; pcl::removeNaNFromPointCloud(*cloud, *cloud, nanIndexes); std::cout << "Loaded " << cloud->size() << " points" << std::endl; diff --git a/tools/pcd_viewer.cpp b/tools/pcd_viewer.cpp index ab519694de9..175e66d811c 100644 --- a/tools/pcd_viewer.cpp +++ b/tools/pcd_viewer.cpp @@ -168,7 +168,7 @@ pp_callback (const pcl::visualization::PointPickingEvent& event, void* cookie) search.setInputCloud (xyzcloud); } // Return the correct index in the cloud instead of the index on the screen - std::vector indices (1); + pcl::Indices indices (1); std::vector distances (1); // Because VTK/OpenGL stores data without NaN, we lose the 1-1 correspondence, so we must search for the real point diff --git a/tracking/include/pcl/tracking/impl/approx_nearest_pair_point_cloud_coherence.hpp b/tracking/include/pcl/tracking/impl/approx_nearest_pair_point_cloud_coherence.hpp index 7d7bede772d..60c856646c4 100644 --- a/tracking/include/pcl/tracking/impl/approx_nearest_pair_point_cloud_coherence.hpp +++ b/tracking/include/pcl/tracking/impl/approx_nearest_pair_point_cloud_coherence.hpp @@ -14,7 +14,7 @@ ApproxNearestPairPointCloudCoherence::computeCoherence( double val = 0.0; // for (std::size_t i = 0; i < indices->size (); i++) for (const auto& point : *cloud) { - int k_index = 0; + pcl::index_t k_index = 0; float k_distance = 0.0; // PointInT input_point = cloud->points[(*indices)[i]]; PointInT input_point = point; diff --git a/tracking/include/pcl/tracking/impl/kld_adaptive_particle_filter_omp.hpp b/tracking/include/pcl/tracking/impl/kld_adaptive_particle_filter_omp.hpp index 46716bb9c14..8b036574c3e 100644 --- a/tracking/include/pcl/tracking/impl/kld_adaptive_particle_filter_omp.hpp +++ b/tracking/include/pcl/tracking/impl/kld_adaptive_particle_filter_omp.hpp @@ -78,7 +78,7 @@ KLDAdaptiveParticleFilterOMPTracker::weight() else { std::vector indices_list(particle_num_); for (int i = 0; i < particle_num_; i++) { - indices_list[i] = IndicesPtr(new std::vector); + indices_list[i] = IndicesPtr(new pcl::Indices); } // clang-format off #pragma omp parallel for \ diff --git a/tracking/include/pcl/tracking/impl/nearest_pair_point_cloud_coherence.hpp b/tracking/include/pcl/tracking/impl/nearest_pair_point_cloud_coherence.hpp index bcd33d6b398..5987bfcb0ff 100644 --- a/tracking/include/pcl/tracking/impl/nearest_pair_point_cloud_coherence.hpp +++ b/tracking/include/pcl/tracking/impl/nearest_pair_point_cloud_coherence.hpp @@ -15,7 +15,7 @@ NearestPairPointCloudCoherence::computeCoherence( // for (std::size_t i = 0; i < indices->size (); i++) for (std::size_t i = 0; i < cloud->size(); i++) { PointInT input_point = (*cloud)[i]; - std::vector k_indices(1); + pcl::Indices k_indices(1); std::vector k_distances(1); search_->nearestKSearch(input_point, 1, k_indices, k_distances); int k_index = k_indices[0]; diff --git a/tracking/include/pcl/tracking/impl/particle_filter.hpp b/tracking/include/pcl/tracking/impl/particle_filter.hpp index feba46da47c..36fdcc90a6e 100644 --- a/tracking/include/pcl/tracking/impl/particle_filter.hpp +++ b/tracking/include/pcl/tracking/impl/particle_filter.hpp @@ -220,7 +220,7 @@ ParticleFilterTracker::testChangeDetection( { change_detector_->setInputCloud(input); change_detector_->addPointsFromInputCloud(); - std::vector newPointIdxVector; + pcl::Indices newPointIdxVector; change_detector_->getPointIndicesFromNewVoxels(newPointIdxVector, change_detector_filter_); change_detector_->switchBuffers(); @@ -250,7 +250,7 @@ ParticleFilterTracker::weight() } else { for (std::size_t i = 0; i < particles_->size(); i++) { - IndicesPtr indices(new std::vector); + IndicesPtr indices(new pcl::Indices); computeTransformedPointCloudWithNormal( (*particles_)[i], *indices, *transed_reference_vector_[i]); } @@ -261,7 +261,7 @@ ParticleFilterTracker::weight() coherence_->setTargetCloud(coherence_input); coherence_->initCompute(); for (std::size_t i = 0; i < particles_->size(); i++) { - IndicesPtr indices(new std::vector); + IndicesPtr indices(new pcl::Indices); coherence_->compute( transed_reference_vector_[i], indices, (*particles_)[i].weight); } @@ -273,7 +273,7 @@ ParticleFilterTracker::weight() template void ParticleFilterTracker::computeTransformedPointCloud( - const StateT& hypothesis, std::vector& indices, PointCloudIn& cloud) + const StateT& hypothesis, pcl::Indices& indices, PointCloudIn& cloud) { if (use_normal_) computeTransformedPointCloudWithNormal(hypothesis, indices, cloud); @@ -296,9 +296,9 @@ template void ParticleFilterTracker::computeTransformedPointCloudWithNormal( #ifdef PCL_TRACKING_NORMAL_SUPPORTED - const StateT& hypothesis, std::vector& indices, PointCloudIn& cloud) + const StateT& hypothesis, pcl::Indices& indices, PointCloudIn& cloud) #else - const StateT&, std::vector&, PointCloudIn&) + const StateT&, pcl::Indices&, PointCloudIn&) #endif { #ifdef PCL_TRACKING_NORMAL_SUPPORTED diff --git a/tracking/include/pcl/tracking/impl/particle_filter_omp.hpp b/tracking/include/pcl/tracking/impl/particle_filter_omp.hpp index 05534e96136..a4cd2a1ff66 100644 --- a/tracking/include/pcl/tracking/impl/particle_filter_omp.hpp +++ b/tracking/include/pcl/tracking/impl/particle_filter_omp.hpp @@ -77,7 +77,7 @@ ParticleFilterOMPTracker::weight() else { std::vector indices_list(particle_num_); for (int i = 0; i < particle_num_; i++) { - indices_list[i] = IndicesPtr(new std::vector); + indices_list[i] = IndicesPtr(new pcl::Indices); } // clang-format off #pragma omp parallel for \ diff --git a/tracking/include/pcl/tracking/particle_filter.h b/tracking/include/pcl/tracking/particle_filter.h index 8a325f103a0..7af302da10b 100644 --- a/tracking/include/pcl/tracking/particle_filter.h +++ b/tracking/include/pcl/tracking/particle_filter.h @@ -435,7 +435,7 @@ class ParticleFilterTracker : public Tracker { **/ void computeTransformedPointCloud(const StateT& hypothesis, - std::vector& indices, + pcl::Indices& indices, PointCloudIn& cloud); /** \brief Compute a reference pointcloud transformed to the pose that hypothesis @@ -447,7 +447,7 @@ class ParticleFilterTracker : public Tracker { **/ void computeTransformedPointCloudWithNormal(const StateT& hypothesis, - std::vector& indices, + pcl::Indices& indices, PointCloudIn& cloud); /** \brief Compute a reference pointcloud transformed to the pose that hypothesis From ff5216522d34bde8cfbac27b9f1d317353b77302 Mon Sep 17 00:00:00 2001 From: Rabah Nouri Date: Mon, 8 Mar 2021 16:26:00 -0500 Subject: [PATCH 030/431] Deprecate unneeded meta-headers (#4628) * Deprecate unneeded meta-headers Deprecated the following: pcl/common/boost.h, pcl/sample_consensus/boost.h, pcl/octree/boost.h, pcl/recognition/boost, pcl/features/boost, pcl/features/eigen.h, and correspondence_rejection_median_distance.hpp --- common/include/pcl/common/boost.h | 1 + features/include/pcl/features/boost.h | 2 +- features/include/pcl/features/boundary.h | 1 - features/include/pcl/features/eigen.h | 2 +- .../impl/statistical_multiscale_interest_region_extraction.hpp | 1 - features/include/pcl/features/narf.h | 1 - features/include/pcl/features/principal_curvatures.h | 1 - filters/include/pcl/filters/boost.h | 2 +- geometry/include/pcl/geometry/eigen.h | 2 +- io/include/pcl/io/eigen.h | 2 +- octree/include/pcl/octree/boost.h | 1 + recognition/include/pcl/recognition/boost.h | 1 + .../pcl/registration/correspondence_rejection_distance.h | 2 -- .../pcl/registration/correspondence_rejection_median_distance.h | 2 -- .../pcl/registration/correspondence_rejection_one_to_one.h | 2 -- .../registration/correspondence_rejection_organized_boundary.h | 2 -- .../pcl/registration/correspondence_rejection_surface_normal.h | 2 -- .../include/pcl/registration/correspondence_rejection_trimmed.h | 2 -- .../pcl/registration/correspondence_rejection_var_trimmed.h | 2 -- registration/include/pcl/registration/eigen.h | 2 +- .../pcl/registration/impl/correspondence_rejection_distance.hpp | 2 +- .../impl/correspondence_rejection_median_distance.hpp | 2 +- .../registration/impl/correspondence_rejection_one_to_one.hpp | 2 +- .../impl/correspondence_rejection_organized_boundary.hpp | 2 +- .../impl/correspondence_rejection_surface_normal.hpp | 2 +- .../pcl/registration/impl/correspondence_rejection_trimmed.hpp | 2 +- .../registration/impl/correspondence_rejection_var_trimmed.hpp | 2 +- sample_consensus/include/pcl/sample_consensus/boost.h | 1 + surface/include/pcl/surface/boost.h | 2 +- surface/include/pcl/surface/eigen.h | 2 +- visualization/include/pcl/visualization/eigen.h | 2 +- 31 files changed, 20 insertions(+), 34 deletions(-) diff --git a/common/include/pcl/common/boost.h b/common/include/pcl/common/boost.h index 09908e61164..232d1df5f3b 100644 --- a/common/include/pcl/common/boost.h +++ b/common/include/pcl/common/boost.h @@ -41,6 +41,7 @@ #ifdef __GNUC__ #pragma GCC system_header #endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #ifndef Q_MOC_RUN // Marking all Boost headers as system headers to remove warnings diff --git a/features/include/pcl/features/boost.h b/features/include/pcl/features/boost.h index 53f51c529b0..4f49824a070 100644 --- a/features/include/pcl/features/boost.h +++ b/features/include/pcl/features/boost.h @@ -42,5 +42,5 @@ #if defined __GNUC__ # pragma GCC system_header #endif - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #include diff --git a/features/include/pcl/features/boundary.h b/features/include/pcl/features/boundary.h index 2c357ee0b71..c9bc22ade6a 100644 --- a/features/include/pcl/features/boundary.h +++ b/features/include/pcl/features/boundary.h @@ -40,7 +40,6 @@ #pragma once -#include #include namespace pcl diff --git a/features/include/pcl/features/eigen.h b/features/include/pcl/features/eigen.h index 3fcbb2784f1..563874881d6 100644 --- a/features/include/pcl/features/eigen.h +++ b/features/include/pcl/features/eigen.h @@ -42,6 +42,6 @@ #if defined __GNUC__ # pragma GCC system_header #endif - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include #include diff --git a/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp b/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp index 50ae066c745..29915489880 100644 --- a/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp +++ b/features/include/pcl/features/impl/statistical_multiscale_interest_region_extraction.hpp @@ -44,7 +44,6 @@ #include #include #include // for PCL_INFO, PCL_ERROR -#include #include #include diff --git a/features/include/pcl/features/narf.h b/features/include/pcl/features/narf.h index 34dbfacf39f..6d8075137cc 100644 --- a/features/include/pcl/features/narf.h +++ b/features/include/pcl/features/narf.h @@ -40,7 +40,6 @@ #include #include -#include #include #include diff --git a/features/include/pcl/features/principal_curvatures.h b/features/include/pcl/features/principal_curvatures.h index 4e3db382f0d..620259947dd 100644 --- a/features/include/pcl/features/principal_curvatures.h +++ b/features/include/pcl/features/principal_curvatures.h @@ -40,7 +40,6 @@ #pragma once -#include #include namespace pcl diff --git a/filters/include/pcl/filters/boost.h b/filters/include/pcl/filters/boost.h index 173598740c3..273c1e67729 100644 --- a/filters/include/pcl/filters/boost.h +++ b/filters/include/pcl/filters/boost.h @@ -43,7 +43,7 @@ #ifdef __GNUC__ #pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") // Marking all Boost headers as system headers to remove warnings #include diff --git a/geometry/include/pcl/geometry/eigen.h b/geometry/include/pcl/geometry/eigen.h index 5426890c56b..2f250e29e23 100644 --- a/geometry/include/pcl/geometry/eigen.h +++ b/geometry/include/pcl/geometry/eigen.h @@ -43,7 +43,7 @@ #ifdef __GNUC__ #pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include #include diff --git a/io/include/pcl/io/eigen.h b/io/include/pcl/io/eigen.h index e51bdc55217..0979ece907e 100644 --- a/io/include/pcl/io/eigen.h +++ b/io/include/pcl/io/eigen.h @@ -40,6 +40,6 @@ #if defined __GNUC__ # pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include diff --git a/octree/include/pcl/octree/boost.h b/octree/include/pcl/octree/boost.h index 3510b239c6f..b3680aab8c7 100644 --- a/octree/include/pcl/octree/boost.h +++ b/octree/include/pcl/octree/boost.h @@ -42,6 +42,7 @@ #ifdef __GNUC__ #pragma GCC system_header #endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") // Marking all Boost headers as system headers to remove warnings #include diff --git a/recognition/include/pcl/recognition/boost.h b/recognition/include/pcl/recognition/boost.h index f129eda2759..44e705be245 100644 --- a/recognition/include/pcl/recognition/boost.h +++ b/recognition/include/pcl/recognition/boost.h @@ -42,5 +42,6 @@ #if defined __GNUC__ # pragma GCC system_header #endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #include diff --git a/registration/include/pcl/registration/correspondence_rejection_distance.h b/registration/include/pcl/registration/correspondence_rejection_distance.h index 9cc78360623..053579649c7 100644 --- a/registration/include/pcl/registration/correspondence_rejection_distance.h +++ b/registration/include/pcl/registration/correspondence_rejection_distance.h @@ -203,5 +203,3 @@ class PCL_EXPORTS CorrespondenceRejectorDistance : public CorrespondenceRejector } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/correspondence_rejection_median_distance.h b/registration/include/pcl/registration/correspondence_rejection_median_distance.h index a7c4e6ee7be..0d5f00c60bd 100644 --- a/registration/include/pcl/registration/correspondence_rejection_median_distance.h +++ b/registration/include/pcl/registration/correspondence_rejection_median_distance.h @@ -208,5 +208,3 @@ class PCL_EXPORTS CorrespondenceRejectorMedianDistance : public CorrespondenceRe }; } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/correspondence_rejection_one_to_one.h b/registration/include/pcl/registration/correspondence_rejection_one_to_one.h index 725a6b12b04..d094c70e6cd 100644 --- a/registration/include/pcl/registration/correspondence_rejection_one_to_one.h +++ b/registration/include/pcl/registration/correspondence_rejection_one_to_one.h @@ -90,5 +90,3 @@ class PCL_EXPORTS CorrespondenceRejectorOneToOne : public CorrespondenceRejector } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/correspondence_rejection_organized_boundary.h b/registration/include/pcl/registration/correspondence_rejection_organized_boundary.h index 22edd12f0f1..25ec0d9581e 100644 --- a/registration/include/pcl/registration/correspondence_rejection_organized_boundary.h +++ b/registration/include/pcl/registration/correspondence_rejection_organized_boundary.h @@ -150,5 +150,3 @@ class PCL_EXPORTS CorrespondenceRejectionOrganizedBoundary }; } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/correspondence_rejection_surface_normal.h b/registration/include/pcl/registration/correspondence_rejection_surface_normal.h index a9338d0d6f3..520276105c1 100644 --- a/registration/include/pcl/registration/correspondence_rejection_surface_normal.h +++ b/registration/include/pcl/registration/correspondence_rejection_surface_normal.h @@ -351,5 +351,3 @@ class PCL_EXPORTS CorrespondenceRejectorSurfaceNormal : public CorrespondenceRej }; } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/correspondence_rejection_trimmed.h b/registration/include/pcl/registration/correspondence_rejection_trimmed.h index c0be69400a5..66e0def0eec 100644 --- a/registration/include/pcl/registration/correspondence_rejection_trimmed.h +++ b/registration/include/pcl/registration/correspondence_rejection_trimmed.h @@ -143,5 +143,3 @@ class PCL_EXPORTS CorrespondenceRejectorTrimmed : public CorrespondenceRejector } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/correspondence_rejection_var_trimmed.h b/registration/include/pcl/registration/correspondence_rejection_var_trimmed.h index 746a67448e5..e5b5c7a7aa6 100644 --- a/registration/include/pcl/registration/correspondence_rejection_var_trimmed.h +++ b/registration/include/pcl/registration/correspondence_rejection_var_trimmed.h @@ -260,5 +260,3 @@ class PCL_EXPORTS CorrespondenceRejectorVarTrimmed : public CorrespondenceReject }; } // namespace registration } // namespace pcl - -#include diff --git a/registration/include/pcl/registration/eigen.h b/registration/include/pcl/registration/eigen.h index 713a78cfea3..5712e8fcac4 100644 --- a/registration/include/pcl/registration/eigen.h +++ b/registration/include/pcl/registration/eigen.h @@ -42,7 +42,7 @@ #if defined __GNUC__ #pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include #include diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_distance.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_distance.hpp index 67e55bf7638..680ed690c7f 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_distance.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_distance.hpp @@ -39,5 +39,5 @@ */ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_DISTANCE_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_DISTANCE_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_DISTANCE_HPP_ */ diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_median_distance.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_median_distance.hpp index 5e84fc7972b..eaa5364e9d7 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_median_distance.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_median_distance.hpp @@ -39,5 +39,5 @@ */ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_MEDIAN_DISTANCE_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_MEDIAN_DISTANCE_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif // PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_MEDIAN_DISTANCE_HPP_ diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_one_to_one.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_one_to_one.hpp index 656b6db8c87..3f256839477 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_one_to_one.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_one_to_one.hpp @@ -39,5 +39,5 @@ */ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_ONE_TO_ONE_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_ONE_TO_ONE_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_ONE_TO_ONE_HPP_ */ diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_organized_boundary.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_organized_boundary.hpp index a7a2fafa655..c70ea72ba5c 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_organized_boundary.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_organized_boundary.hpp @@ -38,5 +38,5 @@ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_ORGANIZED_BOUNDARY_HPP_ */ diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_surface_normal.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_surface_normal.hpp index 6509909b757..65e8bbc1ca9 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_surface_normal.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_surface_normal.hpp @@ -38,5 +38,5 @@ */ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SURFACE_NORMAL_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SURFACE_NORMAL_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_SURFACE_NORMAL_HPP_ */ diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_trimmed.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_trimmed.hpp index 0690e1dc371..9aee8cdad52 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_trimmed.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_trimmed.hpp @@ -39,5 +39,5 @@ */ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_TRIMMED_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_TRIMMED_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_TRIMMED_HPP_ */ diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_var_trimmed.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_var_trimmed.hpp index 53cd52fa31f..201c6d4a4a4 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_var_trimmed.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_var_trimmed.hpp @@ -38,5 +38,5 @@ */ #ifndef PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_VAR_TRIMMED_HPP_ #define PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_VAR_TRIMMED_HPP_ - +PCL_DEPRECATED_HEADER(1, 15, "") #endif /* PCL_REGISTRATION_IMPL_CORRESPONDENCE_REJECTION_VAR_TRIMMED_HPP_ */ diff --git a/sample_consensus/include/pcl/sample_consensus/boost.h b/sample_consensus/include/pcl/sample_consensus/boost.h index 4afdf893184..ea42ca4c2bb 100644 --- a/sample_consensus/include/pcl/sample_consensus/boost.h +++ b/sample_consensus/include/pcl/sample_consensus/boost.h @@ -42,5 +42,6 @@ #if defined __GNUC__ # pragma GCC system_header #endif +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #include diff --git a/surface/include/pcl/surface/boost.h b/surface/include/pcl/surface/boost.h index 3355853feb0..86aca4ea82c 100644 --- a/surface/include/pcl/surface/boost.h +++ b/surface/include/pcl/surface/boost.h @@ -42,6 +42,6 @@ #if defined __GNUC__ # pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #include diff --git a/surface/include/pcl/surface/eigen.h b/surface/include/pcl/surface/eigen.h index 089766aaf23..e3f46b0de21 100644 --- a/surface/include/pcl/surface/eigen.h +++ b/surface/include/pcl/surface/eigen.h @@ -42,6 +42,6 @@ #if defined __GNUC__ # pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include diff --git a/visualization/include/pcl/visualization/eigen.h b/visualization/include/pcl/visualization/eigen.h index 48c16a13427..09d57c502e4 100644 --- a/visualization/include/pcl/visualization/eigen.h +++ b/visualization/include/pcl/visualization/eigen.h @@ -42,7 +42,7 @@ #if defined __GNUC__ # pragma GCC system_header #endif -PCL_DEPRECATED_HEADER(1, 15, "") +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include #include From 2129f28d456c032ab94ca27471aebc0fcd12a8ed Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Tue, 9 Mar 2021 10:30:49 +0100 Subject: [PATCH 031/431] Rename loop variables and remove pointer --- .../include/pcl/people/impl/head_based_subcluster.hpp | 11 +++++------ people/include/pcl/people/impl/height_map_2d.hpp | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/people/include/pcl/people/impl/head_based_subcluster.hpp b/people/include/pcl/people/impl/head_based_subcluster.hpp index 46c8aa1e76d..4dd2e2f94ea 100644 --- a/people/include/pcl/people/impl/head_based_subcluster.hpp +++ b/people/include/pcl/people/impl/head_based_subcluster.hpp @@ -177,9 +177,9 @@ pcl::people::HeadBasedSubclustering::mergeClustersCloseInFloorCoordinate if (!used_clusters[cluster]) // if this cluster has not been used yet { used_clusters[cluster] = true; - for(const auto& points_iterator : input_clusters[cluster].getIndices().indices) + for(const auto& cluster_idx : input_clusters[cluster].getIndices().indices) { - point_indices.indices.push_back(points_iterator); + point_indices.indices.push_back(cluster_idx); } } } @@ -213,10 +213,9 @@ pcl::people::HeadBasedSubclustering::createSubClusters (pcl::people::Per } // Associate cluster points to one of the maximum: - for(const auto& points_iterator : cluster.getIndices().indices) + for(const auto& cluster_idx : cluster.getIndices().indices) { - PointT* current_point = &(*cloud_)[points_iterator]; // current point cloud point - Eigen::Vector3f p_current_eigen(current_point->x, current_point->y, current_point->z); // conversion to eigen + Eigen::Vector3f p_current_eigen((*cloud_)[cluster_idx].x, (*cloud_)[cluster_idx].y, (*cloud_)[cluster_idx].z); // conversion to eigen float t = p_current_eigen.dot(head_ground_coeffs) / normalize_factor; // height from the ground p_current_eigen -= head_ground_coeffs * t; // projection of the point on the groundplane @@ -227,7 +226,7 @@ pcl::people::HeadBasedSubclustering::createSubClusters (pcl::people::Per if (((p_current_eigen - maxima_projected.col(i)).norm()) < heads_minimum_distance_) { correspondence_detected = true; - sub_clusters_indices[i].push_back(points_iterator); + sub_clusters_indices[i].push_back(cluster_idx); subclusters_number_of_points(i)++; } else diff --git a/people/include/pcl/people/impl/height_map_2d.hpp b/people/include/pcl/people/impl/height_map_2d.hpp index de9852c3b0f..05632eb285a 100644 --- a/people/include/pcl/people/impl/height_map_2d.hpp +++ b/people/include/pcl/people/impl/height_map_2d.hpp @@ -85,9 +85,9 @@ pcl::people::HeightMap2D::compute (pcl::people::PersonCluster& c buckets_.resize(std::size_t((cluster.getMax()(1) - cluster.getMin()(1)) / bin_size_) + 1, 0); buckets_cloud_indices_.resize(buckets_.size(), 0); - for(const auto& pit : cluster.getIndices().indices) + for(const auto& cluster_idx : cluster.getIndices().indices) { - PointT* p = &(*cloud_)[pit]; + PointT* p = &(*cloud_)[cluster_idx]; int index; if (!vertical_) // camera horizontal index = int((p->x - cluster.getMin()(0)) / bin_size_); @@ -103,7 +103,7 @@ pcl::people::HeightMap2D::compute (pcl::people::PersonCluster& c if ((heightp * 60) > buckets_[index]) // compare the height of the new point with the existing one { buckets_[index] = heightp * 60; // maximum height - buckets_cloud_indices_[index] = pit; // point cloud index of the point with maximum height + buckets_cloud_indices_[index] = cluster_idx; // point cloud index of the point with maximum height } } } From 2225fab79bac23d2c1ecfb65b3f30e96fbb86153 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Wed, 10 Mar 2021 15:45:23 +0100 Subject: [PATCH 032/431] Improve test_octree_compression - Add additional test that encodes+decodes the same cloud multiple times - Add pcd file as argument so that test OctreeDeCompressionFile actually runs - Run tests for smaller clouds (MAX_XYZ=1.0) in addition to the larger clouds (MAX_XYZ=1024.0) - Make tests stricter: require exact dimensions unless voxel grid downsampling is enabled - Improve some formatting --- test/io/CMakeLists.txt | 3 +- test/io/test_octree_compression.cpp | 246 ++++++++++++++++++---------- 2 files changed, 164 insertions(+), 85 deletions(-) diff --git a/test/io/CMakeLists.txt b/test/io/CMakeLists.txt index 4443fb9b649..303ce71159a 100644 --- a/test/io/CMakeLists.txt +++ b/test/io/CMakeLists.txt @@ -52,4 +52,5 @@ PCL_ADD_TEST(buffers test_buffers PCL_ADD_TEST(io_octree_compression test_octree_compression FILES test_octree_compression.cpp - LINK_WITH pcl_gtest pcl_common pcl_io pcl_octree) + LINK_WITH pcl_gtest pcl_common pcl_io pcl_octree + ARGUMENTS "${PCL_SOURCE_DIR}/test/milk_color.pcd") diff --git a/test/io/test_octree_compression.cpp b/test/io/test_octree_compression.cpp index 3eb4beb633b..73d0736ff84 100644 --- a/test/io/test_octree_compression.cpp +++ b/test/io/test_octree_compression.cpp @@ -48,102 +48,182 @@ int total_runs = 0; char* pcd_file; #define MAX_POINTS 10000.0 -#define MAX_XYZ 1024.0 #define MAX_COLOR 255 -#define NUMBER_OF_TEST_RUNS 2 +#define NUMBER_OF_TEST_RUNS 3 TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) { srand(static_cast (time(NULL))); + for (const double MAX_XYZ : {1.0, 1024.0}) { // Small clouds, large clouds + // iterate over all pre-defined compression profiles + for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; + compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { + // instantiate point cloud compression encoder/decoder + pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); + pcl::io::OctreePointCloudCompression pointcloud_decoder; + pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); + // iterate over runs + for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) + { + try + { + int point_count; + do { // empty point cloud hangs decoder + point_count = MAX_POINTS * rand() / RAND_MAX; + } while (point_count < 1); + // create shared pointcloud instances + pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); + // assign input point clouds to octree + // create random point cloud + for (int point = 0; point < point_count; point++) + { + // generate a random point + pcl::PointXYZRGBA new_point; + new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); + new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), + new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); + new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); + // OctreePointCloudPointVector can store all points.. + cloud->push_back(new_point); + } + EXPECT_EQ(cloud->height, 1); + +// std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; + std::stringstream compressed_data; + pointcloud_encoder.encodePointCloud(cloud, compressed_data); + pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); + if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { + EXPECT_GT(cloud_out->width, 0); + EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; + } + else { + EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; + } + EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; + } + catch (std::exception& e) + { + std::cout << e.what() << std::endl; + } + } // runs + } // compression profiles + } // small clouds, large clouds +} // TEST +TEST (PCL, OctreeDeCompressionRandomPointXYZ) +{ + srand(static_cast (time(NULL))); + for (const double MAX_XYZ : {1.0, 1024.0}) { // Small clouds, large clouds // iterate over all pre-defined compression profiles - for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; - compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { - // instantiate point cloud compression encoder/decoder - pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); - pcl::io::OctreePointCloudCompression pointcloud_decoder; - pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); - // iterate over runs - for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) + for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; + compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { - try + // instantiate point cloud compression encoder/decoder + pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); + pcl::io::OctreePointCloudCompression pointcloud_decoder; + pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); + // loop over runs + for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - int point_count = MAX_POINTS * rand() / RAND_MAX; - if (point_count < 1) - { // empty point cloud hangs decoder - total_runs--; - continue; - } + int point_count; + do { // empty point cloud hangs decoder + point_count = MAX_POINTS * rand() / RAND_MAX; + } while (point_count < 1); // create shared pointcloud instances - pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); + pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); // assign input point clouds to octree // create random point cloud for (int point = 0; point < point_count; point++) { - // gereate a random point - pcl::PointXYZRGBA new_point; - new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), - new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); - // OctreePointCloudPointVector can store all points.. + // generate a random point + pcl::PointXYZ new_point(static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_XYZ * rand() / RAND_MAX)); cloud->push_back(new_point); } - -// std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; + EXPECT_EQ(cloud->height, 1); + // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; std::stringstream compressed_data; - pointcloud_encoder.encodePointCloud(cloud, compressed_data); - pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); - EXPECT_GT((int)cloud_out->width, 0) << "decoded PointCloud width <= 0"; - EXPECT_GT((int)cloud_out->height, 0) << " decoded PointCloud height <= 0 "; - } - catch (std::exception& e) - { - std::cout << e.what() << std::endl; - } - } // runs - } // compression profiles + try + { // decodePointCloud() throws exceptions on errors + pointcloud_encoder.encodePointCloud(cloud, compressed_data); + pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); + if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { + EXPECT_GT(cloud_out->width, 0); + EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; + } + else { + EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; + } + EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; + } + catch (std::exception& e) + { + std::cout << e.what() << std::endl; + } + } // runs + } // compression profiles + } // small clouds, large clouds } // TEST -TEST (PCL, OctreeDeCompressionRandomPointXYZ) +TEST (PCL, OctreeDeCompressionRandomPointXYZRGBASameCloud) { + // Generate a random cloud. Put it into the encoder several times and make + // sure that the decoded cloud has correct width and height each time. + const double MAX_XYZ = 1.0; srand(static_cast (time(NULL))); - // iterate over all pre-defined compression profiles for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; - compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) - { + compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { // instantiate point cloud compression encoder/decoder - pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); - pcl::io::OctreePointCloudCompression pointcloud_decoder; - pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); - // loop over runs + pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); + pcl::io::OctreePointCloudCompression pointcloud_decoder; + + int point_count; + do { // empty point cloud hangs decoder + point_count = MAX_POINTS * rand() / RAND_MAX; + } while (point_count < 1); + // create shared pointcloud instances + pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); + // assign input point clouds to octree + // create random point cloud + for (int point = 0; point < point_count; point++) + { + // generate a random point + pcl::PointXYZRGBA new_point; + new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); + new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), + new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); + new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); + // OctreePointCloudPointVector can store all points.. + cloud->push_back(new_point); + } + EXPECT_EQ(cloud->height, 1); + + // iterate over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - int point_count = MAX_POINTS * rand() / RAND_MAX; - // create shared pointcloud instances - pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); - // assign input point clouds to octree - // create random point cloud - for (int point = 0; point < point_count; point++) - { - // generate a random point - pcl::PointXYZ new_point(static_cast (MAX_XYZ * rand() / RAND_MAX), - static_cast (MAX_XYZ * rand() / RAND_MAX), - static_cast (MAX_XYZ * rand() / RAND_MAX)); - cloud->push_back(new_point); - } -// std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; - std::stringstream compressed_data; try - { // decodePointCloud() throws exceptions on errors + { +// std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; + std::stringstream compressed_data; + pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); pointcloud_encoder.encodePointCloud(cloud, compressed_data); pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); - EXPECT_GT((int)cloud_out->width, 0) << "decoded PointCloud width <= 0"; - EXPECT_GT((int)cloud_out->height, 0) << " decoded PointCloud height <= 0 "; + if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { + EXPECT_GT(cloud_out->width, 0); + EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; + } + else { + EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; + } + EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; } catch (std::exception& e) { @@ -159,36 +239,34 @@ TEST(PCL, OctreeDeCompressionFile) // load point cloud from file, when present if (pcd_file == NULL) return; - int rv = pcl::io::loadPCDFile(pcd_file, *input_cloud_ptr); - float voxel_sizes[] = { 0.1, 0.01 }; + int rv = pcl::io::loadPCDFile(pcd_file, *input_cloud_ptr); + float voxel_sizes[] = { 0.1, 0.01 }; - EXPECT_EQ(rv, 0) << " loadPCDFile " << pcd_file; - EXPECT_GT((int) input_cloud_ptr->width , 0) << "invalid point cloud width from " << pcd_file; - EXPECT_GT((int) input_cloud_ptr->height, 0) << "invalid point cloud height from " << pcd_file; + EXPECT_EQ(rv, 0) << " loadPCDFile " << pcd_file; + EXPECT_GT(input_cloud_ptr->width , 0) << "invalid point cloud width from " << pcd_file; + EXPECT_GT(input_cloud_ptr->height, 0) << "invalid point cloud height from " << pcd_file; - // iterate over compression profiles - for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; - compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { + // iterate over compression profiles + for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; + compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { // instantiate point cloud compression encoder/decoder - pcl::io::OctreePointCloudCompression* PointCloudEncoder = new pcl::io::OctreePointCloudCompression((pcl::io::compression_Profiles_e) compression_profile, false); - pcl::io::OctreePointCloudCompression* PointCloudDecoder = new pcl::io::OctreePointCloudCompression(); + pcl::io::OctreePointCloudCompression PointCloudEncoder((pcl::io::compression_Profiles_e) compression_profile, false); + pcl::io::OctreePointCloudCompression PointCloudDecoder; // iterate over various voxel sizes for (std::size_t i = 0; i < sizeof(voxel_sizes)/sizeof(voxel_sizes[0]); i++) { pcl::octree::OctreePointCloud octree(voxel_sizes[i]); - pcl::PointCloud::Ptr octree_out(new pcl::PointCloud()); + pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); octree.setInputCloud((*input_cloud_ptr).makeShared()); octree.addPointsFromInputCloud(); std::stringstream compressedData; - PointCloudEncoder->encodePointCloud(octree.getInputCloud(), compressedData); - PointCloudDecoder->decodePointCloud(compressedData, octree_out); - EXPECT_GT((int)octree_out->width, 0) << "decoded PointCloud width <= 0"; - EXPECT_GT((int)octree_out->height, 0) << " decoded PointCloud height <= 0 "; + PointCloudEncoder.encodePointCloud(octree.getInputCloud(), compressedData); + PointCloudDecoder.decodePointCloud(compressedData, cloud_out); + EXPECT_GT(cloud_out->width, 0) << "decoded PointCloud width <= 0"; + EXPECT_GT(cloud_out->height, 0) << " decoded PointCloud height <= 0 "; total_runs++; } - delete PointCloudDecoder; - delete PointCloudEncoder; } } From 15caa6e95a0c62c9f33da634d0636770075cb675 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Thu, 11 Mar 2021 09:50:27 +0530 Subject: [PATCH 033/431] [docker] Update CUDA version on 20.04 and add 21.04 image --- .ci/azure-pipelines/env.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.ci/azure-pipelines/env.yml b/.ci/azure-pipelines/env.yml index 264efa3d904..5344a52400c 100644 --- a/.ci/azure-pipelines/env.yml +++ b/.ci/azure-pipelines/env.yml @@ -46,18 +46,25 @@ jobs: VTK_VERSION: 6 tag: 18.04 Ubuntu 20.04: - CUDA_VERSION: 11.1 + CUDA_VERSION: 11.2.1 UBUNTU_DISTRO: 20.04 VTK_VERSION: 7 USE_CUDA: true tag: 20.04 Ubuntu 20.10: - CUDA_VERSION: 11.1 + CUDA_VERSION: 11.2.1 UBUNTU_DISTRO: 20.10 VTK_VERSION: 7 # nvidia-cuda docker image has not been released for 20.10 yet USE_CUDA: "" tag: 20.10 + Ubuntu 21.04: + CUDA_VERSION: 11.2.1 + UBUNTU_DISTRO: 21.04 + VTK_VERSION: 9 + # nvidia-cuda docker image has not been released for 20.10 yet + USE_CUDA: "" + tag: 21.04 steps: - task: Docker@2 displayName: "Build docker image" From dc6e85465aa7603f5eeef0310f8aa07e9a0c4814 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 11 Mar 2021 11:21:08 +0100 Subject: [PATCH 034/431] Use more pcl::Indices in apps, recognition, registration, ... --- .../feature_wrapper/normal_estimator.h | 2 +- .../pipeline/global_nn_classifier.h | 6 +- .../pipeline/global_nn_recognizer_crh.h | 4 +- .../pipeline/global_nn_recognizer_cvfh.h | 4 +- .../pipeline/local_recognizer.h | 4 +- apps/in_hand_scanner/src/icp.cpp | 2 +- apps/in_hand_scanner/src/integration.cpp | 2 +- apps/include/pcl/apps/nn_classification.h | 19 +++---- apps/src/feature_matching.cpp | 6 +- apps/src/ni_linemod.cpp | 4 +- apps/src/openni_feature_persistence.cpp | 2 +- apps/src/pcd_select_object_plane.cpp | 6 +- .../cluster_extraction/cluster_extraction.cpp | 4 +- .../don_segmentation/don_segmentation.cpp | 4 +- .../segmentation/example_region_growing.cpp | 8 +-- .../impl/multiscale_feature_persistence.hpp | 2 +- .../features/multiscale_feature_persistence.h | 2 +- .../include/pcl/keypoints/impl/susan.hpp | 4 +- .../pcl/outofcore/impl/octree_base.hpp | 2 +- .../pcl/outofcore/impl/octree_base_node.hpp | 2 +- .../recognition/hv/hypotheses_verification.h | 2 +- .../pcl/recognition/hv/occlusion_reasoning.h | 4 +- .../impl/hv/greedy_verification.hpp | 2 +- .../include/pcl/recognition/impl/hv/hv_go.hpp | 6 +- .../pcl/recognition/impl/hv/hv_papazov.hpp | 2 +- .../impl/hv/occlusion_reasoning.hpp | 4 +- .../pcl/recognition/implicit_shape_model.h | 2 +- .../recognition/ransac_based/trimmed_icp.h | 2 +- .../registration/correspondence_rejection.h | 4 +- registration/include/pcl/registration/gicp.h | 2 +- .../include/pcl/registration/gicp6d.h | 2 +- .../impl/correspondence_estimation.hpp | 6 +- ...respondence_rejection_sample_consensus.hpp | 6 +- .../include/pcl/registration/impl/gicp.hpp | 4 +- .../pcl/registration/impl/ia_ransac.hpp | 2 +- .../pcl/registration/impl/registration.hpp | 2 +- registration/src/gicp6d.cpp | 4 +- .../impl/grabcut_segmentation.hpp | 4 +- test/filters/test_clipper.cpp | 56 +++++++++---------- test/search/test_flann_search.cpp | 8 +-- test/search/test_organized.cpp | 25 +++------ test/search/test_search.cpp | 14 ++--- tools/crf_segmentation.cpp | 2 +- tools/progressive_morphological_filter.cpp | 2 +- tools/unary_classifier_segment.cpp | 2 +- 45 files changed, 124 insertions(+), 134 deletions(-) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h index e1e7a132970..0e2a86f8b55 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h @@ -30,7 +30,7 @@ class PreProcessorAndNormalEstimator { KdTreeInPtr tree = pcl::make_shared>(false); tree->setInputCloud(input); - std::vector nn_indices(9); + pcl::Indices nn_indices(9); std::vector nn_distances(9); std::vector src_indices; diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_classifier.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_classifier.h index 7b96958227e..d6554df8260 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_classifier.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_classifier.h @@ -33,7 +33,7 @@ class PCL_EXPORTS GlobalClassifier { classify() = 0; virtual void - setIndices(std::vector& indices) = 0; + setIndices(pcl::Indices& indices) = 0; virtual void setInputCloud(const PointInTPtr& cloud) = 0; @@ -91,7 +91,7 @@ class PCL_EXPORTS GlobalNNPipeline flann::Index* flann_index_; std::vector flann_models_; - std::vector indices_; + pcl::Indices indices_; // load features from disk and create flann structure void @@ -185,7 +185,7 @@ class PCL_EXPORTS GlobalNNPipeline } void - setIndices(std::vector& indices) override + setIndices(pcl::Indices& indices) override { indices_ = indices; } diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_crh.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_crh.h index fb597bb1bcd..ff3bde4e537 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_crh.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_crh.h @@ -95,7 +95,7 @@ class PCL_EXPORTS GlobalNNCRHRecognizer { poses_cache_; std::map, Eigen::Vector3f> centroids_cache_; - std::vector indices_; + pcl::Indices indices_; // load features from disk and create flann structure void @@ -216,7 +216,7 @@ class PCL_EXPORTS GlobalNNCRHRecognizer { } void - setIndices(std::vector& indices) + setIndices(pcl::Indices& indices) { indices_ = indices; } diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_cvfh.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_cvfh.h index 82e9cc3442f..54c5076c2d8 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_cvfh.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/global_nn_recognizer_cvfh.h @@ -130,7 +130,7 @@ class PCL_EXPORTS GlobalNNCVFHRecognizer { poses_cache_; std::map, Eigen::Vector3f> centroids_cache_; - std::vector indices_; + pcl::Indices indices_; bool compute_scale_; @@ -295,7 +295,7 @@ class PCL_EXPORTS GlobalNNCVFHRecognizer { } void - setIndices(std::vector& indices) + setIndices(pcl::Indices& indices) { indices_ = indices; } diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h index 8ef60a94427..99fa9f7c11c 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pipeline/local_recognizer.h @@ -80,7 +80,7 @@ class PCL_EXPORTS LocalRecognitionPipeline { flann::Index* flann_index_; std::vector flann_models_; - std::vector indices_; + pcl::Indices indices_; bool use_cache_; std::map, @@ -242,7 +242,7 @@ class PCL_EXPORTS LocalRecognitionPipeline { } void - setIndices(std::vector& indices) + setIndices(pcl::Indices& indices) { indices_ = indices; } diff --git a/apps/in_hand_scanner/src/icp.cpp b/apps/in_hand_scanner/src/icp.cpp index 0688595ed46..8f21a802e35 100644 --- a/apps/in_hand_scanner/src/icp.cpp +++ b/apps/in_hand_scanner/src/icp.cpp @@ -203,7 +203,7 @@ pcl::ihs::ICP::findTransformation (const MeshConstPtr& mesh_model, kd_tree_->setInputCloud (cloud_model_selected); t_build = sw.getTime (); - std::vector index (1); + pcl::Indices index (1); std::vector squared_distance (1); // Clouds with one to one correspondences diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index 565a8ecb610..76fca477f30 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -219,7 +219,7 @@ pcl::ihs::Integration::merge (const CloudXYZRGBNormalConstPtr& cloud_data, xyz_model->push_back (PointXYZ (pt.x, pt.y, pt.z)); } kd_tree_->setInputCloud (xyz_model); - std::vector index (1); + pcl::Indices index (1); std::vector squared_distance (1); mesh_model->reserveVertices (mesh_model->sizeVertices () + cloud_data->size ()); diff --git a/apps/include/pcl/apps/nn_classification.h b/apps/include/pcl/apps/nn_classification.h index fcca0ec6ef8..701510a9ebb 100644 --- a/apps/include/pcl/apps/nn_classification.h +++ b/apps/include/pcl/apps/nn_classification.h @@ -191,7 +191,7 @@ class NNClassification { ResultPtr classify(const PointT& p_q, double radius, float gaussian_param, int max_nn = INT_MAX) { - std::vector k_indices; + pcl::Indices k_indices; std::vector k_sqr_distances; getSimilarExemplars(p_q, radius, k_indices, k_sqr_distances, max_nn); return getGaussianBestScores(gaussian_param, k_indices, k_sqr_distances); @@ -210,7 +210,7 @@ class NNClassification { int getKNearestExemplars(const PointT& p_q, int k, - std::vector& k_indices, + pcl::Indices& k_indices, std::vector& k_sqr_distances) { k_indices.resize(k); @@ -230,7 +230,7 @@ class NNClassification { int getSimilarExemplars(const PointT& p_q, double radius, - std::vector& k_indices, + pcl::Indices& k_indices, std::vector& k_sqr_distances, int max_nn = INT_MAX) { @@ -244,17 +244,16 @@ class NNClassification { * \return a square distance to each training class */ std::shared_ptr> - getSmallestSquaredDistances(std::vector& k_indices, + getSmallestSquaredDistances(pcl::Indices& k_indices, std::vector& k_sqr_distances) { // Reserve space for distances auto sqr_distances = std::make_shared>(classes_.size(), FLT_MAX); // Select square distance to each class - for (std::vector::const_iterator i = k_indices.begin(); i != k_indices.end(); - ++i) - if ((*sqr_distances)[labels_idx_[*i]] > k_sqr_distances[i - k_indices.begin()]) - (*sqr_distances)[labels_idx_[*i]] = k_sqr_distances[i - k_indices.begin()]; + for (auto i = k_indices.cbegin(); i != k_indices.cend(); ++i) + if ((*sqr_distances)[labels_idx_[*i]] > k_sqr_distances[i - k_indices.cbegin()]) + (*sqr_distances)[labels_idx_[*i]] = k_sqr_distances[i - k_indices.cbegin()]; return sqr_distances; } @@ -267,7 +266,7 @@ class NNClassification { * \return pair of label and score for each training class from the neighborhood */ ResultPtr - getLinearBestScores(std::vector& k_indices, std::vector& k_sqr_distances) + getLinearBestScores(pcl::Indices& k_indices, std::vector& k_sqr_distances) { // Get smallest squared distances and transform them to a score for each class auto sqr_distances = getSmallestSquaredDistances(k_indices, k_sqr_distances); @@ -305,7 +304,7 @@ class NNClassification { */ ResultPtr getGaussianBestScores(float gaussian_param, - std::vector& k_indices, + pcl::Indices& k_indices, std::vector& k_sqr_distances) { // Get smallest squared distances and transform them to a score for each class diff --git a/apps/src/feature_matching.cpp b/apps/src/feature_matching.cpp index e1ee3c6408c..3fda149b8c2 100644 --- a/apps/src/feature_matching.cpp +++ b/apps/src/feature_matching.cpp @@ -222,7 +222,7 @@ ICCVTutorial::segmentation( extract.setNegative(true); extract.filter(*segmented); - std::vector indices; + pcl::Indices indices; pcl::removeNaNFromPointCloud(*segmented, *segmented, indices); std::cout << "OK" << std::endl; @@ -247,7 +247,7 @@ ICCVTutorial::segmentation( if (cluster_indices.size() > 1) std::cout << " Using largest one..."; std::cout << std::endl; - typename pcl::IndicesPtr indices(new std::vector); + typename pcl::IndicesPtr indices(new pcl::Indices); *indices = cluster_indices[0].indices; extract.setInputCloud(segmented); extract.setIndices(indices); @@ -326,7 +326,7 @@ ICCVTutorial::findCorrespondences( // Find the index of the best match for each keypoint, and store it in // "correspondences_out" const int k = 1; - std::vector k_indices(k); + pcl::Indices k_indices(k); std::vector k_squared_distances(k); for (int i = 0; i < static_cast(source->size()); ++i) { descriptor_kdtree.nearestKSearch(*source, i, k, k_indices, k_squared_distances); diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index 5b55674d1aa..54473f9794d 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -230,7 +230,7 @@ class NILinemod { for (int p_it = 0; p_it < static_cast(indices_fullset_.size()); ++p_it) indices_fullset_[p_it] = p_it; } - std::vector indices_subset = plane_indices->indices; + pcl::Indices indices_subset = plane_indices->indices; std::sort(indices_subset.begin(), indices_subset.end()); set_difference(indices_fullset_.begin(), indices_fullset_.end(), @@ -385,7 +385,7 @@ class NILinemod { if (idx == -1) return; - std::vector indices(1); + pcl::Indices indices(1); std::vector distances(1); // Use mutices to make sure we get the right cloud diff --git a/apps/src/openni_feature_persistence.cpp b/apps/src/openni_feature_persistence.cpp index 01b7d69a2ad..718109d9c3e 100644 --- a/apps/src/openni_feature_persistence.cpp +++ b/apps/src/openni_feature_persistence.cpp @@ -131,7 +131,7 @@ class OpenNIFeaturePersistence { cloud_subsampled_.reset(new typename pcl::PointCloud()); normals_.reset(new pcl::PointCloud()); features_.reset(new pcl::PointCloud()); - feature_indices_.reset(new std::vector()); + feature_indices_.reset(new pcl::Indices()); feature_locations_.reset(new typename pcl::PointCloud()); // Subsample input cloud diff --git a/apps/src/pcd_select_object_plane.cpp b/apps/src/pcd_select_object_plane.cpp index b4cf492089b..cb26deb2b0b 100644 --- a/apps/src/pcd_select_object_plane.cpp +++ b/apps/src/pcd_select_object_plane.cpp @@ -149,7 +149,7 @@ class ObjectSelection { * \param[out] object the segmented resultant object */ void - segmentObject(int picked_idx, + segmentObject(pcl::index_t picked_idx, const typename PointCloud::ConstPtr& cloud, const PointIndices::Ptr& plane_indices, PointCloud& object) @@ -258,7 +258,7 @@ class ObjectSelection { ///////////////////////////////////////////////////////////////////////// void segment(const PointT& picked_point, - int picked_idx, + pcl::index_t picked_idx, PlanarRegion& region, typename PointCloud::Ptr& object) { @@ -441,7 +441,7 @@ class ObjectSelection { if (idx == -1) return; - std::vector indices(1); + pcl::Indices indices(1); std::vector distances(1); // Get the point that was picked diff --git a/doc/tutorials/content/sources/cluster_extraction/cluster_extraction.cpp b/doc/tutorials/content/sources/cluster_extraction/cluster_extraction.cpp index be2cef5c535..22385562dfd 100644 --- a/doc/tutorials/content/sources/cluster_extraction/cluster_extraction.cpp +++ b/doc/tutorials/content/sources/cluster_extraction/cluster_extraction.cpp @@ -85,8 +85,8 @@ main () for (std::vector::const_iterator it = cluster_indices.begin (); it != cluster_indices.end (); ++it) { pcl::PointCloud::Ptr cloud_cluster (new pcl::PointCloud); - for (std::vector::const_iterator pit = it->indices.begin (); pit != it->indices.end (); ++pit) - cloud_cluster->push_back ((*cloud_filtered)[*pit]); //* + for (const auto& idx : it->indices) + cloud_cluster->push_back ((*cloud_filtered)[idx]); //* cloud_cluster->width = cloud_cluster->size (); cloud_cluster->height = 1; cloud_cluster->is_dense = true; diff --git a/doc/tutorials/content/sources/don_segmentation/don_segmentation.cpp b/doc/tutorials/content/sources/don_segmentation/don_segmentation.cpp index 7e6b49724e4..7c9bc869c90 100644 --- a/doc/tutorials/content/sources/don_segmentation/don_segmentation.cpp +++ b/doc/tutorials/content/sources/don_segmentation/don_segmentation.cpp @@ -171,9 +171,9 @@ main (int argc, char *argv[]) for (std::vector::const_iterator it = cluster_indices.begin (); it != cluster_indices.end (); ++it, j++) { pcl::PointCloud::Ptr cloud_cluster_don (new pcl::PointCloud); - for (std::vector::const_iterator pit = it->indices.begin (); pit != it->indices.end (); ++pit) + for (const auto& idx : it->indices) { - cloud_cluster_don->points.push_back ((*doncloud)[*pit]); + cloud_cluster_don->points.push_back ((*doncloud)[idx]); } cloud_cluster_don->width = cloud_cluster_don->size (); diff --git a/examples/segmentation/example_region_growing.cpp b/examples/segmentation/example_region_growing.cpp index 15a7cd43333..89c38b5b48d 100644 --- a/examples/segmentation/example_region_growing.cpp +++ b/examples/segmentation/example_region_growing.cpp @@ -114,11 +114,9 @@ main (int argc, char** av) clusters_file.open ("clusters.dat"); for (std::size_t i = 0; i < clusters.size (); ++i) { - clusters_file << i << "#" << clusters[i].indices.size () << ": "; - std::vector::const_iterator pit = clusters[i].indices.begin (); - clusters_file << *pit; - for (; pit != clusters[i].indices.end (); ++pit) - clusters_file << " " << *pit; + clusters_file << i << "#" << clusters[i].indices.size () << ":"; + for (const auto& cluster_idx : clusters[i].indices) + clusters_file << " " << cluster_idx; clusters_file << std::endl; } clusters_file.close (); diff --git a/features/include/pcl/features/impl/multiscale_feature_persistence.hpp b/features/include/pcl/features/impl/multiscale_feature_persistence.hpp index 14c192719f0..c0afe99575c 100644 --- a/features/include/pcl/features/impl/multiscale_feature_persistence.hpp +++ b/features/include/pcl/features/impl/multiscale_feature_persistence.hpp @@ -202,7 +202,7 @@ pcl::MultiscaleFeaturePersistence::extractUniqueFeatu ////////////////////////////////////////////////////////////////////////////////////////////// template void pcl::MultiscaleFeaturePersistence::determinePersistentFeatures (FeatureCloud &output_features, - shared_ptr > &output_indices) + pcl::IndicesPtr &output_indices) { if (!initCompute ()) return; diff --git a/features/include/pcl/features/multiscale_feature_persistence.h b/features/include/pcl/features/multiscale_feature_persistence.h index ca55b60958f..acabe3a467a 100644 --- a/features/include/pcl/features/multiscale_feature_persistence.h +++ b/features/include/pcl/features/multiscale_feature_persistence.h @@ -89,7 +89,7 @@ namespace pcl */ void determinePersistentFeatures (FeatureCloud &output_features, - shared_ptr > &output_indices); + pcl::IndicesPtr &output_indices); /** \brief Method for setting the scale parameters for the algorithm * \param scale_values vector of scales to determine the characteristic of each scaling step diff --git a/keypoints/include/pcl/keypoints/impl/susan.hpp b/keypoints/include/pcl/keypoints/impl/susan.hpp index 7767bc40ad5..1f19d08ace8 100644 --- a/keypoints/include/pcl/keypoints/impl/susan.hpp +++ b/keypoints/include/pcl/keypoints/impl/susan.hpp @@ -309,8 +309,8 @@ pcl::SUSANKeypoint::detectKeypoints (P // Check if the output has a "label" field label_idx_ = pcl::getFieldIndex ("label", out_fields_); - const int input_size = static_cast (input_->size ()); - for (int point_index = 0; point_index < input_size; ++point_index) + const auto input_size = static_cast (input_->size ()); + for (pcl::index_t point_index = 0; point_index < input_size; ++point_index) { const PointInT& point_in = input_->points [point_index]; const NormalT& normal_in = normals_->points [point_index]; diff --git a/outofcore/include/pcl/outofcore/impl/octree_base.hpp b/outofcore/include/pcl/outofcore/impl/octree_base.hpp index feac27c8b99..96f3819fa2c 100644 --- a/outofcore/include/pcl/outofcore/impl/octree_base.hpp +++ b/outofcore/include/pcl/outofcore/impl/octree_base.hpp @@ -640,7 +640,7 @@ namespace pcl pcl::PCLPointCloud2::Ptr downsampled_cloud (new pcl::PCLPointCloud2 ()); //create destination for indices - pcl::IndicesPtr downsampled_cloud_indices (new std::vector< int > ()); + pcl::IndicesPtr downsampled_cloud_indices (new pcl::Indices ()); lod_filter_ptr_->filter (*downsampled_cloud_indices); //extract the "random subset", size by setSampleSize diff --git a/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp b/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp index d5dffc42910..5347df01590 100644 --- a/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp +++ b/outofcore/include/pcl/outofcore/impl/octree_base_node.hpp @@ -739,7 +739,7 @@ namespace pcl pcl::PCLPointCloud2::Ptr downsampled_cloud ( new pcl::PCLPointCloud2 () ); //create destination for indices - pcl::IndicesPtr downsampled_cloud_indices ( new std::vector< int > () ); + pcl::IndicesPtr downsampled_cloud_indices ( new pcl::Indices () ); random_sampler.filter (*downsampled_cloud_indices); //extract the "random subset", size by setSampleSize diff --git a/recognition/include/pcl/recognition/hv/hypotheses_verification.h b/recognition/include/pcl/recognition/hv/hypotheses_verification.h index 9e117e04187..f6977ae9174 100644 --- a/recognition/include/pcl/recognition/hv/hypotheses_verification.h +++ b/recognition/include/pcl/recognition/hv/hypotheses_verification.h @@ -252,7 +252,7 @@ namespace pcl typename pcl::PointCloud::Ptr filtered (new pcl::PointCloud ()); typename pcl::occlusion_reasoning::ZBuffering zbuffer_self_occlusion (75, 75, 1.f); zbuffer_self_occlusion.computeDepthMap (models[i], true); - std::vector indices; + pcl::Indices indices; zbuffer_self_occlusion.filter (models[i], indices, 0.005f); pcl::copyPointCloud (*models[i], indices, *filtered); diff --git a/recognition/include/pcl/recognition/hv/occlusion_reasoning.h b/recognition/include/pcl/recognition/hv/occlusion_reasoning.h index ceea925397a..57f841fd111 100644 --- a/recognition/include/pcl/recognition/hv/occlusion_reasoning.h +++ b/recognition/include/pcl/recognition/hv/occlusion_reasoning.h @@ -65,7 +65,7 @@ namespace pcl computeDepthMap (typename pcl::PointCloud::ConstPtr & scene, bool compute_focal = false, bool smooth = false, int wsize = 3); void filter (typename pcl::PointCloud::ConstPtr & model, typename pcl::PointCloud::Ptr & filtered, float thres = 0.01); - void filter (typename pcl::PointCloud::ConstPtr & model, std::vector & indices, float thres = 0.01); + void filter (typename pcl::PointCloud::ConstPtr & model, pcl::Indices & indices, float thres = 0.01); }; template typename pcl::PointCloud::Ptr @@ -76,7 +76,7 @@ namespace pcl float cy = (static_cast (organized_cloud->height) / 2.f - 0.5f); typename pcl::PointCloud::Ptr filtered (new pcl::PointCloud ()); - std::vector indices_to_keep; + pcl::Indices indices_to_keep; indices_to_keep.resize (to_be_filtered->size ()); int keep = 0; diff --git a/recognition/include/pcl/recognition/impl/hv/greedy_verification.hpp b/recognition/include/pcl/recognition/impl/hv/greedy_verification.hpp index 3a2690e8834..9c30dad6aed 100644 --- a/recognition/include/pcl/recognition/impl/hv/greedy_verification.hpp +++ b/recognition/include/pcl/recognition/impl/hv/greedy_verification.hpp @@ -68,7 +68,7 @@ template std::vector explained_indices; std::vector outliers; - std::vector nn_indices; + pcl::Indices nn_indices; std::vector nn_distances; for (std::size_t i = 0; i < recog_model->cloud_->size (); i++) diff --git a/recognition/include/pcl/recognition/impl/hv/hv_go.hpp b/recognition/include/pcl/recognition/impl/hv/hv_go.hpp index 3d8680e14ea..0d3e4a6a164 100644 --- a/recognition/include/pcl/recognition/impl/hv/hv_go.hpp +++ b/recognition/include/pcl/recognition/impl/hv/hv_go.hpp @@ -566,7 +566,7 @@ bool pcl::GlobalHypothesesVerification::addModel(typename pcl::P std::vector outliers_weight; std::vector explained_indices_distances; - std::vector nn_indices; + pcl::Indices nn_indices; std::vector nn_distances; std::map>>> model_explains_scene_points; //which point i from the scene is explained by a points j_k with dist d_k from the model @@ -609,7 +609,7 @@ bool pcl::GlobalHypothesesVerification::addModel(typename pcl::P if (outliers_weight.empty ()) recog_model->outliers_weight_ = 1.f; - pcl::IndicesPtr indices_scene (new std::vector); + pcl::IndicesPtr indices_scene (new pcl::Indices); //go through the map and keep the closest model point in case that several model points explain a scene point int p = 0; @@ -659,7 +659,7 @@ void pcl::GlobalHypothesesVerification::computeClutterCue(Recogn { float rn_sqr = radius_neighborhood_GO_ * radius_neighborhood_GO_; - std::vector nn_indices; + pcl::Indices nn_indices; std::vector nn_distances; std::vector < std::pair > neighborhood_indices; //first is indices to scene point and second is indices to explained_ scene points diff --git a/recognition/include/pcl/recognition/impl/hv/hv_papazov.hpp b/recognition/include/pcl/recognition/impl/hv/hv_papazov.hpp index 70b4f30ebb7..3efbae002ce 100644 --- a/recognition/include/pcl/recognition/impl/hv/hv_papazov.hpp +++ b/recognition/include/pcl/recognition/impl/hv/hv_papazov.hpp @@ -80,7 +80,7 @@ template std::vector explained_indices; std::vector outliers; - std::vector nn_indices; + pcl::Indices nn_indices; std::vector nn_distances; for (std::size_t i = 0; i < recog_model->cloud_->size (); i++) diff --git a/recognition/include/pcl/recognition/impl/hv/occlusion_reasoning.hpp b/recognition/include/pcl/recognition/impl/hv/occlusion_reasoning.hpp index 3ec762b5128..1a314b074c2 100644 --- a/recognition/include/pcl/recognition/impl/hv/occlusion_reasoning.hpp +++ b/recognition/include/pcl/recognition/impl/hv/occlusion_reasoning.hpp @@ -67,7 +67,7 @@ template void pcl::occlusion_reasoning::ZBuffering::filter (typename pcl::PointCloud::ConstPtr & model, typename pcl::PointCloud::Ptr & filtered, float thres) { - std::vector indices_to_keep; + pcl::Indices indices_to_keep; filter(model, indices_to_keep, thres); pcl::copyPointCloud (*model, indices_to_keep, *filtered); } @@ -75,7 +75,7 @@ pcl::occlusion_reasoning::ZBuffering::filter (typename pcl::Poin /////////////////////////////////////////////////////////////////////////////////////////// template void pcl::occlusion_reasoning::ZBuffering::filter (typename pcl::PointCloud::ConstPtr & model, - std::vector & indices_to_keep, float thres) + pcl::Indices & indices_to_keep, float thres) { float cx, cy; diff --git a/recognition/include/pcl/recognition/implicit_shape_model.h b/recognition/include/pcl/recognition/implicit_shape_model.h index f304d40b67b..1671fe8233b 100644 --- a/recognition/include/pcl/recognition/implicit_shape_model.h +++ b/recognition/include/pcl/recognition/implicit_shape_model.h @@ -144,7 +144,7 @@ namespace pcl pcl::KdTreeFLANN::Ptr tree_; /** \brief Stores neighbours indices. */ - std::vector k_ind_; + pcl::Indices k_ind_; /** \brief Stores square distances to the corresponding neighbours. */ std::vector k_sqr_dist_; diff --git a/recognition/include/pcl/recognition/ransac_based/trimmed_icp.h b/recognition/include/pcl/recognition/ransac_based/trimmed_icp.h index 1d4ee8352e1..8fa2a8200d1 100644 --- a/recognition/include/pcl/recognition/ransac_based/trimmed_icp.h +++ b/recognition/include/pcl/recognition/ransac_based/trimmed_icp.h @@ -113,7 +113,7 @@ namespace pcl // Some variables for the closest point search pcl::PointXYZ transformed_source_point; - std::vector target_index (1); + pcl::Indices target_index (1); std::vector sqr_dist_to_target (1); float old_energy, energy = std::numeric_limits::max (); diff --git a/registration/include/pcl/registration/correspondence_rejection.h b/registration/include/pcl/registration/correspondence_rejection.h index dc3e3cab39f..5e4e586db19 100644 --- a/registration/include/pcl/registration/correspondence_rejection.h +++ b/registration/include/pcl/registration/correspondence_rejection.h @@ -114,7 +114,7 @@ class CorrespondenceRejector { */ inline void getRejectedQueryIndices(const pcl::Correspondences& correspondences, - std::vector& indices) + pcl::Indices& indices) { if (!input_correspondences_ || input_correspondences_->empty()) { PCL_WARN("[pcl::registration::%s::getRejectedQueryIndices] Input correspondences " @@ -348,7 +348,7 @@ class DataContainer : public DataContainerInterface { if (target_cloud_updated_ && !force_no_recompute_) { tree_->setInputCloud(target_); } - std::vector indices(1); + pcl::Indices indices(1); std::vector distances(1); if (tree_->nearestKSearch((*input_)[index], 1, indices, distances)) return (distances[0]); diff --git a/registration/include/pcl/registration/gicp.h b/registration/include/pcl/registration/gicp.h index 44d7ee080b1..d39c8d16892 100644 --- a/registration/include/pcl/registration/gicp.h +++ b/registration/include/pcl/registration/gicp.h @@ -404,7 +404,7 @@ class GeneralizedIterativeClosestPoint */ inline bool searchForNeighbors(const PointSource& query, - std::vector& index, + pcl::Indices& index, std::vector& distance) { int k = tree_->nearestKSearch(query, 1, index, distance); diff --git a/registration/include/pcl/registration/gicp6d.h b/registration/include/pcl/registration/gicp6d.h index 1c1fe8f2e6d..bc96ecd06fc 100644 --- a/registration/include/pcl/registration/gicp6d.h +++ b/registration/include/pcl/registration/gicp6d.h @@ -139,7 +139,7 @@ class PCL_EXPORTS GeneralizedIterativeClosestPoint6D */ inline bool searchForNeighbors(const PointXYZLAB& query, - std::vector& index, + pcl::Indices& index, std::vector& distance); protected: diff --git a/registration/include/pcl/registration/impl/correspondence_estimation.hpp b/registration/include/pcl/registration/impl/correspondence_estimation.hpp index 065dad7eec3..19cded5369a 100644 --- a/registration/include/pcl/registration/impl/correspondence_estimation.hpp +++ b/registration/include/pcl/registration/impl/correspondence_estimation.hpp @@ -124,7 +124,7 @@ CorrespondenceEstimation::determineCorresponde correspondences.resize(indices_->size()); - std::vector index(1); + pcl::Indices index(1); std::vector distance(1); pcl::Correspondence corr; unsigned int nr_valid_correspondences = 0; @@ -184,9 +184,9 @@ CorrespondenceEstimation:: double max_dist_sqr = max_distance * max_distance; correspondences.resize(indices_->size()); - std::vector index(1); + pcl::Indices index(1); std::vector distance(1); - std::vector index_reciprocal(1); + pcl::Indices index_reciprocal(1); std::vector distance_reciprocal(1); pcl::Correspondence corr; unsigned int nr_valid_correspondences = 0; diff --git a/registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus.hpp b/registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus.hpp index e2d1d976dc9..e2c68aa5467 100644 --- a/registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus.hpp +++ b/registration/include/pcl/registration/impl/correspondence_rejection_sample_consensus.hpp @@ -74,8 +74,8 @@ CorrespondenceRejectorSampleConsensus::getRemainingCorrespondences( inlier_indices_.clear(); int nr_correspondences = static_cast(original_correspondences.size()); - std::vector source_indices(nr_correspondences); - std::vector target_indices(nr_correspondences); + pcl::Indices source_indices(nr_correspondences); + pcl::Indices target_indices(nr_correspondences); // Copy the query-match indices for (std::size_t i = 0; i < original_correspondences.size(); ++i) { @@ -110,7 +110,7 @@ CorrespondenceRejectorSampleConsensus::getRemainingCorrespondences( return; } - std::vector inliers; + pcl::Indices inliers; sac.getInliers(inliers); if (inliers.size() < 3) { diff --git a/registration/include/pcl/registration/impl/gicp.hpp b/registration/include/pcl/registration/impl/gicp.hpp index 875a6a0c089..ef039547082 100644 --- a/registration/include/pcl/registration/impl/gicp.hpp +++ b/registration/include/pcl/registration/impl/gicp.hpp @@ -63,7 +63,7 @@ GeneralizedIterativeClosestPoint::computeCovariances( } Eigen::Vector3d mean; - std::vector nn_indecies; + pcl::Indices nn_indecies; nn_indecies.reserve(k_correspondences_); std::vector nn_dist_sq; nn_dist_sq.reserve(k_correspondences_); @@ -413,7 +413,7 @@ GeneralizedIterativeClosestPoint::computeTransformatio nr_iterations_ = 0; converged_ = false; double dist_threshold = corr_dist_threshold_ * corr_dist_threshold_; - std::vector nn_indices(1); + pcl::Indices nn_indices(1); std::vector nn_dists(1); pcl::transformPointCloud(output, output, guess); diff --git a/registration/include/pcl/registration/impl/ia_ransac.hpp b/registration/include/pcl/registration/impl/ia_ransac.hpp index 98391344cbf..fa99cba2f7c 100644 --- a/registration/include/pcl/registration/impl/ia_ransac.hpp +++ b/registration/include/pcl/registration/impl/ia_ransac.hpp @@ -166,7 +166,7 @@ float SampleConsensusInitialAlignment::computeErrorMetric( const PointCloudSource& cloud, float) { - std::vector nn_index(1); + pcl::Indices nn_index(1); std::vector nn_distance(1); const ErrorFunctor& compute_error = *error_functor_; diff --git a/registration/include/pcl/registration/impl/registration.hpp b/registration/include/pcl/registration/impl/registration.hpp index 022b2e8f162..1abc953f002 100644 --- a/registration/include/pcl/registration/impl/registration.hpp +++ b/registration/include/pcl/registration/impl/registration.hpp @@ -139,7 +139,7 @@ Registration::getFitnessScore(double max_range PointCloudSource input_transformed; transformPointCloud(*input_, input_transformed, final_transformation_); - std::vector nn_indices(1); + pcl::Indices nn_indices(1); std::vector nn_dists(1); // For each point in the source dataset diff --git a/registration/src/gicp6d.cpp b/registration/src/gicp6d.cpp index f4d98b1d296..b3a4f5db033 100644 --- a/registration/src/gicp6d.cpp +++ b/registration/src/gicp6d.cpp @@ -167,7 +167,7 @@ GeneralizedIterativeClosestPoint6D::setInputTarget( bool GeneralizedIterativeClosestPoint6D::searchForNeighbors(const PointXYZLAB& query, - std::vector& index, + pcl::Indices& index, std::vector& distance) { int k = target_tree_lab_.nearestKSearch(query, 1, index, distance); @@ -208,7 +208,7 @@ GeneralizedIterativeClosestPoint6D::computeTransformation(PointCloudSource& outp nr_iterations_ = 0; converged_ = false; double dist_threshold = corr_dist_threshold_ * corr_dist_threshold_; - std::vector nn_indices(1); + pcl::Indices nn_indices(1); std::vector nn_dists(1); while (!converged_) { diff --git a/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp b/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp index ffcbab2a1fb..e11535f207c 100644 --- a/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp +++ b/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp @@ -317,7 +317,7 @@ GrabCut::initGraph () const NLinks &n_link = n_links_[i_point]; if (n_link.nb_links > 0) { - int point_index = (*indices_) [i_point]; + const auto point_index = (*indices_) [i_point]; std::vector::const_iterator weights_it = n_link.weights.begin (); for (auto indices_it = n_link.indices.cbegin (); indices_it != n_link.indices.cend (); ++indices_it, ++weights_it) { @@ -393,7 +393,7 @@ GrabCut::computeBetaNonOrganized () for (int i_point = 0; i_point < number_of_indices; i_point++) { - int point_index = (*indices_)[i_point]; + const auto point_index = (*indices_)[i_point]; const PointT& point = input_->points [point_index]; if (pcl::isFinite (point)) { diff --git a/test/filters/test_clipper.cpp b/test/filters/test_clipper.cpp index 9486322dc7f..46f82e48e90 100644 --- a/test/filters/test_clipper.cpp +++ b/test/filters/test_clipper.cpp @@ -322,7 +322,7 @@ TEST (CropBox, Filters) // Should contain all EXPECT_EQ (int (indices.size ()), 7); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 7, 8}), indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 7, 8}), indices); EXPECT_EQ (int (cloud_out.size ()), 7); EXPECT_EQ (int (cloud_out.width), 7); EXPECT_EQ (int (cloud_out.height), 1); @@ -346,12 +346,12 @@ TEST (CropBox, Filters) cropBoxFilter.filter (cloud_out); EXPECT_EQ (int (indices.size ()), 3); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 7}), indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 7}), indices); EXPECT_EQ (int (cloud_out.size ()), 3); removed_indices = cropBoxFilter.getRemovedIndices (); EXPECT_EQ (int (removed_indices->size ()), 4); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({3, 5, 6, 8}), *removed_indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({3, 5, 6, 8}), *removed_indices); // Test setNegative cropBoxFilter.setNegative (true); @@ -360,7 +360,7 @@ TEST (CropBox, Filters) cropBoxFilter.filter (indices); EXPECT_EQ (int (indices.size ()), 4); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({3, 5, 6, 8}), indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({3, 5, 6, 8}), indices); cropBoxFilter.setNegative (false); cropBoxFilter.filter (cloud_out); @@ -377,7 +377,7 @@ TEST (CropBox, Filters) removed_indices = cropBoxFilter.getRemovedIndices (); EXPECT_EQ (int (removed_indices->size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), *removed_indices); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), *removed_indices); // Test setNegative cropBoxFilter.setNegative (true); cropBoxFilter.filter (cloud_out_negative); @@ -385,7 +385,7 @@ TEST (CropBox, Filters) cropBoxFilter.filter (indices); EXPECT_EQ (int (indices.size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN(std::vector({0, 4}), indices); + EXPECT_VECTOR_DOES_NOT_CONTAIN(pcl::Indices({0, 4}), indices); cropBoxFilter.setNegative (false); cropBoxFilter.filter (cloud_out); @@ -396,14 +396,14 @@ TEST (CropBox, Filters) cropBoxFilter.filter (cloud_out); EXPECT_EQ (int (indices.size ()), 1); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({7}), indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({7}), indices); EXPECT_EQ (int (cloud_out.size ()), 1); EXPECT_EQ (int (cloud_out.width), 1); EXPECT_EQ (int (cloud_out.height), 1); removed_indices = cropBoxFilter.getRemovedIndices (); EXPECT_EQ (int (removed_indices->size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 8}), *removed_indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), *removed_indices); // Test setNegative cropBoxFilter.setNegative (true); @@ -412,7 +412,7 @@ TEST (CropBox, Filters) cropBoxFilter.filter (indices); EXPECT_EQ (int (indices.size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 8}), indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), indices); cropBoxFilter.setNegative (false); cropBoxFilter.filter (cloud_out); @@ -423,14 +423,14 @@ TEST (CropBox, Filters) cropBoxFilter.filter (cloud_out); EXPECT_EQ (int (indices.size ()), 1); - EXPECT_VECTOR_CONTAINS_ALL (indices, std::vector({7})); + EXPECT_VECTOR_CONTAINS_ALL (indices, pcl::Indices({7})); EXPECT_EQ (int (cloud_out.size ()), 1); EXPECT_EQ (int (cloud_out.width), 1); EXPECT_EQ (int (cloud_out.height), 1); removed_indices = cropBoxFilter.getRemovedIndices (); EXPECT_EQ (int (removed_indices->size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector( {1, 2, 3, 5, 6, 8}), *removed_indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices( {1, 2, 3, 5, 6, 8}), *removed_indices); // Test setNegative cropBoxFilter.setNegative (true); @@ -439,7 +439,7 @@ TEST (CropBox, Filters) cropBoxFilter.filter (indices); EXPECT_EQ (int (indices.size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 8}), indices); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), indices); cropBoxFilter.setNegative (false); cropBoxFilter.filter (cloud_out); @@ -456,7 +456,7 @@ TEST (CropBox, Filters) removed_indices = cropBoxFilter.getRemovedIndices (); EXPECT_EQ (int (removed_indices->size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), *removed_indices); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), *removed_indices); // Test setNegative cropBoxFilter.setNegative (true); @@ -465,7 +465,7 @@ TEST (CropBox, Filters) cropBoxFilter.filter (indices); EXPECT_EQ (int (indices.size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), indices); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), indices); // PCLPointCloud2 without indices // ------------------------------------------------------------------------- @@ -626,7 +626,7 @@ TEST (CropBox, Filters) // Should contain all EXPECT_EQ (int (indices2.size ()), 7); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 7, 8}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 7, 8}), indices2); EXPECT_EQ (int (cloud_out2.width), 7); EXPECT_EQ (int (cloud_out2.height), 1); @@ -649,12 +649,12 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (cloud_out2); EXPECT_EQ (int (indices2.size ()), 3); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 7}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 7}), indices2); EXPECT_EQ (int (cloud_out2.width*cloud_out2.height), 3); removed_indices2 = cropBoxFilter2.getRemovedIndices (); EXPECT_EQ (int (removed_indices2->size ()), 4); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({3, 5, 6, 8}), *removed_indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({3, 5, 6, 8}), *removed_indices2); // Test setNegative cropBoxFilter2.setNegative (true); @@ -663,7 +663,7 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (indices2); EXPECT_EQ (int (indices2.size ()), 4); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({3, 5, 6, 8}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({3, 5, 6, 8}), indices2); cropBoxFilter2.setNegative (false); cropBoxFilter2.filter (cloud_out2); @@ -680,7 +680,7 @@ TEST (CropBox, Filters) removed_indices2 = cropBoxFilter2.getRemovedIndices (); EXPECT_EQ (int (removed_indices2->size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), *removed_indices2); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), *removed_indices2); // Test setNegative cropBoxFilter2.setNegative (true); cropBoxFilter2.filter (cloud_out2_negative); @@ -688,7 +688,7 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (indices2); EXPECT_EQ (int (indices2.size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), indices2); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), indices2); cropBoxFilter2.setNegative (false); cropBoxFilter2.filter (cloud_out2); @@ -699,13 +699,13 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (cloud_out2); EXPECT_EQ (int (indices2.size ()), 1); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({7}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({7}), indices2); EXPECT_EQ (int (cloud_out2.width), 1); EXPECT_EQ (int (cloud_out2.height), 1); removed_indices2 = cropBoxFilter2.getRemovedIndices (); EXPECT_EQ (int (removed_indices2->size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 8}), *removed_indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), *removed_indices2); // Test setNegative cropBoxFilter2.setNegative (true); @@ -714,7 +714,7 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (indices2); EXPECT_EQ (int (indices2.size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 8}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), indices2); cropBoxFilter2.setNegative (false); cropBoxFilter2.filter (cloud_out2); @@ -725,13 +725,13 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (cloud_out2); EXPECT_EQ (int (indices2.size ()), 1); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({7}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({7}), indices2); EXPECT_EQ (int (cloud_out2.width), 1); EXPECT_EQ (int (cloud_out2.height), 1); removed_indices = cropBoxFilter.getRemovedIndices (); EXPECT_EQ (int (removed_indices2->size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector( {1, 2, 3, 5, 6, 8}), *removed_indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), *removed_indices2); // Test setNegative cropBoxFilter2.setNegative (true); @@ -740,7 +740,7 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (indices2); EXPECT_EQ (int (indices2.size ()), 6); - EXPECT_VECTOR_CONTAINS_ALL (std::vector({1, 2, 3, 5, 6, 8}), indices2); + EXPECT_VECTOR_CONTAINS_ALL (pcl::Indices({1, 2, 3, 5, 6, 8}), indices2); cropBoxFilter2.setNegative (false); cropBoxFilter2.filter (cloud_out2); @@ -756,7 +756,7 @@ TEST (CropBox, Filters) removed_indices2 = cropBoxFilter2.getRemovedIndices (); EXPECT_EQ (int (removed_indices2->size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), *removed_indices2); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), *removed_indices2); // Test setNegative cropBoxFilter2.setNegative (true); @@ -765,7 +765,7 @@ TEST (CropBox, Filters) cropBoxFilter2.filter (indices2); EXPECT_EQ (int (indices2.size ()), 7); - EXPECT_VECTOR_DOES_NOT_CONTAIN (std::vector({0, 4}), indices2); + EXPECT_VECTOR_DOES_NOT_CONTAIN (pcl::Indices({0, 4}), indices2); } diff --git a/test/search/test_flann_search.cpp b/test/search/test_flann_search.cpp index 72428f86ae1..b5bd3051de8 100644 --- a/test/search/test_flann_search.cpp +++ b/test/search/test_flann_search.cpp @@ -217,8 +217,8 @@ TEST (PCL, FlannSearch_knnByIndex) flann_search.setInputCloud (cloud_big.makeShared ()); std::vector< std::vector< float > > dists; - std::vector< std::vector< int > > indices; - std::vector< int > query_indices; + std::vector< pcl::Indices > indices; + pcl::Indices query_indices; for (std::size_t i = 0; inearestKSearch (cloud_big, std::vector (), no_of_neighbors, indices_flann,dists_flann); + flann_search->nearestKSearch (cloud_big, pcl::Indices (), no_of_neighbors, indices_flann,dists_flann); } { ScopeTime scopeTime ("kd tree multi nearestKSearch"); - kdtree_search->nearestKSearch (cloud_big, std::vector (), no_of_neighbors, indices_tree,dists_tree); + kdtree_search->nearestKSearch (cloud_big, pcl::Indices (), no_of_neighbors, indices_tree,dists_tree); } ASSERT_EQ (indices_flann.size (), dists_flann.size ()); diff --git a/test/search/test_organized.cpp b/test/search/test_organized.cpp index f31e77365c8..faf944bba46 100644 --- a/test/search/test_organized.cpp +++ b/test/search/test_organized.cpp @@ -236,7 +236,7 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Neighbours_Within_Radius_Search) } } - std::vector cloudNWRSearch; + pcl::Indices cloudNWRSearch; std::vector cloudNWRRadius; // execute organized search @@ -244,35 +244,28 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Neighbours_Within_Radius_Search) organizedNeighborSearch.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius); // check if result from organized radius search can be also found in bruteforce search - std::vector::const_iterator current = cloudNWRSearch.begin(); - while (current != cloudNWRSearch.end()) + for (const auto& current : cloudNWRSearch) { pointDist = sqrt ( - ((*cloudIn)[*current].x-searchPoint.x) * ((*cloudIn)[*current].x-searchPoint.x) + - ((*cloudIn)[*current].y-searchPoint.y) * ((*cloudIn)[*current].y-searchPoint.y) + - ((*cloudIn)[*current].z-searchPoint.z) * ((*cloudIn)[*current].z-searchPoint.z) + ((*cloudIn)[current].x-searchPoint.x) * ((*cloudIn)[current].x-searchPoint.x) + + ((*cloudIn)[current].y-searchPoint.y) * ((*cloudIn)[current].y-searchPoint.y) + + ((*cloudIn)[current].z-searchPoint.z) * ((*cloudIn)[current].z-searchPoint.z) ); ASSERT_EQ ( (pointDist<=searchRadius) , true); - - ++current; } // check if bruteforce result from organized radius search can be also found in bruteforce search - current = cloudSearchBruteforce.begin(); - while (current != cloudSearchBruteforce.end()) + for (const auto& current : cloudSearchBruteforce) { - pointDist = sqrt ( - ((*cloudIn)[*current].x-searchPoint.x) * ((*cloudIn)[*current].x-searchPoint.x) + - ((*cloudIn)[*current].y-searchPoint.y) * ((*cloudIn)[*current].y-searchPoint.y) + - ((*cloudIn)[*current].z-searchPoint.z) * ((*cloudIn)[*current].z-searchPoint.z) + ((*cloudIn)[current].x-searchPoint.x) * ((*cloudIn)[current].x-searchPoint.x) + + ((*cloudIn)[current].y-searchPoint.y) * ((*cloudIn)[current].y-searchPoint.y) + + ((*cloudIn)[current].z-searchPoint.z) * ((*cloudIn)[current].z-searchPoint.z) ); ASSERT_EQ ( (pointDist<=searchRadius) , true); - - ++current; } ASSERT_EQ (cloudNWRRadius.size() , cloudSearchBruteforce.size ()); diff --git a/test/search/test_search.cpp b/test/search/test_search.cpp index f72b06156d9..59cdd319aed 100644 --- a/test/search/test_search.cpp +++ b/test/search/test_search.cpp @@ -127,9 +127,9 @@ std::vector* > unorganized_search_methods; std::vector* > organized_search_methods; /** \brief lists of indices to be used as query points for various search methods and different cloud types*/ -std::vector unorganized_dense_cloud_query_indices; -std::vector unorganized_sparse_cloud_query_indices; -std::vector organized_sparse_query_indices; +pcl::Indices unorganized_dense_cloud_query_indices; +pcl::Indices unorganized_sparse_cloud_query_indices; +pcl::Indices organized_sparse_query_indices; /** \briet test whether the result of a search contains unique point ids or not * @param indices resulting indices from a search @@ -233,8 +233,8 @@ testResultValidity (const typename PointCloud::ConstPtr point_cloud, con * \param eps threshold for comparing the distances * \return true if both sets are the same, false otherwise */ -bool compareResults (const std::vector& indices1, const std::vector& distances1, const std::string& name1, - const std::vector& indices2, const std::vector& distances2, const std::string& name2, float eps) +bool compareResults (const pcl::Indices& indices1, const std::vector& distances1, const std::string& name1, + const pcl::Indices& indices2, const std::vector& distances2, const std::string& name2, float eps) { bool equal = true; if (indices1.size () != indices2.size ()) @@ -475,7 +475,7 @@ TEST (PCL, unorganized_dense_cloud_Complete_Radius) // Test search on unorganized point clouds in a grid TEST (PCL, unorganized_grid_cloud_Complete_Radius) { - std::vector query_indices; + pcl::Indices query_indices; query_indices.reserve (query_count); unsigned skip = static_cast (unorganized_grid_cloud->size ()) / query_count; @@ -543,7 +543,7 @@ TEST (PCL, Organized_Sparse_View_Radius) * \param cloud input cloud required to check for nans and to get number of points * \param[in] query_count maximum number of query points */ -void createQueryIndices (std::vector& query_indices, PointCloud::ConstPtr point_cloud, unsigned query_count) +void createQueryIndices (pcl::Indices& query_indices, PointCloud::ConstPtr point_cloud, unsigned query_count) { query_indices.clear (); query_indices.reserve (query_count); diff --git a/tools/crf_segmentation.cpp b/tools/crf_segmentation.cpp index 8d8d756f221..a54351e8384 100644 --- a/tools/crf_segmentation.cpp +++ b/tools/crf_segmentation.cpp @@ -195,7 +195,7 @@ main (int argc, char** argv) // TODO:: make this as an optional argument ?? - std::vector tmp_indices; + pcl::Indices tmp_indices; pcl::removeNaNFromPointCloud (*cloud, *cloud, tmp_indices); // parse optional input arguments from the command line diff --git a/tools/progressive_morphological_filter.cpp b/tools/progressive_morphological_filter.cpp index c05871a1ecf..8f8c6275c41 100644 --- a/tools/progressive_morphological_filter.cpp +++ b/tools/progressive_morphological_filter.cpp @@ -114,7 +114,7 @@ compute (ConstCloudPtr &input, Cloud &output, int max_window_size, float slope, print_highlight (stderr, "Computing "); - std::vector ground; + pcl::Indices ground; if (approximate) { diff --git a/tools/unary_classifier_segment.cpp b/tools/unary_classifier_segment.cpp index d026ef2901d..c7972ec17a2 100644 --- a/tools/unary_classifier_segment.cpp +++ b/tools/unary_classifier_segment.cpp @@ -184,7 +184,7 @@ main (int argc, char** argv) return (-1); // TODO:: make this as an optional argument ?? - std::vector tmp_indices; + pcl::Indices tmp_indices; pcl::removeNaNFromPointCloud (*cloud, *cloud, tmp_indices); // parse optional input arguments from the command line From 57e236ea4560f6f5870d22cae45425dfd8f14026 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 11 Mar 2021 19:14:30 +0100 Subject: [PATCH 035/431] Change fields of PCLPointCloud2 and PCLImage to uindex_t - with unsigned, the numbers have twice the capacity before having to switch to a bigger datatype - consistent with ROS messages (sensor_msgs/PointCloud2 and sensor_msgs/Image) - rules out the possibility to have negative width/height/steps The other changes are follow-ups, to avoid sign-compare warnings, and removing unnecessary casts --- common/include/pcl/PCLImage.h | 6 +++--- common/include/pcl/PCLPointCloud2.h | 8 ++++---- common/src/PCLPointCloud2.cpp | 2 +- common/src/io.cpp | 4 ++-- common/src/pcl_base.cpp | 2 +- common/src/range_image.cpp | 2 +- filters/src/extract_indices.cpp | 4 ++-- io/src/obj_io.cpp | 4 ++-- io/src/pcd_io.cpp | 14 +++++++------- io/src/vtk_lib_io.cpp | 26 +++++++++++++------------- tools/transform_point_cloud.cpp | 2 +- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/common/include/pcl/PCLImage.h b/common/include/pcl/PCLImage.h index 2ac69498cb8..475acb8c642 100644 --- a/common/include/pcl/PCLImage.h +++ b/common/include/pcl/PCLImage.h @@ -13,12 +13,12 @@ namespace pcl { ::pcl::PCLHeader header; - index_t height = 0; - index_t width = 0; + uindex_t height = 0; + uindex_t width = 0; std::string encoding; std::uint8_t is_bigendian = 0; - index_t step = 0; + uindex_t step = 0; std::vector data; diff --git a/common/include/pcl/PCLPointCloud2.h b/common/include/pcl/PCLPointCloud2.h index cde7e6e08d8..50520f66e11 100644 --- a/common/include/pcl/PCLPointCloud2.h +++ b/common/include/pcl/PCLPointCloud2.h @@ -17,15 +17,15 @@ namespace pcl { ::pcl::PCLHeader header; - index_t height = 0; - index_t width = 0; + uindex_t height = 0; + uindex_t width = 0; std::vector<::pcl::PCLPointField> fields; static_assert(BOOST_ENDIAN_BIG_BYTE || BOOST_ENDIAN_LITTLE_BYTE, "unable to determine system endianness"); std::uint8_t is_bigendian = BOOST_ENDIAN_BIG_BYTE; - index_t point_step = 0; - index_t row_step = 0; + uindex_t point_step = 0; + uindex_t row_step = 0; std::vector data; diff --git a/common/src/PCLPointCloud2.cpp b/common/src/PCLPointCloud2.cpp index 5940cae67c5..20d18d66c3a 100644 --- a/common/src/PCLPointCloud2.cpp +++ b/common/src/PCLPointCloud2.cpp @@ -149,7 +149,7 @@ pcl::PCLPointCloud2::concatenate (pcl::PCLPointCloud2 &cloud1, const pcl::PCLPoi } const auto data1_size = cloud1.data.size (); cloud1.data.resize(data1_size + cloud2.data.size ()); - for (index_t cp = 0; cp < size2; ++cp) + for (uindex_t cp = 0; cp < size2; ++cp) { for (const auto& field_data: valid_fields) { diff --git a/common/src/io.cpp b/common/src/io.cpp index 61b4273ab5b..9e8e7fc5cdc 100644 --- a/common/src/io.cpp +++ b/common/src/io.cpp @@ -181,7 +181,7 @@ pcl::concatenateFields (const pcl::PCLPointCloud2 &cloud1, // Iterate over each point and perform the appropriate memcpys int point_offset = 0; - for (index_t cp = 0; cp < cloud_out.width * cloud_out.height; ++cp) + for (uindex_t cp = 0; cp < cloud_out.width * cloud_out.height; ++cp) { memcpy (&cloud_out.data[point_offset], &cloud2.data[cp * cloud2.point_step], cloud2.point_step); int field_offset = cloud2.point_step; @@ -276,7 +276,7 @@ pcl::concatenatePointCloud (const pcl::PCLPointCloud2 &cloud1, cloud_out.data.resize (nrpts + (cloud2.width * cloud2.height) * cloud_out.point_step); // Copy the second cloud - for (index_t cp = 0; cp < cloud2.width * cloud2.height; ++cp) + for (uindex_t cp = 0; cp < cloud2.width * cloud2.height; ++cp) { int i = 0; for (std::size_t j = 0; j < fields2.size (); ++j) diff --git a/common/src/pcl_base.cpp b/common/src/pcl_base.cpp index ca03ffc4c48..e591812d72f 100644 --- a/common/src/pcl_base.cpp +++ b/common/src/pcl_base.cpp @@ -126,7 +126,7 @@ pcl::PCLBase::initCompute () } // If we have a set of fake indices, but they do not match the number of points in the cloud, update them - if (fake_indices_ && indices_->size () != static_cast((input_->width * input_->height))) + if (fake_indices_ && indices_->size () != (input_->width * input_->height)) { const auto indices_size = indices_->size (); try diff --git a/common/src/range_image.cpp b/common/src/range_image.cpp index 93227a20552..48b0a6a1583 100644 --- a/common/src/range_image.cpp +++ b/common/src/range_image.cpp @@ -833,7 +833,7 @@ RangeImage::extractFarRanges (const pcl::PCLPointCloud2& point_cloud_data, vp_z_offset = point_cloud_data.fields[vp_z_idx].offset, distance_offset = point_cloud_data.fields[distance_idx].offset; - for (index_t point_idx = 0; point_idx < point_cloud_data.width*point_cloud_data.height; ++point_idx) + for (uindex_t point_idx = 0; point_idx < point_cloud_data.width*point_cloud_data.height; ++point_idx) { float x = *reinterpret_cast (data+x_offset), y = *reinterpret_cast (data+y_offset), diff --git a/filters/src/extract_indices.cpp b/filters/src/extract_indices.cpp index cde67ea5c3b..6ac3544d895 100644 --- a/filters/src/extract_indices.cpp +++ b/filters/src/extract_indices.cpp @@ -89,7 +89,7 @@ pcl::ExtractIndices::applyFilter (PCLPointCloud2 &output) output = *input_; return; } - if (indices_->size () == static_cast(input_->width * input_->height)) + if (indices_->size () == (input_->width * input_->height)) { // If negative, then return an empty cloud if (negative_) @@ -146,7 +146,7 @@ pcl::ExtractIndices::applyFilter (PCLPointCloud2 &output) void pcl::ExtractIndices::applyFilter (Indices &indices) { - if (indices_->size () > static_cast(input_->width * input_->height)) + if (indices_->size () > (input_->width * input_->height)) { PCL_ERROR ("[pcl::%s::applyFilter] The indices size exceeds the size of the input.\n", getClassName ().c_str ()); indices.clear (); diff --git a/io/src/obj_io.cpp b/io/src/obj_io.cpp index 6ee4b8e6589..4bfb891347f 100644 --- a/io/src/obj_io.cpp +++ b/io/src/obj_io.cpp @@ -536,8 +536,8 @@ pcl::OBJReader::read (const std::string &file_name, pcl::PCLPointCloud2 &cloud, std::vector st; try { - index_t point_idx = 0; - index_t normal_idx = 0; + uindex_t point_idx = 0; + uindex_t normal_idx = 0; while (!fs.eof ()) { diff --git a/io/src/pcd_io.cpp b/io/src/pcd_io.cpp index b5898b3d3ed..31254677533 100644 --- a/io/src/pcd_io.cpp +++ b/io/src/pcd_io.cpp @@ -361,7 +361,7 @@ pcl::PCDReader::readHeader (std::istream &fs, pcl::PCLPointCloud2 &cloud, } } - if (static_cast(cloud.width * cloud.height) != nr_points) + if (cloud.width * cloud.height != nr_points) { PCL_ERROR ("[pcl::PCDReader::readHeader] HEIGHT (%d) x WIDTH (%d) != number of points (%d)\n", cloud.height, cloud.width, nr_points); return (-1); @@ -611,7 +611,7 @@ pcl::PCDReader::readBodyBinary (const unsigned char *map, pcl::PCLPointCloud2 &c toff += fields_sizes[i] * cloud.width * cloud.height; } // Copy it to the cloud - for (index_t i = 0; i < cloud.width * cloud.height; ++i) + for (uindex_t i = 0; i < cloud.width * cloud.height; ++i) { for (std::size_t j = 0; j < pters.size (); ++j) { @@ -629,7 +629,7 @@ pcl::PCDReader::readBodyBinary (const unsigned char *map, pcl::PCLPointCloud2 &c // Extra checks (not needed for ASCII) int point_size = static_cast (cloud.data.size () / (cloud.height * cloud.width)); // Once copied, we need to go over each field and check if it has NaN/Inf values and assign cloud.is_dense to true or false - for (index_t i = 0; i < cloud.width * cloud.height; ++i) + for (uindex_t i = 0; i < cloud.width * cloud.height; ++i) { for (unsigned int d = 0; d < static_cast (cloud.fields.size ()); ++d) { @@ -986,7 +986,7 @@ pcl::PCDWriter::generateHeaderBinary (const pcl::PCLPointCloud2 &cloud, fsize += field.count * getFieldSize (field.datatype); // The size of the fields cannot be larger than point_step - if (fsize > static_cast(cloud.point_step)) + if (fsize > cloud.point_step) { PCL_ERROR ("[pcl::PCDWriter::generateHeaderBinary] The size of the fields (%d) is larger than point_step (%d)! Something is wrong here...\n", fsize, cloud.point_step); return (""); @@ -1028,7 +1028,7 @@ pcl::PCDWriter::generateHeaderBinary (const pcl::PCLPointCloud2 &cloud, field_counts << " " << count; } // Check extra padding - if (toffset < static_cast(cloud.point_step)) + if (toffset < cloud.point_step) { field_names << " _"; // By convention, _ is an invalid field name field_sizes << " 1"; // Make size = 1 @@ -1068,7 +1068,7 @@ pcl::PCDWriter::generateHeaderBinaryCompressed (std::ostream &os, fsize += field.count * getFieldSize (field.datatype); // The size of the fields cannot be larger than point_step - if (fsize > static_cast(cloud.point_step)) + if (fsize > cloud.point_step) { PCL_ERROR ("[pcl::PCDWriter::generateHeaderBinaryCompressed] The size of the fields (%d) is larger than point_step (%d)! Something is wrong here...\n", fsize, cloud.point_step); return (-1); @@ -1415,7 +1415,7 @@ pcl::PCDWriter::writeBinaryCompressed (std::ostream &os, const pcl::PCLPointClou } // Go over all the points, and copy the data in the appropriate places - for (index_t i = 0; i < cloud.width * cloud.height; ++i) + for (uindex_t i = 0; i < cloud.width * cloud.height; ++i) { for (std::size_t j = 0; j < pters.size (); ++j) { diff --git a/io/src/vtk_lib_io.cpp b/io/src/vtk_lib_io.cpp index b71615cb949..7f5eb205ba3 100644 --- a/io/src/vtk_lib_io.cpp +++ b/io/src/vtk_lib_io.cpp @@ -413,7 +413,7 @@ pcl::io::vtk2mesh (const vtkSmartPointer& poly_data, pcl::TextureMe int pcl::io::mesh2vtk (const pcl::PolygonMesh& mesh, vtkSmartPointer& poly_data) { - unsigned int nr_points = mesh.cloud.width * mesh.cloud.height; + auto nr_points = mesh.cloud.width * mesh.cloud.height; unsigned int nr_polygons = static_cast (mesh.polygons.size ()); // reset vtkPolyData object @@ -556,12 +556,12 @@ pcl::io::pointCloudTovtkPolyData(const pcl::PCLPointCloud2Ptr& cloud, vtkSmartPo vtkSmartPointer cloud_vertices = vtkSmartPointer::New (); vtkIdType pid[1]; - for (index_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) + for (uindex_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) { float point[3]; - int point_offset = (int (point_idx) * cloud->point_step); - int offset = point_offset + cloud->fields[x_idx].offset; + auto point_offset = (point_idx * cloud->point_step); + auto offset = point_offset + cloud->fields[x_idx].offset; memcpy (&point, &cloud->data[offset], sizeof (float)*3); pid[0] = cloud_points->InsertNextPoint (point); @@ -582,12 +582,12 @@ pcl::io::pointCloudTovtkPolyData(const pcl::PCLPointCloud2Ptr& cloud, vtkSmartPo colors->SetNumberOfComponents (3); colors->SetName ("rgb"); - for (index_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) + for (uindex_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) { unsigned char bgr[3]; - int point_offset = (int (point_idx) * cloud->point_step); - int offset = point_offset + cloud->fields[rgb_idx].offset; + auto point_offset = (point_idx * cloud->point_step); + auto offset = point_offset + cloud->fields[rgb_idx].offset; memcpy (&bgr, &cloud->data[offset], sizeof (unsigned char)*3); colors->InsertNextTuple3(bgr[2], bgr[1], bgr[0]); @@ -605,12 +605,12 @@ pcl::io::pointCloudTovtkPolyData(const pcl::PCLPointCloud2Ptr& cloud, vtkSmartPo cloud_intensity->SetNumberOfComponents (1); cloud_intensity->SetName("intensity"); - for (index_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) + for (uindex_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) { float intensity; - int point_offset = (int (point_idx) * cloud->point_step); - int offset = point_offset + cloud->fields[intensity_idx].offset; + auto point_offset = (point_idx * cloud->point_step); + auto offset = point_offset + cloud->fields[intensity_idx].offset; memcpy (&intensity, &cloud->data[offset], sizeof(float)); cloud_intensity->InsertNextValue(intensity); @@ -630,12 +630,12 @@ pcl::io::pointCloudTovtkPolyData(const pcl::PCLPointCloud2Ptr& cloud, vtkSmartPo normals->SetNumberOfComponents(3); //3d normals (ie x,y,z) normals->SetName("normals"); - for (index_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) + for (uindex_t point_idx = 0; point_idx < cloud->width * cloud->height; point_idx ++) { float normal[3]; - int point_offset = (int (point_idx) * cloud->point_step); - int offset = point_offset + cloud->fields[normal_x_idx].offset; + auto point_offset = (point_idx * cloud->point_step); + auto offset = point_offset + cloud->fields[normal_x_idx].offset; memcpy (&normal, &cloud->data[offset], sizeof (float)*3); normals->InsertNextTuple(normal); diff --git a/tools/transform_point_cloud.cpp b/tools/transform_point_cloud.cpp index 22f68bdb2c3..4d1b57cc408 100644 --- a/tools/transform_point_cloud.cpp +++ b/tools/transform_point_cloud.cpp @@ -199,7 +199,7 @@ scaleInPlace (pcl::PCLPointCloud2 &cloud, double* multiplier) int z_idx = pcl::getFieldIndex (cloud, "z"); Eigen::Array3i xyz_offset (cloud.fields[x_idx].offset, cloud.fields[y_idx].offset, cloud.fields[z_idx].offset); - for (index_t cp = 0; cp < cloud.width * cloud.height; ++cp) + for (uindex_t cp = 0; cp < cloud.width * cloud.height; ++cp) { // Assume all 3 fields are the same (XYZ) assert ((cloud.fields[x_idx].datatype == cloud.fields[y_idx].datatype)); From 4175d66658d16a3874aff4312fbea6ed1a728f70 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 12 Mar 2021 07:14:22 +0530 Subject: [PATCH 036/431] Thanks @larshg for the typo correction :) Co-authored-by: Lars Glud --- .ci/azure-pipelines/env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-pipelines/env.yml b/.ci/azure-pipelines/env.yml index 5344a52400c..1fe345fa180 100644 --- a/.ci/azure-pipelines/env.yml +++ b/.ci/azure-pipelines/env.yml @@ -62,7 +62,7 @@ jobs: CUDA_VERSION: 11.2.1 UBUNTU_DISTRO: 21.04 VTK_VERSION: 9 - # nvidia-cuda docker image has not been released for 20.10 yet + # nvidia-cuda docker image has not been released for 21.04 yet USE_CUDA: "" tag: 21.04 steps: From 086c797bc397655c89e6de1fbea181f288e7b96b Mon Sep 17 00:00:00 2001 From: Markus Vieth <39675748+mvieth@users.noreply.github.com> Date: Fri, 12 Mar 2021 03:13:10 +0100 Subject: [PATCH 037/431] Fix and improve documentation (#4597) - Remove duplications - Correct line references - Fix broken links - Add missing ingroup command --- doc/tutorials/content/function_filter.rst | 2 -- doc/tutorials/content/gpu_people.rst | 20 ++++++++++---------- sample_consensus/sample_consensus.doxy | 10 +++++----- surface/include/pcl/surface/reconstruction.h | 1 + 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/doc/tutorials/content/function_filter.rst b/doc/tutorials/content/function_filter.rst index c04c2009f38..f346934b477 100644 --- a/doc/tutorials/content/function_filter.rst +++ b/doc/tutorials/content/function_filter.rst @@ -26,14 +26,12 @@ Now, let's break down the code piece by piece. In the following lines, we define the PointCloud structures, fill in the input cloud, and display its content to screen. .. literalinclude:: sources/function_filter/sphere_removal.cpp - :language: cpp :language: cpp :lines: 10-21 Then, we create the condition which a given point must satisfy so that it remains in our PointCloud. To do this we create a `std::function` which accepts a PointCloud by const reference and an index, and returns true only if the point lies inside a sphere. This is then used to build the filter .. literalinclude:: sources/function_filter/sphere_removal.cpp - :language: cpp :language: cpp :lines: 23-34 diff --git a/doc/tutorials/content/gpu_people.rst b/doc/tutorials/content/gpu_people.rst index 9ed6fe6f577..e9c9cdf0d8d 100644 --- a/doc/tutorials/content/gpu_people.rst +++ b/doc/tutorials/content/gpu_people.rst @@ -39,7 +39,7 @@ Now, let's break down the code piece by piece. Starting from the main routine. .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 317-367 + :lines: 319-369 First the GPU device is set, by default this is the first GPU found in the bus, but if you have multiple GPU's in your system, this allows you to select a specific one. @@ -47,7 +47,7 @@ Then a OpenNI Capture is made, see the OpenNI Grabber tutorial for more info on .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 329-338 + :lines: 331-340 The implementation is based on a similar approach as Shotton et al. and thus needs off-line learned random decision forests for labeling. The current implementation allows up to 4 decision trees to be loaded into @@ -55,19 +55,19 @@ the forest. This is done by giving it the names of the text files to load. .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 340-341 + :lines: 342-343 An additional parameter allows you to configure the number of trees to be loaded. .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 350-352 + :lines: 352-354 Then the RDF object is created, loading the trees upon creation. .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 354-359 + :lines: 356-361 Now we create the application object, give it the pointer to the RDF object and start the loop. Now we'll have a look at the main loop. @@ -75,7 +75,7 @@ Now we'll have a look at the main loop. .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 238-286 + :lines: 237-288 This routine first connects a callback routine to the grabber and waits for valid data to arrive. Each time the data arrives it will call the process function of the people detector, this is a @@ -87,13 +87,13 @@ The visualizeAndWrite method will illustrate one of the available methods of the .. literalinclude:: sources/gpu/people_detect/src/people_detect.cpp :language: cpp - :lines: 141-178 + :lines: 140-177 -Line 144 calls the RDF getLabels method which returns the labels on the device, these however +Line 143 calls the RDF getLabels method which returns the labels on the device, these however are a discrete enum of the labels and are visually hard to recognize, so these are converted to -colors that illustrate each body part in line 145. +colors that illustrate each body part in line 144. At this point the results are still stored in the device memory and need to be copied to the CPU -host memory, this is done in line 151. Afterwards the images are shown and stored to disk. +host memory, this is done in line 150. Afterwards the images are shown and stored to disk. Compiling and running the program --------------------------------- diff --git a/sample_consensus/sample_consensus.doxy b/sample_consensus/sample_consensus.doxy index 1cbf55d8445..aeaf62d401b 100644 --- a/sample_consensus/sample_consensus.doxy +++ b/sample_consensus/sample_consensus.doxy @@ -37,11 +37,11 @@ The following list describes the robust sample consensus estimators implemented: diff --git a/surface/include/pcl/surface/reconstruction.h b/surface/include/pcl/surface/reconstruction.h index de5939440fd..9a196d804d3 100644 --- a/surface/include/pcl/surface/reconstruction.h +++ b/surface/include/pcl/surface/reconstruction.h @@ -53,6 +53,7 @@ namespace pcl * - \b reconstruct(&PolygonMesh): creates a PolygonMesh object from the input data * * \author Radu B. Rusu, Michael Dixon, Alexandru E. Ichim + * \ingroup surface */ template class PCLSurfaceBase: public PCLBase From 793d190afd443c81c0a9b384c425a6ed83d2a618 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 12 Mar 2021 17:05:19 +0100 Subject: [PATCH 038/431] OctreePointCloudCompression: delete unused class member --- io/include/pcl/compression/octree_pointcloud_compression.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/io/include/pcl/compression/octree_pointcloud_compression.h b/io/include/pcl/compression/octree_pointcloud_compression.h index d251d35e7b6..8548daac363 100644 --- a/io/include/pcl/compression/octree_pointcloud_compression.h +++ b/io/include/pcl/compression/octree_pointcloud_compression.h @@ -252,9 +252,6 @@ namespace pcl /** \brief Vector for storing binary tree structure */ std::vector binary_tree_data_vector_; - /** \brief Iterator on binary tree structure vector */ - std::vector binary_color_tree_vector_; - /** \brief Vector for storing points per voxel information */ std::vector point_count_data_vector_; From 72b9a9bcc5a0fe8a763a00e61e4c8d9713bcd37a Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 12 Mar 2021 17:06:45 +0100 Subject: [PATCH 039/431] Octree2BufBase: compute bit pattern only when needed --- .../pcl/octree/impl/octree2buf_base.hpp | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree2buf_base.hpp b/octree/include/pcl/octree/impl/octree2buf_base.hpp index edaea812171..e1d46260b0c 100644 --- a/octree/include/pcl/octree/impl/octree2buf_base.hpp +++ b/octree/include/pcl/octree/impl/octree2buf_base.hpp @@ -559,21 +559,17 @@ Octree2BufBase::serializeTreeRecursive( bool do_XOR_encoding_arg, bool new_leafs_filter_arg) { - // bit pattern - char branch_bit_pattern_curr_buffer; - char branch_bit_pattern_prev_buffer; - char node_XOR_bit_pattern; - - // occupancy bit patterns of branch node (current and previous octree buffer) - branch_bit_pattern_curr_buffer = getBranchBitPattern(*branch_arg, buffer_selector_); - branch_bit_pattern_prev_buffer = getBranchBitPattern(*branch_arg, !buffer_selector_); - - // XOR of current and previous occupancy bit patterns - node_XOR_bit_pattern = - branch_bit_pattern_curr_buffer ^ branch_bit_pattern_prev_buffer; - if (binary_tree_out_arg) { + // occupancy bit patterns of branch node (current octree buffer) + const char branch_bit_pattern_curr_buffer = + getBranchBitPattern(*branch_arg, buffer_selector_); if (do_XOR_encoding_arg) { + // occupancy bit patterns of branch node (previous octree buffer) + const char branch_bit_pattern_prev_buffer = + getBranchBitPattern(*branch_arg, !buffer_selector_); + // XOR of current and previous occupancy bit patterns + const char node_XOR_bit_pattern = + branch_bit_pattern_curr_buffer ^ branch_bit_pattern_prev_buffer; // write XOR bit pattern to output vector binary_tree_out_arg->push_back(node_XOR_bit_pattern); } From bcc9eccfb015462dc0dc2d917988f68deb33ce92 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 12 Mar 2021 17:07:08 +0100 Subject: [PATCH 040/431] Octree2BufBase: clear leaf contents when copying from previous buffer The createLeafRecursive function reuses leaf nodes from the previous buffer if possible. Before this commit, the contents of the leaf were not cleared, so if the leaf e.g. contains point indices, they are practically copied from the previous to the current octree. --- octree/include/pcl/octree/impl/octree2buf_base.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/octree/include/pcl/octree/impl/octree2buf_base.hpp b/octree/include/pcl/octree/impl/octree2buf_base.hpp index e1d46260b0c..61f7f70f2d0 100644 --- a/octree/include/pcl/octree/impl/octree2buf_base.hpp +++ b/octree/include/pcl/octree/impl/octree2buf_base.hpp @@ -431,6 +431,7 @@ Octree2BufBase::createLeafRecursive( OctreeNode* child_node = branch_arg->getChildPtr(!buffer_selector_, child_idx); if (child_node->getNodeType() == LEAF_NODE) { child_leaf = static_cast(child_node); + child_leaf->getContainer() = LeafContainer(); // Clear contents of leaf branch_arg->setChildPtr(buffer_selector_, child_idx, child_node); } else { From cb72c13e6ef8d7f47187094d2e07f4082d3ff60a Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Tue, 15 Sep 2020 18:00:26 +0200 Subject: [PATCH 041/431] Use parenteses --- .ci/azure-pipelines/build/windows.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-pipelines/build/windows.yaml b/.ci/azure-pipelines/build/windows.yaml index 6ffce220103..0e0c90473be 100644 --- a/.ci/azure-pipelines/build/windows.yaml +++ b/.ci/azure-pipelines/build/windows.yaml @@ -40,6 +40,6 @@ steps: inputs: testResultsFormat: 'CTest' testResultsFiles: '**/Test*.xml' - searchFolder: '%BUILD_DIR%' + searchFolder: '$(BUILD_DIR)' condition: succeededOrFailed() From ef3d972e8c8e144f8264ea45532a181d5b7e4fcc Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Fri, 29 Jan 2021 16:26:51 +0100 Subject: [PATCH 042/431] Enable Xvfb for visualization tests. --- .ci/azure-pipelines/azure-pipelines.yaml | 2 ++ .ci/azure-pipelines/build/ubuntu.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml index a6b03419323..511e093a8ee 100644 --- a/.ci/azure-pipelines/azure-pipelines.yaml +++ b/.ci/azure-pipelines/azure-pipelines.yaml @@ -45,6 +45,7 @@ stages: variables: BUILD_DIR: '$(Agent.BuildDirectory)/build' CMAKE_CXX_FLAGS: '-Wall -Wextra -Wnoexcept-type' + DISPLAY: :99.0 # Checked for in CMake steps: - template: build/ubuntu.yaml @@ -94,6 +95,7 @@ stages: variables: BUILD_DIR: '$(Agent.BuildDirectory)/build' CMAKE_CXX_FLAGS: '-Wall -Wextra' + DISPLAY: :99.0 # Checked for in CMake steps: - template: build/ubuntu.yaml - job: ubuntu_indices diff --git a/.ci/azure-pipelines/build/ubuntu.yaml b/.ci/azure-pipelines/build/ubuntu.yaml index 559dfddd70e..99065d28ff6 100644 --- a/.ci/azure-pipelines/build/ubuntu.yaml +++ b/.ci/azure-pipelines/build/ubuntu.yaml @@ -1,4 +1,6 @@ steps: + - script: (nohup Xvfb :99 -screen 0 1280x1024x24 -nolisten tcp -nolisten unix &) + displayName: "Start Xvfb for DISPLAY=$(DISPLAY)" - checkout: self # find the commit hash on a quick non-forced update too fetchDepth: 10 From 6ddb59d1e15f0e5d664880a4b97a5b078e993d1f Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 13 Mar 2021 11:09:34 +0100 Subject: [PATCH 043/431] Add deprecation for incorrectly installed headers - Problem: some headers are currently installed twice - Add deprecation/redirection headers - Install these headers instead of one set of the "full" headers (so deprecation headers+full headers instead of full headers twice) - If user includes the wrong header (wrong path), it still works, but they get the deprecation notice --- recognition/CMakeLists.txt | 32 +++++++++---------- .../include/pcl/recognition/auxiliary.h | 2 ++ recognition/include/pcl/recognition/bvh.h | 2 ++ .../include/pcl/recognition/hypothesis.h | 2 ++ .../pcl/recognition/impl/line_rgbd.hpp | 2 ++ .../pcl/recognition/impl/simple_octree.hpp | 2 ++ .../pcl/recognition/impl/voxel_structure.hpp | 2 ++ .../include/pcl/recognition/line_rgbd.h | 2 ++ .../include/pcl/recognition/model_library.h | 2 ++ .../include/pcl/recognition/obj_rec_ransac.h | 2 ++ .../include/pcl/recognition/orr_graph.h | 2 ++ .../include/pcl/recognition/orr_octree.h | 2 ++ .../pcl/recognition/orr_octree_zprojection.h | 2 ++ .../pcl/recognition/rigid_transform_space.h | 2 ++ .../include/pcl/recognition/simple_octree.h | 2 ++ .../include/pcl/recognition/trimmed_icp.h | 2 ++ .../include/pcl/recognition/voxel_structure.h | 2 ++ 17 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 recognition/include/pcl/recognition/auxiliary.h create mode 100644 recognition/include/pcl/recognition/bvh.h create mode 100644 recognition/include/pcl/recognition/hypothesis.h create mode 100644 recognition/include/pcl/recognition/impl/line_rgbd.hpp create mode 100644 recognition/include/pcl/recognition/impl/simple_octree.hpp create mode 100644 recognition/include/pcl/recognition/impl/voxel_structure.hpp create mode 100644 recognition/include/pcl/recognition/line_rgbd.h create mode 100644 recognition/include/pcl/recognition/model_library.h create mode 100644 recognition/include/pcl/recognition/obj_rec_ransac.h create mode 100644 recognition/include/pcl/recognition/orr_graph.h create mode 100644 recognition/include/pcl/recognition/orr_octree.h create mode 100644 recognition/include/pcl/recognition/orr_octree_zprojection.h create mode 100644 recognition/include/pcl/recognition/rigid_transform_space.h create mode 100644 recognition/include/pcl/recognition/simple_octree.h create mode 100644 recognition/include/pcl/recognition/trimmed_icp.h create mode 100644 recognition/include/pcl/recognition/voxel_structure.h diff --git a/recognition/CMakeLists.txt b/recognition/CMakeLists.txt index 54d357e6f8d..7e9386e7cd9 100644 --- a/recognition/CMakeLists.txt +++ b/recognition/CMakeLists.txt @@ -38,20 +38,20 @@ set(incs "include/pcl/${SUBSYS_NAME}/dense_quantized_multi_mod_template.h" "include/pcl/${SUBSYS_NAME}/sparse_quantized_multi_mod_template.h" "include/pcl/${SUBSYS_NAME}/surface_normal_modality.h" - "include/pcl/${SUBSYS_NAME}/linemod/line_rgbd.h" + "include/pcl/${SUBSYS_NAME}/line_rgbd.h" "include/pcl/${SUBSYS_NAME}/implicit_shape_model.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/auxiliary.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/hypothesis.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/model_library.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/rigid_transform_space.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/obj_rec_ransac.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/orr_graph.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/orr_octree_zprojection.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/trimmed_icp.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/orr_octree.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/simple_octree.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/voxel_structure.h" - "include/pcl/${SUBSYS_NAME}/ransac_based/bvh.h" + "include/pcl/${SUBSYS_NAME}/auxiliary.h" + "include/pcl/${SUBSYS_NAME}/hypothesis.h" + "include/pcl/${SUBSYS_NAME}/model_library.h" + "include/pcl/${SUBSYS_NAME}/rigid_transform_space.h" + "include/pcl/${SUBSYS_NAME}/obj_rec_ransac.h" + "include/pcl/${SUBSYS_NAME}/orr_graph.h" + "include/pcl/${SUBSYS_NAME}/orr_octree_zprojection.h" + "include/pcl/${SUBSYS_NAME}/trimmed_icp.h" + "include/pcl/${SUBSYS_NAME}/orr_octree.h" + "include/pcl/${SUBSYS_NAME}/simple_octree.h" + "include/pcl/${SUBSYS_NAME}/voxel_structure.h" + "include/pcl/${SUBSYS_NAME}/bvh.h" ) set(ransac_based_incs @@ -91,9 +91,9 @@ set(cg_incs ) set(impl_incs - "include/pcl/${SUBSYS_NAME}/impl/linemod/line_rgbd.hpp" - "include/pcl/${SUBSYS_NAME}/impl/ransac_based/simple_octree.hpp" - "include/pcl/${SUBSYS_NAME}/impl/ransac_based/voxel_structure.hpp" + "include/pcl/${SUBSYS_NAME}/impl/line_rgbd.hpp" + "include/pcl/${SUBSYS_NAME}/impl/simple_octree.hpp" + "include/pcl/${SUBSYS_NAME}/impl/voxel_structure.hpp" "include/pcl/${SUBSYS_NAME}/impl/implicit_shape_model.hpp" ) diff --git a/recognition/include/pcl/recognition/auxiliary.h b/recognition/include/pcl/recognition/auxiliary.h new file mode 100644 index 00000000000..0e364add08e --- /dev/null +++ b/recognition/include/pcl/recognition/auxiliary.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/bvh.h b/recognition/include/pcl/recognition/bvh.h new file mode 100644 index 00000000000..12374a202c6 --- /dev/null +++ b/recognition/include/pcl/recognition/bvh.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/hypothesis.h b/recognition/include/pcl/recognition/hypothesis.h new file mode 100644 index 00000000000..ad8f5b642df --- /dev/null +++ b/recognition/include/pcl/recognition/hypothesis.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/impl/line_rgbd.hpp b/recognition/include/pcl/recognition/impl/line_rgbd.hpp new file mode 100644 index 00000000000..53d67119496 --- /dev/null +++ b/recognition/include/pcl/recognition/impl/line_rgbd.hpp @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/impl/simple_octree.hpp b/recognition/include/pcl/recognition/impl/simple_octree.hpp new file mode 100644 index 00000000000..0c8c0ccb3d0 --- /dev/null +++ b/recognition/include/pcl/recognition/impl/simple_octree.hpp @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/impl/voxel_structure.hpp b/recognition/include/pcl/recognition/impl/voxel_structure.hpp new file mode 100644 index 00000000000..44697e8e358 --- /dev/null +++ b/recognition/include/pcl/recognition/impl/voxel_structure.hpp @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/line_rgbd.h b/recognition/include/pcl/recognition/line_rgbd.h new file mode 100644 index 00000000000..5d526ad3984 --- /dev/null +++ b/recognition/include/pcl/recognition/line_rgbd.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/model_library.h b/recognition/include/pcl/recognition/model_library.h new file mode 100644 index 00000000000..4b4ee3345bd --- /dev/null +++ b/recognition/include/pcl/recognition/model_library.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/obj_rec_ransac.h b/recognition/include/pcl/recognition/obj_rec_ransac.h new file mode 100644 index 00000000000..52b96362eb5 --- /dev/null +++ b/recognition/include/pcl/recognition/obj_rec_ransac.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/orr_graph.h b/recognition/include/pcl/recognition/orr_graph.h new file mode 100644 index 00000000000..a43e35c9558 --- /dev/null +++ b/recognition/include/pcl/recognition/orr_graph.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/orr_octree.h b/recognition/include/pcl/recognition/orr_octree.h new file mode 100644 index 00000000000..b0f43fc2f27 --- /dev/null +++ b/recognition/include/pcl/recognition/orr_octree.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/orr_octree_zprojection.h b/recognition/include/pcl/recognition/orr_octree_zprojection.h new file mode 100644 index 00000000000..536f8a53f49 --- /dev/null +++ b/recognition/include/pcl/recognition/orr_octree_zprojection.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/rigid_transform_space.h b/recognition/include/pcl/recognition/rigid_transform_space.h new file mode 100644 index 00000000000..2cc30436bad --- /dev/null +++ b/recognition/include/pcl/recognition/rigid_transform_space.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/simple_octree.h b/recognition/include/pcl/recognition/simple_octree.h new file mode 100644 index 00000000000..aa47e0d885d --- /dev/null +++ b/recognition/include/pcl/recognition/simple_octree.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/trimmed_icp.h b/recognition/include/pcl/recognition/trimmed_icp.h new file mode 100644 index 00000000000..cabf17ba777 --- /dev/null +++ b/recognition/include/pcl/recognition/trimmed_icp.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") diff --git a/recognition/include/pcl/recognition/voxel_structure.h b/recognition/include/pcl/recognition/voxel_structure.h new file mode 100644 index 00000000000..a78e541ca7d --- /dev/null +++ b/recognition/include/pcl/recognition/voxel_structure.h @@ -0,0 +1,2 @@ +#include +PCL_DEPRECATED_HEADER(1, 15, "Please use instead") From 5b2339aeb0bc562354c712434cd7b182b687ea92 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 25 Aug 2020 04:15:22 +0900 Subject: [PATCH 044/431] Compile octree with all options enabled and int64 as indices --- common/include/pcl/common/io.h | 4 +-- common/src/io.cpp | 2 +- .../pcl/octree/impl/octree_pointcloud.hpp | 2 +- .../include/pcl/octree/impl/octree_search.hpp | 33 +++++++++---------- octree/include/pcl/octree/octree_container.h | 14 ++++---- octree/include/pcl/octree/octree_pointcloud.h | 4 +-- .../octree/octree_pointcloud_changedetector.h | 2 +- octree/include/pcl/octree/octree_search.h | 30 ++++++++--------- 8 files changed, 45 insertions(+), 46 deletions(-) diff --git a/common/include/pcl/common/io.h b/common/include/pcl/common/io.h index 33dfaf049e5..ccb6825de37 100644 --- a/common/include/pcl/common/io.h +++ b/common/include/pcl/common/io.h @@ -347,7 +347,7 @@ namespace pcl * \note Assumes unique indices. * \ingroup common */ - template > void + template > void copyPointCloud (const pcl::PointCloud &cloud_in, const IndicesAllocator< IndicesVectorAllocator> &indices, pcl::PointCloud &cloud_out); @@ -392,7 +392,7 @@ namespace pcl * \note Assumes unique indices. * \ingroup common */ - template > void + template > void copyPointCloud (const pcl::PointCloud &cloud_in, const IndicesAllocator &indices, pcl::PointCloud &cloud_out); diff --git a/common/src/io.cpp b/common/src/io.cpp index 9e8e7fc5cdc..838ab1c37a5 100644 --- a/common/src/io.cpp +++ b/common/src/io.cpp @@ -438,7 +438,7 @@ pcl::copyPointCloud ( void pcl::copyPointCloud ( const pcl::PCLPointCloud2 &cloud_in, - const IndicesAllocator< Eigen::aligned_allocator > &indices, + const IndicesAllocator< Eigen::aligned_allocator > &indices, pcl::PCLPointCloud2 &cloud_out) { cloud_out.header = cloud_in.header; diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 19bced45b1c..12d91b0bddb 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -612,7 +612,7 @@ pcl::octree::OctreePointCloud std::size_t leaf_obj_count = (*leaf_node)->getSize(); // copy leaf data - std::vector leafIndices; + Indices leafIndices; leafIndices.reserve(leaf_obj_count); (*leaf_node)->getPointIndices(leafIndices); diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 16b98ce0f98..8269cb98dd9 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -48,7 +48,7 @@ namespace octree { template bool OctreePointCloudSearch::voxelSearch( - const PointT& point, std::vector& point_idx_data) + const PointT& point, Indices& point_idx_data) { assert(isFinite(point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); @@ -71,7 +71,7 @@ OctreePointCloudSearch::voxelSearch( template bool OctreePointCloudSearch::voxelSearch( - const int index, std::vector& point_idx_data) + const int index, Indices& point_idx_data) { const PointT search_point = this->getPointByIndex(index); return (this->voxelSearch(search_point, point_idx_data)); @@ -80,10 +80,7 @@ OctreePointCloudSearch::voxelSearch( template int OctreePointCloudSearch::nearestKSearch( - const PointT& p_q, - int k, - std::vector& k_indices, - std::vector& k_sqr_distances) + const PointT& p_q, int k, Indices& k_indices, std::vector& k_sqr_distances) { assert(this->leaf_count_ > 0); assert(isFinite(p_q) && @@ -123,7 +120,7 @@ OctreePointCloudSearch::nearestKSearch template int OctreePointCloudSearch::nearestKSearch( - int index, int k, std::vector& k_indices, std::vector& k_sqr_distances) + int index, int k, Indices& k_indices, std::vector& k_sqr_distances) { const PointT search_point = this->getPointByIndex(index); return (nearestKSearch(search_point, k, k_indices, k_sqr_distances)); @@ -162,7 +159,7 @@ int OctreePointCloudSearch::radiusSearch( const PointT& p_q, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const { @@ -191,7 +188,7 @@ int OctreePointCloudSearch::radiusSearch( int index, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const { @@ -205,7 +202,7 @@ int OctreePointCloudSearch::boxSearch( const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, - std::vector& k_indices) const + Indices& k_indices) const { OctreeKey key; @@ -290,7 +287,7 @@ OctreePointCloudSearch:: } else { // we reached leaf node level - std::vector decoded_point_vector; + Indices decoded_point_vector; const LeafNode* child_leaf = static_cast(child_node); @@ -338,7 +335,7 @@ OctreePointCloudSearch:: const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const { @@ -389,7 +386,7 @@ OctreePointCloudSearch:: else { // we reached leaf node level const LeafNode* child_leaf = static_cast(child_node); - std::vector decoded_point_vector; + Indices decoded_point_vector; // decode leaf node into decoded_point_vector (*child_leaf)->getPointIndices(decoded_point_vector); @@ -479,7 +476,7 @@ OctreePointCloudSearch:: } else { // we reached leaf node level - std::vector decoded_point_vector; + Indices decoded_point_vector; const LeafNode* child_leaf = static_cast(child_node); @@ -522,7 +519,7 @@ OctreePointCloudSearch::boxSearchRecur const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices) const + Indices& k_indices) const { // iterate over all children for (unsigned char child_idx = 0; child_idx < 8; child_idx++) { @@ -563,7 +560,7 @@ OctreePointCloudSearch::boxSearchRecur } else { // we reached leaf node level - std::vector decoded_point_vector; + Indices decoded_point_vector; const LeafNode* child_leaf = static_cast(child_node); @@ -630,7 +627,7 @@ int OctreePointCloudSearch:: getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count) const { OctreeKey key; @@ -867,7 +864,7 @@ OctreePointCloudSearch:: unsigned char a, const OctreeNode* node, const OctreeKey& key, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count) const { if (max_x < 0.0 || max_y < 0.0 || max_z < 0.0) diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index c4655b7cfdf..4452f0ca04a 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -38,6 +38,8 @@ #pragma once +#include + #include #include #include @@ -102,7 +104,7 @@ class OctreeContainerBase { * data. \ */ void - getPointIndices(std::vector&) const + getPointIndices(Indices&) const {} }; @@ -157,7 +159,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { * data. */ void - getPointIndices(std::vector&) const + getPointIndices(Indices&) const {} }; @@ -216,7 +218,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { * data vector */ void - getPointIndices(std::vector& data_vector_arg) const + getPointIndices(Indices& data_vector_arg) const { if (data_ >= 0) data_vector_arg.push_back(data_); @@ -295,7 +297,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * within data vector */ void - getPointIndices(std::vector& data_vector_arg) const + getPointIndices(Indices& data_vector_arg) const { data_vector_arg.insert( data_vector_arg.end(), leafDataTVector_.begin(), leafDataTVector_.end()); @@ -305,7 +307,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * of point indices. * \return reference to vector of point indices to be stored within data vector */ - std::vector& + Indices& getPointIndicesVector() { return leafDataTVector_; @@ -329,7 +331,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { protected: /** \brief Leaf node DataT vector. */ - std::vector leafDataTVector_; + Indices leafDataTVector_; }; } // namespace octree diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 4f66675c530..41e12709cc6 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -82,8 +82,8 @@ class OctreePointCloud : public OctreeT { OctreePointCloud(const double resolution_arg); // public typedefs - using IndicesPtr = shared_ptr>; - using IndicesConstPtr = shared_ptr>; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloud = pcl::PointCloud; using PointCloudPtr = typename PointCloud::Ptr; diff --git a/octree/include/pcl/octree/octree_pointcloud_changedetector.h b/octree/include/pcl/octree/octree_pointcloud_changedetector.h index 902dfd2c9d5..fd06d3beca6 100644 --- a/octree/include/pcl/octree/octree_pointcloud_changedetector.h +++ b/octree/include/pcl/octree/octree_pointcloud_changedetector.h @@ -91,7 +91,7 @@ class OctreePointCloudChangeDetector * \return number of point indices */ std::size_t - getPointIndicesFromNewVoxels(std::vector& indicesVector_arg, + getPointIndicesFromNewVoxels(Indices& indicesVector_arg, const int minPointsPerLeaf_arg = 0) { diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index 83d30c6f1d3..6ea74d9e643 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -58,8 +58,8 @@ class OctreePointCloudSearch : public OctreePointCloud { public: // public typedefs - using IndicesPtr = shared_ptr>; - using IndicesConstPtr = shared_ptr>; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloud = pcl::PointCloud; using PointCloudPtr = typename PointCloud::Ptr; @@ -91,7 +91,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const PointT& point, std::vector& point_idx_data); + voxelSearch(const PointT& point, Indices& point_idx_data); /** \brief Search for neighbors within a voxel at given point referenced by a point * index @@ -100,7 +100,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const int index, std::vector& point_idx_data); + voxelSearch(const int index, Indices& point_idx_data); /** \brief Search for k-nearest neighbors at the query point. * \param[in] cloud the point cloud data @@ -116,7 +116,7 @@ class OctreePointCloudSearch nearestKSearch(const PointCloud& cloud, int index, int k, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances) { return (nearestKSearch(cloud[index], k, k_indices, k_sqr_distances)); @@ -134,7 +134,7 @@ class OctreePointCloudSearch int nearestKSearch(const PointT& p_q, int k, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances); /** \brief Search for k-nearest neighbors at query point @@ -151,7 +151,7 @@ class OctreePointCloudSearch int nearestKSearch(int index, int k, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances); /** \brief Search for approx. nearest neighbor at the query point. @@ -203,7 +203,7 @@ class OctreePointCloudSearch radiusSearch(const PointCloud& cloud, int index, double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn = 0) { @@ -222,7 +222,7 @@ class OctreePointCloudSearch int radiusSearch(const PointT& p_q, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn = 0) const; @@ -240,7 +240,7 @@ class OctreePointCloudSearch int radiusSearch(int index, const double radius, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn = 0) const; @@ -270,7 +270,7 @@ class OctreePointCloudSearch int getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count = 0) const; /** \brief Search for points within rectangular search area @@ -283,7 +283,7 @@ class OctreePointCloudSearch int boxSearch(const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, - std::vector& k_indices) const; + Indices& k_indices) const; protected: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -389,7 +389,7 @@ class OctreePointCloudSearch const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices, + Indices& k_indices, std::vector& k_sqr_distances, unsigned int max_nn) const; @@ -477,7 +477,7 @@ class OctreePointCloudSearch const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - std::vector& k_indices) const; + Indices& k_indices) const; /** \brief Recursively search the tree for all intersected leaf nodes and return a * vector of indices. This algorithm is based off the paper An Efficient Parametric @@ -506,7 +506,7 @@ class OctreePointCloudSearch unsigned char a, const OctreeNode* node, const OctreeKey& key, - std::vector& k_indices, + Indices& k_indices, int max_voxel_count) const; /** \brief Initialize raytracing algorithm From 9c49ead861079120d6d330831a3b59db5837157b Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Wed, 26 Aug 2020 10:37:03 +0900 Subject: [PATCH 045/431] Octree PointCloud checked --- .../pcl/octree/impl/octree_pointcloud.hpp | 37 ++++----- .../impl/octree_pointcloud_adjacency.hpp | 4 +- .../include/pcl/octree/impl/octree_search.hpp | 81 ++++++++++--------- octree/include/pcl/octree/octree_pointcloud.h | 16 ++-- .../pcl/octree/octree_pointcloud_adjacency.h | 2 +- .../octree_pointcloud_adjacency_container.h | 4 +- .../pcl/octree/octree_pointcloud_density.h | 10 +-- .../octree/octree_pointcloud_voxelcentroid.h | 11 +-- octree/include/pcl/octree/octree_search.h | 70 ++++++++-------- 9 files changed, 118 insertions(+), 117 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 12d91b0bddb..c467417f6dc 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -41,6 +41,7 @@ #include #include // for pcl::isFinite #include +#include #include @@ -78,8 +79,8 @@ pcl::octree::OctreePointCloud addPointsFromInputCloud() { if (indices_) { - for (const int& index : *indices_) { - assert((index >= 0) && (index < static_cast(input_->size()))); + for (const auto& index : *indices_) { + assert((index >= 0) && (index < input_->size())); if (isFinite((*input_)[index])) { // add points to octree @@ -88,10 +89,10 @@ pcl::octree::OctreePointCloud } } else { - for (std::size_t i = 0; i < input_->size(); i++) { + for (index_t i = 0; i < static_cast(input_->size()); i++) { if (isFinite((*input_)[i])) { // add points to octree - this->addPointIdx(static_cast(i)); + this->addPointIdx(i); } } } @@ -104,7 +105,7 @@ template void pcl::octree::OctreePointCloud:: - addPointFromCloud(const int point_idx_arg, IndicesPtr indices_arg) + addPointFromCloud(const index_t point_idx_arg, IndicesPtr indices_arg) { this->addPointIdx(point_idx_arg); if (indices_arg) @@ -124,7 +125,7 @@ pcl::octree::OctreePointCloud cloud_arg->push_back(point_arg); - this->addPointIdx(static_cast(cloud_arg->size()) - 1); + this->addPointIdx(cloud_arg->size() - 1); } ////////////////////////////////////////////////////////////////////////////////////////////// @@ -143,7 +144,7 @@ pcl::octree::OctreePointCloud cloud_arg->push_back(point_arg); - this->addPointFromCloud(static_cast(cloud_arg->size()) - 1, indices_arg); + this->addPointFromCloud(cloud_arg->size() - 1, indices_arg); } ////////////////////////////////////////////////////////////////////////////////////////////// @@ -175,7 +176,7 @@ template bool pcl::octree::OctreePointCloud:: - isVoxelOccupiedAtPoint(const int& point_idx_arg) const + isVoxelOccupiedAtPoint(const index_t& point_idx_arg) const { // retrieve point from input cloud const PointT& point = (*this->input_)[point_idx_arg]; @@ -233,7 +234,7 @@ template void pcl::octree::OctreePointCloud:: - deleteVoxelAtPoint(const int& point_idx_arg) + deleteVoxelAtPoint(const index_t& point_idx_arg) { // retrieve point from input cloud const PointT& point = (*this->input_)[point_idx_arg]; @@ -247,7 +248,7 @@ template -int +pcl::uindex_t pcl::octree::OctreePointCloud:: getOccupiedVoxelCenters(AlignedPointTVector& voxel_center_list_arg) const { @@ -628,7 +629,7 @@ pcl::octree::OctreePointCloud // add data to new branch OctreeKey new_index_key; - for (const int& leafIndex : leafIndices) { + for (const auto& leafIndex : leafIndices) { const PointT& point_from_index = (*input_)[leafIndex]; // generate key @@ -651,11 +652,11 @@ template void pcl::octree::OctreePointCloud:: - addPointIdx(const int point_idx_arg) + addPointIdx(const index_t point_idx_arg) { OctreeKey key; - assert(point_idx_arg < static_cast(input_->size())); + assert(point_idx_arg < input_->size()); const PointT& point = (*input_)[point_idx_arg]; @@ -699,10 +700,10 @@ template const PointT& pcl::octree::OctreePointCloud:: - getPointByIndex(const unsigned int index_arg) const + getPointByIndex(const index_t index_arg) const { // retrieve point from input cloud - assert(index_arg < static_cast(input_->size())); + assert(index_arg < input_->size()); return ((*this->input_)[index_arg]); } @@ -833,7 +834,7 @@ template bool pcl::octree::OctreePointCloud:: - genOctreeKeyForDataT(const int& data_arg, OctreeKey& key_arg) const + genOctreeKeyForDataT(const index_t& data_arg, OctreeKey& key_arg) const { const PointT temp_point = getPointByIndex(data_arg); @@ -962,13 +963,13 @@ template -int +pcl::uindex_t pcl::octree::OctreePointCloud:: getOccupiedVoxelCentersRecursive(const BranchNode* node_arg, const OctreeKey& key_arg, AlignedPointTVector& voxel_center_list_arg) const { - int voxel_count = 0; + uindex_t voxel_count = 0; // iterate over all children for (unsigned char child_idx = 0; child_idx < 8; child_idx++) { diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index 51623030f46..0b1a00c6cec 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -153,11 +153,11 @@ pcl::octree::OctreePointCloudAdjacency template void pcl::octree::OctreePointCloudAdjacency:: - addPointIdx(const int pointIdx_arg) + addPointIdx(const index_t pointIdx_arg) { OctreeKey key; - assert(pointIdx_arg < static_cast(this->input_->size())); + assert(pointIdx_arg < this->input_->size()); const PointT& point = (*this->input_)[pointIdx_arg]; if (!pcl::isFinite(point)) diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 8269cb98dd9..6f7563bad00 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -71,16 +71,19 @@ OctreePointCloudSearch::voxelSearch( template bool OctreePointCloudSearch::voxelSearch( - const int index, Indices& point_idx_data) + const index_t index, Indices& point_idx_data) { const PointT search_point = this->getPointByIndex(index); return (this->voxelSearch(search_point, point_idx_data)); } template -int +uindex_t OctreePointCloudSearch::nearestKSearch( - const PointT& p_q, int k, Indices& k_indices, std::vector& k_sqr_distances) + const PointT& p_q, + uindex_t k, + Indices& k_indices, + std::vector& k_sqr_distances) { assert(this->leaf_count_ > 0); assert(isFinite(p_q) && @@ -104,23 +107,23 @@ OctreePointCloudSearch::nearestKSearch getKNearestNeighborRecursive( p_q, k, this->root_node_, key, 1, smallest_dist, point_candidates); - unsigned int result_count = static_cast(point_candidates.size()); + index_t result_count = static_cast(point_candidates.size()); k_indices.resize(result_count); k_sqr_distances.resize(result_count); - for (unsigned int i = 0; i < result_count; ++i) { + for (index_t i = 0; i < result_count; ++i) { k_indices[i] = point_candidates[i].point_idx_; k_sqr_distances[i] = point_candidates[i].point_distance_; } - return static_cast(k_indices.size()); + return k_indices.size(); } template -int +uindex_t OctreePointCloudSearch::nearestKSearch( - int index, int k, Indices& k_indices, std::vector& k_sqr_distances) + index_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) { const PointT search_point = this->getPointByIndex(index); return (nearestKSearch(search_point, k, k_indices, k_sqr_distances)); @@ -129,7 +132,7 @@ OctreePointCloudSearch::nearestKSearch template void OctreePointCloudSearch::approxNearestSearch( - const PointT& p_q, int& result_index, float& sqr_distance) + const PointT& p_q, index_t& result_index, float& sqr_distance) { assert(this->leaf_count_ > 0); assert(isFinite(p_q) && @@ -147,7 +150,7 @@ OctreePointCloudSearch::approxNearestS template void OctreePointCloudSearch::approxNearestSearch( - int query_index, int& result_index, float& sqr_distance) + index_t query_index, index_t& result_index, float& sqr_distance) { const PointT search_point = this->getPointByIndex(query_index); @@ -155,13 +158,13 @@ OctreePointCloudSearch::approxNearestS } template -int +uindex_t OctreePointCloudSearch::radiusSearch( const PointT& p_q, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const + uindex_t max_nn) const { assert(isFinite(p_q) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); @@ -180,17 +183,17 @@ OctreePointCloudSearch::radiusSearch( k_sqr_distances, max_nn); - return (static_cast(k_indices.size())); + return k_indices.size(); } template -int +uindex_t OctreePointCloudSearch::radiusSearch( - int index, + index_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const + uindex_t max_nn) const { const PointT search_point = this->getPointByIndex(index); @@ -198,7 +201,7 @@ OctreePointCloudSearch::radiusSearch( } template -int +uindex_t OctreePointCloudSearch::boxSearch( const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, @@ -212,7 +215,7 @@ OctreePointCloudSearch::boxSearch( boxSearchRecursive(min_pt, max_pt, this->root_node_, key, 1, k_indices); - return (static_cast(k_indices.size())); + return k_indices.size(); } template @@ -220,7 +223,7 @@ double OctreePointCloudSearch:: getKNearestNeighborRecursive( const PointT& point, - unsigned int K, + uindex_t K, const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, @@ -295,7 +298,7 @@ OctreePointCloudSearch:: (*child_leaf)->getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& point_index : decoded_point_vector) { + for (const auto& point_index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(point_index); @@ -337,7 +340,7 @@ OctreePointCloudSearch:: unsigned int tree_depth, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const + uindex_t max_nn) const { // get spatial voxel information double voxel_squared_diameter = this->getVoxelSquaredDiameter(tree_depth); @@ -380,7 +383,7 @@ OctreePointCloudSearch:: k_indices, k_sqr_distances, max_nn); - if (max_nn != 0 && k_indices.size() == static_cast(max_nn)) + if (max_nn != 0 && k_indices.size() == max_nn) return; } else { @@ -392,7 +395,7 @@ OctreePointCloudSearch:: (*child_leaf)->getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& index : decoded_point_vector) { + for (const auto& index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(index); // calculate point distance to search point @@ -406,7 +409,7 @@ OctreePointCloudSearch:: k_indices.push_back(index); k_sqr_distances.push_back(squared_dist); - if (max_nn != 0 && k_indices.size() == static_cast(max_nn)) + if (max_nn != 0 && k_indices.size() == max_nn) return; } } @@ -421,7 +424,7 @@ OctreePointCloudSearch:: const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - int& result_index, + index_t& result_index, float& sqr_distance) { OctreeKey minChildKey; @@ -486,7 +489,7 @@ OctreePointCloudSearch:: (**child_leaf).getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& index : decoded_point_vector) { + for (const auto& index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(index); // calculate point distance to search point @@ -568,7 +571,7 @@ OctreePointCloudSearch::boxSearchRecur (**child_leaf).getPointIndices(decoded_point_vector); // Linearly iterate over all decoded (unsorted) points - for (const int& index : decoded_point_vector) { + for (const auto& index : decoded_point_vector) { const PointT& candidate_point = this->getPointByIndex(index); // check if point falls within search box @@ -587,12 +590,12 @@ OctreePointCloudSearch::boxSearchRecur } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelCenters(Eigen::Vector3f origin, Eigen::Vector3f direction, AlignedPointTVector& voxel_center_list, - int max_voxel_count) const + uindex_t max_voxel_count) const { OctreeKey key; key.x = key.y = key.z = 0; @@ -623,12 +626,12 @@ OctreePointCloudSearch:: } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, Indices& k_indices, - int max_voxel_count) const + uindex_t max_voxel_count) const { OctreeKey key; key.x = key.y = key.z = 0; @@ -657,7 +660,7 @@ OctreePointCloudSearch:: } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelCentersRecursive(double min_x, double min_y, @@ -669,7 +672,7 @@ OctreePointCloudSearch:: const OctreeNode* node, const OctreeKey& key, AlignedPointTVector& voxel_center_list, - int max_voxel_count) const + uindex_t max_voxel_count) const { if (max_x < 0.0 || max_y < 0.0 || max_z < 0.0) return (0); @@ -686,7 +689,7 @@ OctreePointCloudSearch:: } // Voxel intersection count for branches children - int voxel_count = 0; + uindex_t voxel_count = 0; // Voxel mid lines double mid_x = 0.5 * (min_x + max_x); @@ -694,7 +697,7 @@ OctreePointCloudSearch:: double mid_z = 0.5 * (min_z + max_z); // First voxel node ray will intersect - int curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); + auto curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); // Child index, node and key unsigned char child_idx; @@ -853,7 +856,7 @@ OctreePointCloudSearch:: } template -int +uindex_t OctreePointCloudSearch:: getIntersectedVoxelIndicesRecursive(double min_x, double min_y, @@ -865,7 +868,7 @@ OctreePointCloudSearch:: const OctreeNode* node, const OctreeKey& key, Indices& k_indices, - int max_voxel_count) const + uindex_t max_voxel_count) const { if (max_x < 0.0 || max_y < 0.0 || max_z < 0.0) return (0); @@ -881,7 +884,7 @@ OctreePointCloudSearch:: } // Voxel intersection count for branches children - int voxel_count = 0; + uindex_t voxel_count = 0; // Voxel mid lines double mid_x = 0.5 * (min_x + max_x); @@ -889,7 +892,7 @@ OctreePointCloudSearch:: double mid_z = 0.5 * (min_z + max_z); // First voxel node ray will intersect - int curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); + auto curr_node = getFirstIntersectedNode(min_x, min_y, min_z, mid_x, mid_y, mid_z); // Child index, node and key unsigned char child_idx; diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 41e12709cc6..8d7fabc7beb 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -200,7 +200,7 @@ class OctreePointCloud : public OctreeT { * setInputCloud) */ void - addPointFromCloud(const int point_idx_arg, IndicesPtr indices_arg); + addPointFromCloud(index_t point_idx_arg, IndicesPtr indices_arg); /** \brief Add point simultaneously to octree and input point cloud. * \param[in] point_arg point to be added @@ -258,14 +258,14 @@ class OctreePointCloud : public OctreeT { * \return "true" if voxel exist; "false" otherwise */ bool - isVoxelOccupiedAtPoint(const int& point_idx_arg) const; + isVoxelOccupiedAtPoint(const index_t& point_idx_arg) const; /** \brief Get a PointT vector of centers of all occupied voxels. * \param[out] voxel_center_list_arg results are written to this vector of PointT * elements * \return number of occupied voxels */ - int + uindex_t getOccupiedVoxelCenters(AlignedPointTVector& voxel_center_list_arg) const; /** \brief Get a PointT vector of centers of voxels intersected by a line segment. @@ -295,7 +295,7 @@ class OctreePointCloud : public OctreeT { * \param[in] point_idx_arg index of point addressing the voxel to be deleted. */ void - deleteVoxelAtPoint(const int& point_idx_arg); + deleteVoxelAtPoint(const index_t& point_idx_arg); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Bounding box methods @@ -428,7 +428,7 @@ class OctreePointCloud : public OctreeT { * \a setInputCloud to be added */ virtual void - addPointIdx(const int point_idx_arg); + addPointIdx(index_t point_idx_arg); /** \brief Add point at index from input pointcloud dataset to octree * \param[in] leaf_node to be expanded @@ -448,7 +448,7 @@ class OctreePointCloud : public OctreeT { * \return PointT from input pointcloud dataset */ const PointT& - getPointByIndex(const unsigned int index_arg) const; + getPointByIndex(index_t index_arg) const; /** \brief Find octree leaf node at a given point * \param[in] point_arg query point @@ -520,7 +520,7 @@ class OctreePointCloud : public OctreeT { * are assignable */ virtual bool - genOctreeKeyForDataT(const int& data_arg, OctreeKey& key_arg) const; + genOctreeKeyForDataT(const index_t& data_arg, OctreeKey& key_arg) const; /** \brief Generate a point at center of leaf node voxel * \param[in] key_arg octree key addressing a leaf node. @@ -560,7 +560,7 @@ class OctreePointCloud : public OctreeT { * elements * \return number of voxels found */ - int + uindex_t getOccupiedVoxelCentersRecursive(const BranchNode* node_arg, const OctreeKey& key_arg, AlignedPointTVector& voxel_center_list_arg) const; diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency.h b/octree/include/pcl/octree/octree_pointcloud_adjacency.h index bc9c55cb26c..8b93c9b71d3 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency.h @@ -195,7 +195,7 @@ class OctreePointCloudAdjacency * \note This virtual implementation allows the use of a transform function to compute * keys. */ void - addPointIdx(const int point_idx_arg) override; + addPointIdx(index_t point_idx_arg) override; /** \brief Fills in the neighbors fields for new voxels. * diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index 16f257cdf97..f79f53e0d81 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -170,7 +170,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { /** \brief Sets the number of points contributing to this leaf */ void - setPointCounter(int points_arg) + setPointCounter(uindex_t points_arg) { num_points_ = points_arg; } @@ -218,7 +218,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { } private: - int num_points_; + uindex_t num_points_; NeighborListT neighbors_; DataT data_; }; diff --git a/octree/include/pcl/octree/octree_pointcloud_density.h b/octree/include/pcl/octree/octree_pointcloud_density.h index 19e97d045d1..61545019577 100644 --- a/octree/include/pcl/octree/octree_pointcloud_density.h +++ b/octree/include/pcl/octree/octree_pointcloud_density.h @@ -76,11 +76,7 @@ class OctreePointCloudDensityContainer : public OctreeContainerBase { /** \brief Read input data. Only an internal counter is increased. */ - void - addPointIndex(int) - { - point_counter_++; - } + void addPointIndex(index_t) { point_counter_++; } /** \brief Return point counter. * \return Amount of points @@ -99,7 +95,7 @@ class OctreePointCloudDensityContainer : public OctreeContainerBase { } private: - unsigned int point_counter_; + uindex_t point_counter_; }; /** \brief @b Octree pointcloud density class @@ -136,7 +132,7 @@ class OctreePointCloudDensity unsigned int getVoxelDensityAtPoint(const PointT& point_arg) const { - unsigned int point_count = 0; + uindex_t point_count = 0; OctreePointCloudDensityContainer* leaf = this->findLeafAtPoint(point_arg); diff --git a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h index 1207db8ec99..4c8973f9019 100644 --- a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h +++ b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h @@ -114,7 +114,7 @@ class OctreePointCloudVoxelCentroidContainer : public OctreeContainerBase { } private: - unsigned int point_counter_; + uindex_t point_counter_; PointT point_sum_; }; @@ -156,11 +156,11 @@ class OctreePointCloudVoxelCentroid * \param pointIdx_arg */ void - addPointIdx(const int pointIdx_arg) override + addPointIdx(const index_t pointIdx_arg) override { OctreeKey key; - assert(pointIdx_arg < static_cast(this->input_->size())); + assert(pointIdx_arg < this->input_->size()); const PointT& point = (*this->input_)[pointIdx_arg]; @@ -190,7 +190,8 @@ class OctreePointCloudVoxelCentroid * \return "true" if voxel is found; "false" otherwise */ inline bool - getVoxelCentroidAtPoint(const int& point_idx_arg, PointT& voxel_centroid_arg) const + getVoxelCentroidAtPoint(const index_t& point_idx_arg, + PointT& voxel_centroid_arg) const { // get centroid at point return (this->getVoxelCentroidAtPoint((*this->input_)[point_idx_arg], @@ -202,7 +203,7 @@ class OctreePointCloudVoxelCentroid * elements * \return number of occupied voxels */ - std::size_t + uindex_t getVoxelCentroids( typename OctreePointCloud:: AlignedPointTVector& voxel_centroid_list_arg) const; diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index 6ea74d9e643..df5dffaca9d 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -100,7 +100,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const int index, Indices& point_idx_data); + voxelSearch(const index_t index, Indices& point_idx_data); /** \brief Search for k-nearest neighbors at the query point. * \param[in] cloud the point cloud data @@ -112,10 +112,10 @@ class OctreePointCloudSearch * points (must be resized to \a k a priori!) * \return number of neighbors found */ - inline int + inline uindex_t nearestKSearch(const PointCloud& cloud, - int index, - int k, + index_t index, + uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) { @@ -131,9 +131,9 @@ class OctreePointCloudSearch * points (must be resized to k a priori!) * \return number of neighbors found */ - int + uindex_t nearestKSearch(const PointT& p_q, - int k, + uindex_t k, Indices& k_indices, std::vector& k_sqr_distances); @@ -148,9 +148,9 @@ class OctreePointCloudSearch * points (must be resized to \a k a priori!) * \return number of neighbors found */ - int - nearestKSearch(int index, - int k, + uindex_t + nearestKSearch(index_t index, + uindex_t k, Indices& k_indices, std::vector& k_sqr_distances); @@ -163,8 +163,8 @@ class OctreePointCloudSearch */ inline void approxNearestSearch(const PointCloud& cloud, - int query_index, - int& result_index, + index_t query_index, + index_t& result_index, float& sqr_distance) { return (approxNearestSearch(cloud[query_index], result_index, sqr_distance)); @@ -176,7 +176,7 @@ class OctreePointCloudSearch * \param[out] sqr_distance the resultant squared distance to the neighboring point */ void - approxNearestSearch(const PointT& p_q, int& result_index, float& sqr_distance); + approxNearestSearch(const PointT& p_q, index_t& result_index, float& sqr_distance); /** \brief Search for approx. nearest neighbor at the query point. * \param[in] query_index index representing the query point in the dataset given by @@ -187,7 +187,7 @@ class OctreePointCloudSearch * \return number of neighbors found */ void - approxNearestSearch(int query_index, int& result_index, float& sqr_distance); + approxNearestSearch(index_t query_index, index_t& result_index, float& sqr_distance); /** \brief Search for all neighbors of query point that are within a given radius. * \param[in] cloud the point cloud data @@ -199,13 +199,13 @@ class OctreePointCloudSearch * \param[in] max_nn if given, bounds the maximum returned neighbors to this value * \return number of neighbors found in radius */ - int + uindex_t radiusSearch(const PointCloud& cloud, - int index, + index_t index, double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn = 0) + index_t max_nn = 0) { return (radiusSearch(cloud[index], radius, k_indices, k_sqr_distances, max_nn)); } @@ -219,12 +219,12 @@ class OctreePointCloudSearch * \param[in] max_nn if given, bounds the maximum returned neighbors to this value * \return number of neighbors found in radius */ - int + uindex_t radiusSearch(const PointT& p_q, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn = 0) const; + uindex_t max_nn = 0) const; /** \brief Search for all neighbors of query point that are within a given radius. * \param[in] index index representing the query point in the dataset given by \a @@ -237,12 +237,12 @@ class OctreePointCloudSearch * \param[in] max_nn if given, bounds the maximum returned neighbors to this value * \return number of neighbors found in radius */ - int - radiusSearch(int index, + uindex_t + radiusSearch(index_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn = 0) const; + uindex_t max_nn = 0) const; /** \brief Get a PointT vector of centers of all voxels that intersected by a ray * (origin, direction). @@ -253,11 +253,11 @@ class OctreePointCloudSearch * disable) * \return number of intersected voxels */ - int + uindex_t getIntersectedVoxelCenters(Eigen::Vector3f origin, Eigen::Vector3f direction, AlignedPointTVector& voxel_center_list, - int max_voxel_count = 0) const; + uindex_t max_voxel_count = 0) const; /** \brief Get indices of all voxels that are intersected by a ray (origin, * direction). @@ -267,11 +267,11 @@ class OctreePointCloudSearch * disable) * \return number of intersected voxels */ - int + uindex_t getIntersectedVoxelIndices(Eigen::Vector3f origin, Eigen::Vector3f direction, Indices& k_indices, - int max_voxel_count = 0) const; + uindex_t max_voxel_count = 0) const; /** \brief Search for points within rectangular search area * Points exactly on the edges of the search rectangle are included. @@ -280,7 +280,7 @@ class OctreePointCloudSearch * \param[out] k_indices the resultant point indices * \return number of points found within search area */ - int + uindex_t boxSearch(const Eigen::Vector3f& min_pt, const Eigen::Vector3f& max_pt, Indices& k_indices) const; @@ -341,7 +341,7 @@ class OctreePointCloudSearch * \param[in] point_idx index for a dataset point given by \a setInputCloud * \param[in] point_distance distance of query point to voxel center */ - prioPointQueueEntry(unsigned int& point_idx, float point_distance) + prioPointQueueEntry(index_t point_idx, float point_distance) : point_idx_(point_idx), point_distance_(point_distance) {} @@ -355,7 +355,7 @@ class OctreePointCloudSearch } /** \brief Index representing a point in the dataset given by \a setInputCloud. */ - int point_idx_; + index_t point_idx_; /** \brief Distance to query point. */ float point_distance_; @@ -391,7 +391,7 @@ class OctreePointCloudSearch unsigned int tree_depth, Indices& k_indices, std::vector& k_sqr_distances, - unsigned int max_nn) const; + uindex_t max_nn) const; /** \brief Recursive search method that explores the octree and finds the K nearest * neighbors @@ -407,7 +407,7 @@ class OctreePointCloudSearch double getKNearestNeighborRecursive( const PointT& point, - unsigned int K, + uindex_t K, const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, @@ -428,7 +428,7 @@ class OctreePointCloudSearch const BranchNode* node, const OctreeKey& key, unsigned int tree_depth, - int& result_index, + index_t& result_index, float& sqr_distance); /** \brief Recursively search the tree for all intersected leaf nodes and return a @@ -449,7 +449,7 @@ class OctreePointCloudSearch * disable) * \return number of voxels found */ - int + uindex_t getIntersectedVoxelCentersRecursive(double min_x, double min_y, double min_z, @@ -460,7 +460,7 @@ class OctreePointCloudSearch const OctreeNode* node, const OctreeKey& key, AlignedPointTVector& voxel_center_list, - int max_voxel_count) const; + uindex_t max_voxel_count) const; /** \brief Recursive search method that explores the octree and finds points within a * rectangular search area @@ -496,7 +496,7 @@ class OctreePointCloudSearch * disable) * \return number of voxels found */ - int + uindex_t getIntersectedVoxelIndicesRecursive(double min_x, double min_y, double min_z, @@ -507,7 +507,7 @@ class OctreePointCloudSearch const OctreeNode* node, const OctreeKey& key, Indices& k_indices, - int max_voxel_count) const; + uindex_t max_voxel_count) const; /** \brief Initialize raytracing algorithm * \param origin From c195686fef0995d93b42fce983faeccd51c1ddb4 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 25 Aug 2020 04:45:34 +0900 Subject: [PATCH 046/431] Second batch of changes detected via io --- io/include/pcl/compression/color_coding.h | 4 ++-- .../impl/octree_pointcloud_compression.hpp | 2 +- io/include/pcl/compression/point_coding.h | 2 +- octree/include/pcl/octree/octree_container.h | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/io/include/pcl/compression/color_coding.h b/io/include/pcl/compression/color_coding.h index b4b9e6de5e5..af0e6414df5 100644 --- a/io/include/pcl/compression/color_coding.h +++ b/io/include/pcl/compression/color_coding.h @@ -155,7 +155,7 @@ class ColorCoding * \param inputCloud_arg input point cloud * */ void - encodeAverageOfPoints (const typename std::vector& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) + encodeAverageOfPoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { unsigned int avgRed = 0; unsigned int avgGreen = 0; @@ -202,7 +202,7 @@ class ColorCoding * \param inputCloud_arg input point cloud * */ void - encodePoints (const typename std::vector& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) + encodePoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { unsigned int avgRed; unsigned int avgGreen; diff --git a/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp b/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp index e28e754b306..098f579fc25 100644 --- a/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp +++ b/io/include/pcl/compression/impl/octree_pointcloud_compression.hpp @@ -473,7 +473,7 @@ namespace pcl LeafT &leaf_arg, const OctreeKey & key_arg) { // reference to point indices vector stored within octree leaf - const std::vector& leafIdx = leaf_arg.getPointIndicesVector(); + const auto& leafIdx = leaf_arg.getPointIndicesVector(); if (!do_voxel_grid_enDecoding_) { diff --git a/io/include/pcl/compression/point_coding.h b/io/include/pcl/compression/point_coding.h index a23a8678ab1..d10eb23c44c 100644 --- a/io/include/pcl/compression/point_coding.h +++ b/io/include/pcl/compression/point_coding.h @@ -126,7 +126,7 @@ class PointCoding * \param inputCloud_arg input point cloud */ void - encodePoints (const typename std::vector& indexVector_arg, const double* referencePoint_arg, + encodePoints (const Indices& indexVector_arg, const double* referencePoint_arg, PointCloudConstPtr inputCloud_arg) { std::size_t len = indexVector_arg.size (); diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index 4452f0ca04a..a3867aee2cd 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -90,14 +90,14 @@ class OctreeContainerBase { * indices. */ void - addPointIndex(const int&) + addPointIndex(const index_t&) {} /** \brief Empty getPointIndex implementation as this leaf node does not store any * point indices. */ void - getPointIndex(int&) const + getPointIndex(index_t&) const {} /** \brief Empty getPointIndices implementation as this leaf node does not store any @@ -148,7 +148,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Empty getPointIndex implementation as this leaf node does not store any * point indices. */ - int + index_t getPointIndex() const { assert("getPointIndex: undefined point index"); @@ -197,7 +197,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { * \param[in] data_arg index to be stored within leaf node. */ void - addPointIndex(int data_arg) + addPointIndex(index_t data_arg) { data_ = data_arg; } @@ -206,7 +206,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { * point index * \return index stored within container. */ - int + index_t getPointIndex() const { return data_; @@ -242,7 +242,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { protected: /** \brief Point index stored in octree. */ - int data_; + index_t data_; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -276,7 +276,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * \param[in] data_arg index to be stored within leaf node. */ void - addPointIndex(int data_arg) + addPointIndex(index_t data_arg) { leafDataTVector_.push_back(data_arg); } @@ -285,7 +285,7 @@ class OctreeContainerPointIndices : public OctreeContainerBase { * point indices. * \return index stored within container. */ - int + index_t getPointIndex() const { return leafDataTVector_.back(); From 730d376e0f3317a68a410be0b0e7527b312fd853 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sat, 19 Sep 2020 03:15:10 +0900 Subject: [PATCH 047/431] Get parts of code compiling --- .../pcl/octree/impl/octree2buf_base.hpp | 47 +++++++++--------- .../include/pcl/octree/impl/octree_base.hpp | 44 ++++++++--------- .../pcl/octree/impl/octree_iterator.hpp | 23 +++++---- .../pcl/octree/impl/octree_pointcloud.hpp | 4 +- .../impl/octree_pointcloud_adjacency.hpp | 22 +++------ .../impl/octree_pointcloud_voxelcentroid.hpp | 2 +- octree/include/pcl/octree/octree2buf_base.h | 42 ++++++++-------- octree/include/pcl/octree/octree_base.h | 44 ++++++++--------- octree/include/pcl/octree/octree_container.h | 14 +++--- octree/include/pcl/octree/octree_iterator.h | 49 +++++++++---------- octree/include/pcl/octree/octree_key.h | 10 ++-- octree/include/pcl/octree/octree_pointcloud.h | 2 +- octree/src/octree_inst.cpp | 4 +- 13 files changed, 147 insertions(+), 160 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree2buf_base.hpp b/octree/include/pcl/octree/impl/octree2buf_base.hpp index edaea812171..477233e8629 100644 --- a/octree/include/pcl/octree/impl/octree2buf_base.hpp +++ b/octree/include/pcl/octree/impl/octree2buf_base.hpp @@ -67,17 +67,17 @@ Octree2BufBase::~Octree2BufBase() template void Octree2BufBase::setMaxVoxelIndex( - unsigned int max_voxel_index_arg) + uindex_t max_voxel_index_arg) { - unsigned int treeDepth; + uindex_t treeDepth; assert(max_voxel_index_arg > 0); // tree depth == amount of bits of maxVoxels - treeDepth = std::max( - (std::min(static_cast(OctreeKey::maxDepth), - static_cast(std::ceil(std::log2(max_voxel_index_arg))))), - static_cast(0)); + treeDepth = + std::max(std::min(OctreeKey::maxDepth, + std::ceil(std::log2(max_voxel_index_arg))), + 0); // define depthMask_ by setting a single bit to 1 at bit position == tree depth depth_mask_ = (1 << (treeDepth - 1)); @@ -86,7 +86,7 @@ Octree2BufBase::setMaxVoxelIndex( ////////////////////////////////////////////////////////////////////////////////////////////// template void -Octree2BufBase::setTreeDepth(unsigned int depth_arg) +Octree2BufBase::setTreeDepth(uindex_t depth_arg) { assert(depth_arg > 0); @@ -103,9 +103,9 @@ Octree2BufBase::setTreeDepth(unsigned int dept ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -Octree2BufBase::findLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +Octree2BufBase::findLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -117,9 +117,9 @@ Octree2BufBase::findLeaf(unsigned int idx_x_ar ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -Octree2BufBase::createLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +Octree2BufBase::createLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -131,8 +131,9 @@ Octree2BufBase::createLeaf(unsigned int idx_x_ ////////////////////////////////////////////////////////////////////////////////////////////// template bool -Octree2BufBase::existLeaf( - unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg) const +Octree2BufBase::existLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) const { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -144,9 +145,9 @@ Octree2BufBase::existLeaf( ////////////////////////////////////////////////////////////////////////////////////////////// template void -Octree2BufBase::removeLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +Octree2BufBase::removeLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -352,10 +353,10 @@ Octree2BufBase::serializeNewLeafs( ////////////////////////////////////////////////////////////////////////////////////////////// template -unsigned int +uindex_t Octree2BufBase::createLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg, @@ -465,7 +466,7 @@ template void Octree2BufBase::findLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const { @@ -500,7 +501,7 @@ Octree2BufBase::findLeafRecursive( template bool Octree2BufBase::deleteLeafRecursive( - const OctreeKey& key_arg, unsigned int depth_mask_arg, BranchNode* branch_arg) + const OctreeKey& key_arg, uindex_t depth_mask_arg, BranchNode* branch_arg) { // index to branch child unsigned char child_idx; @@ -642,7 +643,7 @@ template void Octree2BufBase::deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binaryTreeIT_arg, typename std::vector::const_iterator& binaryTreeIT_End_arg, diff --git a/octree/include/pcl/octree/impl/octree_base.hpp b/octree/include/pcl/octree/impl/octree_base.hpp index 70ca1974d07..afd9d3c8e13 100644 --- a/octree/include/pcl/octree/impl/octree_base.hpp +++ b/octree/include/pcl/octree/impl/octree_base.hpp @@ -67,16 +67,16 @@ OctreeBase::~OctreeBase() template void OctreeBase::setMaxVoxelIndex( - unsigned int max_voxel_index_arg) + uindex_t max_voxel_index_arg) { - unsigned int tree_depth; + uindex_t tree_depth; assert(max_voxel_index_arg > 0); // tree depth == bitlength of maxVoxels tree_depth = - std::min(static_cast(OctreeKey::maxDepth), - static_cast(std::ceil(std::log2(max_voxel_index_arg)))); + std::min(static_cast(OctreeKey::maxDepth), + static_cast(std::ceil(std::log2(max_voxel_index_arg)))); // define depthMask_ by setting a single bit to 1 at bit position == tree depth depth_mask_ = (1 << (tree_depth - 1)); @@ -85,7 +85,7 @@ OctreeBase::setMaxVoxelIndex( ////////////////////////////////////////////////////////////////////////////////////////////// template void -OctreeBase::setTreeDepth(unsigned int depth_arg) +OctreeBase::setTreeDepth(uindex_t depth_arg) { assert(depth_arg > 0); @@ -102,9 +102,9 @@ OctreeBase::setTreeDepth(unsigned int depth_ar ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -OctreeBase::findLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +OctreeBase::findLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -116,9 +116,9 @@ OctreeBase::findLeaf(unsigned int idx_x_arg, ////////////////////////////////////////////////////////////////////////////////////////////// template LeafContainerT* -OctreeBase::createLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +OctreeBase::createLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -130,9 +130,9 @@ OctreeBase::createLeaf(unsigned int idx_x_arg, ////////////////////////////////////////////////////////////////////////////////////////////// template bool -OctreeBase::existLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) const +OctreeBase::existLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) const { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -144,9 +144,9 @@ OctreeBase::existLeaf(unsigned int idx_x_arg, ////////////////////////////////////////////////////////////////////////////////////////////// template void -OctreeBase::removeLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) +OctreeBase::removeLeaf(uindex_t idx_x_arg, + uindex_t idx_y_arg, + uindex_t idx_z_arg) { // generate key OctreeKey key(idx_x_arg, idx_y_arg, idx_z_arg); @@ -281,10 +281,10 @@ OctreeBase::deserializeTree( ////////////////////////////////////////////////////////////////////////////////////////////// template -unsigned int +uindex_t OctreeBase::createLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg) @@ -344,7 +344,7 @@ template void OctreeBase::findLeafRecursive( const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const { @@ -381,7 +381,7 @@ OctreeBase::findLeafRecursive( template bool OctreeBase::deleteLeafRecursive( - const OctreeKey& key_arg, unsigned int depth_mask_arg, BranchNode* branch_arg) + const OctreeKey& key_arg, uindex_t depth_mask_arg, BranchNode* branch_arg) { // index to branch child unsigned char child_idx; @@ -491,7 +491,7 @@ template void OctreeBase::deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binary_tree_input_it_arg, typename std::vector::const_iterator& binary_tree_input_it_end_arg, diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index 76e33fab632..bb0d7719e7a 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -45,7 +45,7 @@ namespace pcl { namespace octree { ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeDepthFirstIterator::OctreeDepthFirstIterator(unsigned int max_depth_arg) +OctreeDepthFirstIterator::OctreeDepthFirstIterator(uindex_t max_depth_arg) : OctreeIteratorBase(max_depth_arg), stack_() { // initialize iterator @@ -55,7 +55,7 @@ OctreeDepthFirstIterator::OctreeDepthFirstIterator(unsigned int max_dep ////////////////////////////////////////////////////////////////////////////////////////////// template OctreeDepthFirstIterator::OctreeDepthFirstIterator(OctreeT* octree_arg, - unsigned int max_depth_arg) + uindex_t max_depth_arg) : OctreeIteratorBase(octree_arg, max_depth_arg), stack_() { // initialize iterator @@ -163,8 +163,7 @@ OctreeDepthFirstIterator::operator++() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeBreadthFirstIterator::OctreeBreadthFirstIterator( - unsigned int max_depth_arg) +OctreeBreadthFirstIterator::OctreeBreadthFirstIterator(uindex_t max_depth_arg) : OctreeIteratorBase(max_depth_arg), FIFO_() { OctreeIteratorBase::reset(); @@ -175,8 +174,8 @@ OctreeBreadthFirstIterator::OctreeBreadthFirstIterator( ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeBreadthFirstIterator::OctreeBreadthFirstIterator( - OctreeT* octree_arg, unsigned int max_depth_arg) +OctreeBreadthFirstIterator::OctreeBreadthFirstIterator(OctreeT* octree_arg, + uindex_t max_depth_arg) : OctreeIteratorBase(octree_arg, max_depth_arg), FIFO_() { OctreeIteratorBase::reset(); @@ -264,8 +263,8 @@ OctreeFixedDepthIterator::OctreeFixedDepthIterator() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeFixedDepthIterator::OctreeFixedDepthIterator( - OctreeT* octree_arg, unsigned int fixed_depth_arg) +OctreeFixedDepthIterator::OctreeFixedDepthIterator(OctreeT* octree_arg, + uindex_t fixed_depth_arg) : OctreeBreadthFirstIterator(octree_arg, fixed_depth_arg) , fixed_depth_(fixed_depth_arg) { @@ -275,7 +274,7 @@ OctreeFixedDepthIterator::OctreeFixedDepthIterator( ////////////////////////////////////////////////////////////////////////////////////////////// template void -OctreeFixedDepthIterator::reset(unsigned int fixed_depth_arg) +OctreeFixedDepthIterator::reset(uindex_t fixed_depth_arg) { // Set the desired depth to walk through fixed_depth_ = fixed_depth_arg; @@ -315,7 +314,7 @@ OctreeFixedDepthIterator::reset(unsigned int fixed_depth_arg) ////////////////////////////////////////////////////////////////////////////////////////////// template OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( - unsigned int max_depth_arg) + uindex_t max_depth_arg) : OctreeBreadthFirstIterator(max_depth_arg) { reset(); @@ -324,7 +323,7 @@ OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( ////////////////////////////////////////////////////////////////////////////////////////////// template OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( - OctreeT* octree_arg, unsigned int max_depth_arg) + OctreeT* octree_arg, uindex_t max_depth_arg) : OctreeBreadthFirstIterator(octree_arg, max_depth_arg) { reset(); @@ -334,7 +333,7 @@ OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( template OctreeLeafNodeBreadthFirstIterator::OctreeLeafNodeBreadthFirstIterator( OctreeT* octree_arg, - unsigned int max_depth_arg, + uindex_t max_depth_arg, IteratorState* current_state, const std::deque& fifo) : OctreeBreadthFirstIterator(octree_arg, max_depth_arg, current_state, fifo) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index c467417f6dc..bf3e5a5dc75 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -265,7 +265,7 @@ template -int +pcl::index_t pcl::octree::OctreePointCloud:: getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, @@ -320,7 +320,7 @@ pcl::octree::OctreePointCloud voxel_center_list.push_back(center); } - return (static_cast(voxel_center_list.size())); + return (static_cast(voxel_center_list.size())); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index 0b1a00c6cec..3bcaf1ce147 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -127,12 +127,9 @@ pcl::octree::OctreePointCloudAdjacency if (pcl::isFinite(temp)) // Make sure transformed point is finite - if it is not, it // gets default key { - key_arg.x = - static_cast((temp.x - this->min_x_) / this->resolution_); - key_arg.y = - static_cast((temp.y - this->min_y_) / this->resolution_); - key_arg.z = - static_cast((temp.z - this->min_z_) / this->resolution_); + key_arg.x = static_cast((temp.x - this->min_x_) / this->resolution_); + key_arg.y = static_cast((temp.y - this->min_y_) / this->resolution_); + key_arg.z = static_cast((temp.z - this->min_z_) / this->resolution_); } else { key_arg = OctreeKey(); @@ -140,12 +137,9 @@ pcl::octree::OctreePointCloudAdjacency } else { // calculate integer key for point coordinates - key_arg.x = - static_cast((point_arg.x - this->min_x_) / this->resolution_); - key_arg.y = - static_cast((point_arg.y - this->min_y_) / this->resolution_); - key_arg.z = - static_cast((point_arg.z - this->min_z_) / this->resolution_); + key_arg.x = static_cast((point_arg.x - this->min_x_) / this->resolution_); + key_arg.y = static_cast((point_arg.y - this->min_y_) / this->resolution_); + key_arg.z = static_cast((point_arg.z - this->min_z_) / this->resolution_); } } @@ -294,13 +288,13 @@ pcl::octree::OctreePointCloudAdjacency direction.normalize(); float precision = 1.0f; const float step_size = static_cast(resolution_) * precision; - const int nsteps = std::max(1, static_cast(norm / step_size)); + const auto nsteps = std::max(1, norm / step_size); OctreeKey prev_key = key; // Walk along the line segment with small steps. Eigen::Vector3f p = leaf_centroid; PointT octree_p; - for (int i = 0; i < nsteps; ++i) { + for (uindex_t i = 0; i < nsteps; ++i) { // Start at the leaf voxel, and move back towards sensor. p += (direction * step_size); diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp index ed3f132f641..f5e6e889cd5 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_voxelcentroid.hpp @@ -70,7 +70,7 @@ pcl::octree::OctreePointCloudVoxelCentroid -std::size_t +pcl::uindex_t pcl::octree::OctreePointCloudVoxelCentroid:: getVoxelCentroids( typename OctreePointCloud:: diff --git a/octree/include/pcl/octree/octree2buf_base.h b/octree/include/pcl/octree/octree2buf_base.h index 632057d1664..84d735c3bea 100644 --- a/octree/include/pcl/octree/octree2buf_base.h +++ b/octree/include/pcl/octree/octree2buf_base.h @@ -212,7 +212,7 @@ class BufferedBranchNode : public OctreeNode { * \ingroup octree * \author Julius Kammerl (julius@kammerl.de) */ -template class Octree2BufBase { @@ -236,7 +236,7 @@ class Octree2BufBase { using Iterator = OctreeDepthFirstIterator; using ConstIterator = const OctreeDepthFirstIterator; Iterator - begin(unsigned int max_depth_arg = 0) + begin(uindex_t max_depth_arg = 0) { return Iterator(this, max_depth_arg); }; @@ -258,7 +258,7 @@ class Octree2BufBase { using ConstLeafNodeDepthFirstIterator = const OctreeLeafNodeDepthFirstIterator; LeafNodeDepthFirstIterator - leaf_depth_begin(unsigned int max_depth_arg = 0) + leaf_depth_begin(uindex_t max_depth_arg = 0) { return LeafNodeDepthFirstIterator(this, max_depth_arg); }; @@ -273,7 +273,7 @@ class Octree2BufBase { using DepthFirstIterator = OctreeDepthFirstIterator; using ConstDepthFirstIterator = const OctreeDepthFirstIterator; DepthFirstIterator - depth_begin(unsigned int maxDepth_arg = 0) + depth_begin(uindex_t maxDepth_arg = 0) { return DepthFirstIterator(this, maxDepth_arg); }; @@ -287,7 +287,7 @@ class Octree2BufBase { using BreadthFirstIterator = OctreeBreadthFirstIterator; using ConstBreadthFirstIterator = const OctreeBreadthFirstIterator; BreadthFirstIterator - breadth_begin(unsigned int max_depth_arg = 0) + breadth_begin(uindex_t max_depth_arg = 0) { return BreadthFirstIterator(this, max_depth_arg); }; @@ -303,7 +303,7 @@ class Octree2BufBase { const OctreeLeafNodeBreadthFirstIterator; LeafNodeBreadthIterator - leaf_breadth_begin(unsigned int max_depth_arg = 0u) + leaf_breadth_begin(uindex_t max_depth_arg = 0u) { return LeafNodeBreadthIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -354,18 +354,18 @@ class Octree2BufBase { * \param max_voxel_index_arg: maximum amount of voxels per dimension */ void - setMaxVoxelIndex(unsigned int max_voxel_index_arg); + setMaxVoxelIndex(uindex_t max_voxel_index_arg); /** \brief Set the maximum depth of the octree. * \param depth_arg: maximum depth of octree */ void - setTreeDepth(unsigned int depth_arg); + setTreeDepth(uindex_t depth_arg); /** \brief Get the maximum depth of the octree. * \return depth_arg: maximum depth of octree */ - inline unsigned int + inline uindex_t getTreeDepth() const { return this->octree_depth_; @@ -379,7 +379,7 @@ class Octree2BufBase { * \return pointer to new leaf node container. */ LeafContainerT* - createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + createLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \note If leaf node already exist, this method returns the existing node @@ -389,7 +389,7 @@ class Octree2BufBase { * \return pointer to leaf node container if found, null pointer otherwise. */ LeafContainerT* - findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + findLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Check for the existence of leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \param idx_x_arg: index of leaf node in the X axis. @@ -398,9 +398,7 @@ class Octree2BufBase { * \return "true" if leaf node search is successful, otherwise it returns "false". */ bool - existLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) const; + existLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg) const; /** \brief Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \param idx_x_arg: index of leaf node in the X axis. @@ -408,7 +406,7 @@ class Octree2BufBase { * \param idx_z_arg: index of leaf node in the Z axis. */ void - removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + removeLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Return the amount of existing leafs in the octree. * \return amount of registered leaf nodes. @@ -825,9 +823,9 @@ class Octree2BufBase { * \param branch_reset_arg: Reset pointer array of current branch * \return depth mask at which leaf node was created/found **/ - unsigned int + uindex_t createLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg, @@ -843,7 +841,7 @@ class Octree2BufBase { **/ void findLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const; @@ -857,7 +855,7 @@ class Octree2BufBase { **/ bool deleteLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg); /** \brief Recursively explore the octree and output binary octree description @@ -901,7 +899,7 @@ class Octree2BufBase { void deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binary_tree_in_it_arg, typename std::vector::const_iterator& binary_tree_in_it_end_arg, @@ -978,7 +976,7 @@ class Octree2BufBase { BranchNode* root_node_; /** \brief Depth mask based on octree depth **/ - unsigned int depth_mask_; + uindex_t depth_mask_; /** \brief key range */ OctreeKey max_key_; @@ -990,7 +988,7 @@ class Octree2BufBase { bool tree_dirty_flag_; /** \brief Octree depth */ - unsigned int octree_depth_; + uindex_t octree_depth_; /** \brief Enable dynamic_depth * \note Note that this parameter is ignored in octree2buf! */ diff --git a/octree/include/pcl/octree/octree_base.h b/octree/include/pcl/octree/octree_base.h index c95b0be55f2..5201f64d4d6 100644 --- a/octree/include/pcl/octree/octree_base.h +++ b/octree/include/pcl/octree/octree_base.h @@ -57,7 +57,7 @@ namespace octree { * \ingroup octree * \author Julius Kammerl (julius@kammerl.de) */ -template class OctreeBase { public: @@ -84,10 +84,10 @@ class OctreeBase { BranchNode* root_node_; /** \brief Depth mask based on octree depth **/ - unsigned int depth_mask_; + uindex_t depth_mask_; /** \brief Octree depth */ - unsigned int octree_depth_; + uindex_t octree_depth_; /** \brief Enable dynamic_depth **/ bool dynamic_depth_enabled_; @@ -109,7 +109,7 @@ class OctreeBase { using ConstIterator = const OctreeDepthFirstIterator; Iterator - begin(unsigned int max_depth_arg = 0u) + begin(uindex_t max_depth_arg = 0u) { return Iterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); }; @@ -133,7 +133,7 @@ class OctreeBase { const OctreeLeafNodeDepthFirstIterator; LeafNodeDepthFirstIterator - leaf_depth_begin(unsigned int max_depth_arg = 0u) + leaf_depth_begin(uindex_t max_depth_arg = 0u) { return LeafNodeDepthFirstIterator( this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -150,7 +150,7 @@ class OctreeBase { using ConstDepthFirstIterator = const OctreeDepthFirstIterator; DepthFirstIterator - depth_begin(unsigned int max_depth_arg = 0u) + depth_begin(uindex_t max_depth_arg = 0u) { return DepthFirstIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -167,7 +167,7 @@ class OctreeBase { using ConstBreadthFirstIterator = const OctreeBreadthFirstIterator; BreadthFirstIterator - breadth_begin(unsigned int max_depth_arg = 0u) + breadth_begin(uindex_t max_depth_arg = 0u) { return BreadthFirstIterator(this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -184,7 +184,7 @@ class OctreeBase { using ConstFixedDepthIterator = const OctreeFixedDepthIterator; FixedDepthIterator - fixed_depth_begin(unsigned int fixed_depth_arg = 0u) + fixed_depth_begin(uindex_t fixed_depth_arg = 0u) { return FixedDepthIterator(this, fixed_depth_arg); }; @@ -201,7 +201,7 @@ class OctreeBase { const OctreeLeafNodeBreadthFirstIterator; LeafNodeBreadthFirstIterator - leaf_breadth_begin(unsigned int max_depth_arg = 0u) + leaf_breadth_begin(uindex_t max_depth_arg = 0u) { return LeafNodeBreadthFirstIterator( this, max_depth_arg ? max_depth_arg : this->octree_depth_); @@ -249,18 +249,18 @@ class OctreeBase { * \param[in] max_voxel_index_arg maximum amount of voxels per dimension */ void - setMaxVoxelIndex(unsigned int max_voxel_index_arg); + setMaxVoxelIndex(uindex_t max_voxel_index_arg); /** \brief Set the maximum depth of the octree. * \param max_depth_arg: maximum depth of octree */ void - setTreeDepth(unsigned int max_depth_arg); + setTreeDepth(uindex_t max_depth_arg); /** \brief Get the maximum depth of the octree. * \return depth_arg: maximum depth of octree */ - unsigned int + uindex_t getTreeDepth() const { return this->octree_depth_; @@ -274,7 +274,7 @@ class OctreeBase { * \return pointer to new leaf node container. */ LeafContainerT* - createLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + createLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Find leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \note If leaf node already exist, this method returns the existing node @@ -284,7 +284,7 @@ class OctreeBase { * \return pointer to leaf node container if found, null pointer otherwise. */ LeafContainerT* - findLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + findLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief idx_x_arg for the existence of leaf node at (idx_x_arg, idx_y_arg, * idx_z_arg). @@ -294,9 +294,7 @@ class OctreeBase { * \return "true" if leaf node search is successful, otherwise it returns "false". */ bool - existLeaf(unsigned int idx_x_arg, - unsigned int idx_y_arg, - unsigned int idx_z_arg) const; + existLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg) const; /** \brief Remove leaf node at (idx_x_arg, idx_y_arg, idx_z_arg). * \param idx_x_arg: index of leaf node in the X axis. @@ -304,7 +302,7 @@ class OctreeBase { * \param idx_z_arg: index of leaf node in the Z axis. */ void - removeLeaf(unsigned int idx_x_arg, unsigned int idx_y_arg, unsigned int idx_z_arg); + removeLeaf(uindex_t idx_x_arg, uindex_t idx_y_arg, uindex_t idx_z_arg); /** \brief Return the amount of existing leafs in the octree. * \return amount of registered leaf nodes. @@ -580,9 +578,9 @@ class OctreeBase { * \param parent_of_leaf_arg: return pointer to parent of leaf node * \return depth mask at which leaf node was created **/ - unsigned int + uindex_t createLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafNode*& return_leaf_arg, BranchNode*& parent_of_leaf_arg); @@ -597,7 +595,7 @@ class OctreeBase { **/ void findLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg, LeafContainerT*& result_arg) const; @@ -611,7 +609,7 @@ class OctreeBase { **/ bool deleteLeafRecursive(const OctreeKey& key_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, BranchNode* branch_arg); /** \brief Recursively explore the octree and output binary octree description @@ -644,7 +642,7 @@ class OctreeBase { void deserializeTreeRecursive( BranchNode* branch_arg, - unsigned int depth_mask_arg, + uindex_t depth_mask_arg, OctreeKey& key_arg, typename std::vector::const_iterator& binary_tree_input_it_arg, typename std::vector::const_iterator& binary_tree_input_it_end_arg, diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index a3867aee2cd..fe3074e9e56 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -127,7 +127,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Abstract get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - std::size_t + index_t getSize() const override { return 0; @@ -220,24 +220,24 @@ class OctreeContainerPointIndex : public OctreeContainerBase { void getPointIndices(Indices& data_vector_arg) const { - if (data_ >= 0) + if (data_ != static_cast(-1)) data_vector_arg.push_back(data_); } /** \brief Get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - std::size_t + index_t getSize() const override { - return data_ < 0 ? 0 : 1; + return data_ != static_cast(-1) ? 0 : 1; } /** \brief Reset leaf node memory to zero. */ void reset() override { - data_ = -1; + data_ = static_cast(-1); } protected: @@ -316,10 +316,10 @@ class OctreeContainerPointIndices : public OctreeContainerBase { /** \brief Get size of container (number of indices) * \return number of point indices in container. */ - std::size_t + index_t getSize() const override { - return leafDataTVector_.size(); + return static_cast(leafDataTVector_.size()); } /** \brief Reset leaf node. Clear DataT vector.*/ diff --git a/octree/include/pcl/octree/octree_iterator.h b/octree/include/pcl/octree/octree_iterator.h index 2156b3274ca..ae0fbd4c1bd 100644 --- a/octree/include/pcl/octree/octree_iterator.h +++ b/octree/include/pcl/octree/octree_iterator.h @@ -59,7 +59,7 @@ namespace octree { struct IteratorState { OctreeNode* node_; OctreeKey key_; - unsigned int depth_; + uindex_t depth_; }; /** \brief @b Abstract octree iterator class @@ -82,7 +82,7 @@ class OctreeIteratorBase : public std::iteratorreset(); @@ -93,7 +93,7 @@ class OctreeIteratorBase : public std::iteratorreset(); @@ -108,7 +108,7 @@ class OctreeIteratorBase : public std::iteratorgetTreeDepth(); + uindex_t depth = octree_->getTreeDepth(); id = static_cast(key.x) << (depth * 2) | static_cast(key.y) << (depth * 1) | static_cast(key.z) << (depth * 0); @@ -344,7 +344,7 @@ class OctreeIteratorBase : public std::iterator { /** \brief Empty constructor. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeDepthFirstIterator(unsigned int max_depth_arg = 0); + explicit OctreeDepthFirstIterator(uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its * root node. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeDepthFirstIterator(OctreeT* octree_arg, - unsigned int max_depth_arg = 0); + explicit OctreeDepthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its @@ -384,7 +383,7 @@ class OctreeDepthFirstIterator : public OctreeIteratorBase { */ explicit OctreeDepthFirstIterator( OctreeT* octree_arg, - unsigned int max_depth_arg, + uindex_t max_depth_arg, IteratorState* current_state, const std::vector& stack = std::vector()) : OctreeIteratorBase(octree_arg, max_depth_arg, current_state), stack_(stack) @@ -469,15 +468,14 @@ class OctreeBreadthFirstIterator : public OctreeIteratorBase { /** \brief Empty constructor. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeBreadthFirstIterator(unsigned int max_depth_arg = 0); + explicit OctreeBreadthFirstIterator(uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its * root node. * \param[in] max_depth_arg Depth limitation during traversal */ - explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, - unsigned int max_depth_arg = 0); + explicit OctreeBreadthFirstIterator(OctreeT* octree_arg, uindex_t max_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its @@ -489,7 +487,7 @@ class OctreeBreadthFirstIterator : public OctreeIteratorBase { */ explicit OctreeBreadthFirstIterator( OctreeT* octree_arg, - unsigned int max_depth_arg, + uindex_t max_depth_arg, IteratorState* current_state, const std::deque& fifo = std::deque()) : OctreeIteratorBase(octree_arg, max_depth_arg, current_state), FIFO_(fifo) @@ -575,8 +573,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { * root node. * \param[in] fixed_depth_arg Depth level during traversal */ - explicit OctreeFixedDepthIterator(OctreeT* octree_arg, - unsigned int fixed_depth_arg = 0); + explicit OctreeFixedDepthIterator(OctreeT* octree_arg, uindex_t fixed_depth_arg = 0); /** \brief Constructor. * \param[in] octree_arg Octree to be iterated. Initially the iterator is set to its @@ -589,7 +586,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { */ OctreeFixedDepthIterator( OctreeT* octree_arg, - unsigned int fixed_depth_arg, + uindex_t fixed_depth_arg, IteratorState* current_state, const std::deque& fifo = std::deque()) : OctreeBreadthFirstIterator( @@ -623,7 +620,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { * \param[in] fixed_depth_arg Depth level during traversal */ void - reset(unsigned int fixed_depth_arg); + reset(uindex_t fixed_depth_arg); /** \brief Reset the iterator to the first node at the current depth */ @@ -637,7 +634,7 @@ class OctreeFixedDepthIterator : public OctreeBreadthFirstIterator { using OctreeBreadthFirstIterator::FIFO_; /** \brief Given level of the node to be iterated */ - unsigned int fixed_depth_; + uindex_t fixed_depth_; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -657,7 +654,7 @@ class OctreeLeafNodeDepthFirstIterator : public OctreeDepthFirstIterator(max_depth_arg) { reset(); @@ -669,7 +666,7 @@ class OctreeLeafNodeDepthFirstIterator : public OctreeDepthFirstIterator(octree_arg, max_depth_arg) { reset(); @@ -685,7 +682,7 @@ class OctreeLeafNodeDepthFirstIterator : public OctreeDepthFirstIterator& stack = std::vector()) : OctreeDepthFirstIterator(octree_arg, max_depth_arg, current_state, stack) @@ -759,7 +756,7 @@ class OctreeLeafNodeBreadthFirstIterator : public OctreeBreadthFirstIterator& fifo = std::deque()); diff --git a/octree/include/pcl/octree/octree_key.h b/octree/include/pcl/octree/octree_key.h index a103d5a31db..508f29ad7a7 100644 --- a/octree/include/pcl/octree/octree_key.h +++ b/octree/include/pcl/octree/octree_key.h @@ -140,17 +140,17 @@ class OctreeKey { /* \brief maximum depth that can be addressed */ static const unsigned char maxDepth = - static_cast(sizeof(std::uint32_t) * 8); + static_cast(sizeof(uindex_t) * 8); // Indices addressing a voxel at (X, Y, Z) union { struct { - std::uint32_t x; - std::uint32_t y; - std::uint32_t z; + uindex_t x; + uindex_t y; + uindex_t z; }; - std::uint32_t key_[3]; + uindex_t key_[3]; }; }; } // namespace octree diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 8d7fabc7beb..aad4f2cfd82 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -279,7 +279,7 @@ class OctreePointCloud : public OctreeT { * octree_resolution x precision * \return number of intersected voxels */ - int + index_t getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, AlignedPointTVector& voxel_center_list, diff --git a/octree/src/octree_inst.cpp b/octree/src/octree_inst.cpp index e0d266508ab..2f149f0b487 100644 --- a/octree/src/octree_inst.cpp +++ b/octree/src/octree_inst.cpp @@ -39,8 +39,8 @@ // Instantiations of specific point types -template class PCL_EXPORTS pcl::octree::OctreeBase; -template class PCL_EXPORTS pcl::octree::Octree2BufBase; +template class PCL_EXPORTS pcl::octree::OctreeBase; +template class PCL_EXPORTS pcl::octree::Octree2BufBase; template class PCL_EXPORTS pcl::octree::OctreeBase Date: Sat, 19 Sep 2020 21:45:07 +0900 Subject: [PATCH 048/431] Trying to make octree tests pass compile --- .../octree_pointcloud_compression.h | 2 +- kdtree/include/pcl/kdtree/impl/io.hpp | 8 ++-- .../include/pcl/kdtree/impl/kdtree_flann.hpp | 16 ++++---- kdtree/include/pcl/kdtree/io.h | 4 +- kdtree/include/pcl/kdtree/kdtree.h | 20 +++++----- kdtree/include/pcl/kdtree/kdtree_flann.h | 12 +++--- .../pcl/octree/impl/octree_iterator.hpp | 3 +- octree/include/pcl/octree/octree_container.h | 2 +- octree/include/pcl/octree/octree_iterator.h | 18 +++++++-- octree/include/pcl/octree/octree_pointcloud.h | 4 +- .../octree_pointcloud_adjacency_container.h | 2 +- test/octree/test_octree.cpp | 38 +++++++++---------- 12 files changed, 70 insertions(+), 59 deletions(-) diff --git a/io/include/pcl/compression/octree_pointcloud_compression.h b/io/include/pcl/compression/octree_pointcloud_compression.h index d251d35e7b6..4a742179d91 100644 --- a/io/include/pcl/compression/octree_pointcloud_compression.h +++ b/io/include/pcl/compression/octree_pointcloud_compression.h @@ -158,7 +158,7 @@ namespace pcl * \param[in] pointIdx_arg the index representing the point in the dataset given by \a setInputCloud to be added */ void - addPointIdx (const int pointIdx_arg) override + addPointIdx (const index_t pointIdx_arg) override { ++object_count_; OctreePointCloud::addPointIdx(pointIdx_arg); diff --git a/kdtree/include/pcl/kdtree/impl/io.hpp b/kdtree/include/pcl/kdtree/impl/io.hpp index 4e577beeb59..921b42bb3c7 100644 --- a/kdtree/include/pcl/kdtree/impl/io.hpp +++ b/kdtree/include/pcl/kdtree/impl/io.hpp @@ -47,12 +47,12 @@ template void pcl::getApproximateIndices ( const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices) + Indices &indices) { pcl::KdTreeFLANN tree; tree.setInputCloud (cloud_ref); - std::vector nn_idx (1); + Indices nn_idx (1); std::vector nn_dists (1); indices.resize (cloud_in->size ()); for (std::size_t i = 0; i < cloud_in->size (); ++i) @@ -67,12 +67,12 @@ template void pcl::getApproximateIndices ( const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices) + Indices &indices) { pcl::KdTreeFLANN tree; tree.setInputCloud (cloud_ref); - std::vector nn_idx (1); + Indices nn_idx (1); std::vector nn_dists (1); indices.resize (cloud_in->size ()); for (std::size_t i = 0; i < cloud_in->size (); ++i) diff --git a/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp b/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp index 8d5959e7da7..923764f0631 100644 --- a/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp +++ b/kdtree/include/pcl/kdtree/impl/kdtree_flann.hpp @@ -128,9 +128,9 @@ pcl::KdTreeFLANN::setInputCloud (const PointCloudConstPtr &cloud, } /////////////////////////////////////////////////////////////////////////////////////////// -template int +template int pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned int k, - std::vector &k_indices, + Indices &k_indices, std::vector &k_distances) const { assert (point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!"); @@ -147,7 +147,7 @@ pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned in std::vector query (dim_); point_representation_->vectorize (static_cast (point), query); - ::flann::Matrix k_indices_mat (&k_indices[0], 1, k); + ::flann::Matrix k_indices_mat (&k_indices[0], 1, k); ::flann::Matrix k_distances_mat (&k_distances[0], 1, k); // Wrap the k_indices and k_distances vectors (no data copy) flann_index_->knnSearch (::flann::Matrix (&query[0], 1, dim_), @@ -159,7 +159,7 @@ pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned in { for (std::size_t i = 0; i < static_cast (k); ++i) { - int& neighbor_index = k_indices[i]; + auto& neighbor_index = k_indices[i]; neighbor_index = index_mapping_[neighbor_index]; } } @@ -169,7 +169,7 @@ pcl::KdTreeFLANN::nearestKSearch (const PointT &point, unsigned in /////////////////////////////////////////////////////////////////////////////////////////// template int -pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius, std::vector &k_indices, +pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius, Indices &k_indices, std::vector &k_sqr_dists, unsigned int max_nn) const { assert (point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to radiusSearch!"); @@ -181,7 +181,7 @@ pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius if (max_nn == 0 || max_nn > total_nr_points_) max_nn = total_nr_points_; - std::vector > indices(1); + std::vector indices(1); std::vector > dists(1); ::flann::SearchParams params (param_radius_); @@ -204,7 +204,7 @@ pcl::KdTreeFLANN::radiusSearch (const PointT &point, double radius { for (int i = 0; i < neighbors_in_radius; ++i) { - int& neighbor_index = k_indices[i]; + auto& neighbor_index = k_indices[i]; neighbor_index = index_mapping_[neighbor_index]; } } @@ -259,7 +259,7 @@ pcl::KdTreeFLANN::convertCloudToArray (const PointCloud &cloud) /////////////////////////////////////////////////////////////////////////////////////////// template void -pcl::KdTreeFLANN::convertCloudToArray (const PointCloud &cloud, const std::vector &indices) +pcl::KdTreeFLANN::convertCloudToArray (const PointCloud &cloud, const Indices &indices) { // No point in doing anything if the array is empty if (cloud.empty ()) diff --git a/kdtree/include/pcl/kdtree/io.h b/kdtree/include/pcl/kdtree/io.h index a3ebb21f808..071340dcca6 100644 --- a/kdtree/include/pcl/kdtree/io.h +++ b/kdtree/include/pcl/kdtree/io.h @@ -55,7 +55,7 @@ namespace pcl template void getApproximateIndices (const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices); + Indices &indices); /** \brief Get a set of approximate indices for a given point cloud into a reference point cloud. * The coordinates of the two point clouds can differ. The method uses an internal KdTree for @@ -69,7 +69,7 @@ namespace pcl template void getApproximateIndices (const typename pcl::PointCloud::ConstPtr &cloud_in, const typename pcl::PointCloud::ConstPtr &cloud_ref, - std::vector &indices); + Indices &indices); } #include diff --git a/kdtree/include/pcl/kdtree/kdtree.h b/kdtree/include/pcl/kdtree/kdtree.h index 5d5e5034f21..82baf32a49c 100644 --- a/kdtree/include/pcl/kdtree/kdtree.h +++ b/kdtree/include/pcl/kdtree/kdtree.h @@ -54,8 +54,8 @@ namespace pcl class KdTree { public: - using IndicesPtr = shared_ptr >; - using IndicesConstPtr = shared_ptr >; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using PointCloud = pcl::PointCloud; using PointCloudPtr = typename PointCloud::Ptr; @@ -133,7 +133,7 @@ namespace pcl */ virtual int nearestKSearch (const PointT &p_q, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const = 0; + Indices &k_indices, std::vector &k_sqr_distances) const = 0; /** \brief Search for k-nearest neighbors for the given query point. * @@ -153,7 +153,7 @@ namespace pcl */ virtual int nearestKSearch (const PointCloud &cloud, int index, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const + Indices &k_indices, std::vector &k_sqr_distances) const { assert (index >= 0 && index < static_cast (cloud.size ()) && "Out-of-bounds error in nearestKSearch!"); return (nearestKSearch (cloud[index], k, k_indices, k_sqr_distances)); @@ -170,7 +170,7 @@ namespace pcl */ template inline int nearestKSearchT (const PointTDiff &point, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const + Indices &k_indices, std::vector &k_sqr_distances) const { PointT p; copyPoint (point, p); @@ -196,7 +196,7 @@ namespace pcl */ virtual int nearestKSearch (int index, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const + Indices &k_indices, std::vector &k_sqr_distances) const { if (indices_ == nullptr) { @@ -219,7 +219,7 @@ namespace pcl * \return number of neighbors found in radius */ virtual int - radiusSearch (const PointT &p_q, double radius, std::vector &k_indices, + radiusSearch (const PointT &p_q, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const = 0; /** \brief Search for all the nearest neighbors of the query point in a given radius. @@ -241,7 +241,7 @@ namespace pcl */ virtual int radiusSearch (const PointCloud &cloud, int index, double radius, - std::vector &k_indices, std::vector &k_sqr_distances, + Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const { assert (index >= 0 && index < static_cast (cloud.size ()) && "Out-of-bounds error in radiusSearch!"); @@ -259,7 +259,7 @@ namespace pcl * \return number of neighbors found in radius */ template inline int - radiusSearchT (const PointTDiff &point, double radius, std::vector &k_indices, + radiusSearchT (const PointTDiff &point, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const { PointT p; @@ -287,7 +287,7 @@ namespace pcl * \exception asserts in debug mode if the index is not between 0 and the maximum number of points */ virtual int - radiusSearch (int index, double radius, std::vector &k_indices, + radiusSearch (int index, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const { if (indices_ == nullptr) diff --git a/kdtree/include/pcl/kdtree/kdtree_flann.h b/kdtree/include/pcl/kdtree/kdtree_flann.h index bf053ac0b65..50e2190a637 100644 --- a/kdtree/include/pcl/kdtree/kdtree_flann.h +++ b/kdtree/include/pcl/kdtree/kdtree_flann.h @@ -75,8 +75,8 @@ namespace pcl using PointCloud = typename KdTree::PointCloud; using PointCloudConstPtr = typename KdTree::PointCloudConstPtr; - using IndicesPtr = shared_ptr >; - using IndicesConstPtr = shared_ptr >; + using IndicesPtr = shared_ptr; + using IndicesConstPtr = shared_ptr; using FLANNIndex = ::flann::Index; @@ -154,9 +154,9 @@ namespace pcl * * \exception asserts in debug mode if the index is not between 0 and the maximum number of points */ - int + int nearestKSearch (const PointT &point, unsigned int k, - std::vector &k_indices, std::vector &k_sqr_distances) const override; + Indices &k_indices, std::vector &k_sqr_distances) const override; /** \brief Search for all the nearest neighbors of the query point in a given radius. * @@ -175,7 +175,7 @@ namespace pcl * \exception asserts in debug mode if the index is not between 0 and the maximum number of points */ int - radiusSearch (const PointT &point, double radius, std::vector &k_indices, + radiusSearch (const PointT &point, double radius, Indices &k_indices, std::vector &k_sqr_distances, unsigned int max_nn = 0) const override; private: @@ -196,7 +196,7 @@ namespace pcl * \param[in] indices the point cloud indices */ void - convertCloudToArray (const PointCloud &cloud, const std::vector &indices); + convertCloudToArray (const PointCloud &cloud, const Indices &indices); private: /** \brief Class getName method. */ diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index bb0d7719e7a..6a394ab1545 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -257,8 +257,7 @@ OctreeBreadthFirstIterator::operator++() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeFixedDepthIterator::OctreeFixedDepthIterator() -: OctreeBreadthFirstIterator(0u), fixed_depth_(0u) +OctreeFixedDepthIterator::OctreeFixedDepthIterator() : fixed_depth_(0u) {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index fe3074e9e56..d860f016c1c 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -76,7 +76,7 @@ class OctreeContainerBase { /** \brief Pure abstract method to get size of container (number of indices) * \return number of points/indices stored in leaf node container. */ - virtual std::size_t + virtual index_t getSize() const { return 0u; diff --git a/octree/include/pcl/octree/octree_iterator.h b/octree/include/pcl/octree/octree_iterator.h index ae0fbd4c1bd..2c1a848d33f 100644 --- a/octree/include/pcl/octree/octree_iterator.h +++ b/octree/include/pcl/octree/octree_iterator.h @@ -82,8 +82,13 @@ class OctreeIteratorBase : public std::iteratorreset(); } @@ -93,7 +98,14 @@ class OctreeIteratorBase : public std::iteratorreset(); diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index aad4f2cfd82..66afc625c41 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -183,7 +183,7 @@ class OctreePointCloud : public OctreeT { /** \brief Get the maximum depth of the octree. * \return depth_arg: maximum depth of octree * */ - inline unsigned int + inline uindex_t getTreeDepth() const { return this->octree_depth_; @@ -440,7 +440,7 @@ class OctreePointCloud : public OctreeT { expandLeafNode(LeafNode* leaf_node, BranchNode* parent_branch, unsigned char child_idx, - unsigned int depth_mask); + uindex_t depth_mask); /** \brief Get point at index from input pointcloud dataset * \param[in] index_arg index representing the point in the dataset given by \a diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index f79f53e0d81..18a0414d657 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -119,7 +119,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { /** \brief virtual method to get size of container * \return number of points added to leaf node container. */ - std::size_t + index_t getSize() const override { return num_points_; diff --git a/test/octree/test_octree.cpp b/test/octree/test_octree.cpp index 7e24a46f18b..b2c7e579a93 100644 --- a/test/octree/test_octree.cpp +++ b/test/octree/test_octree.cpp @@ -308,7 +308,7 @@ TEST (PCL, Octree_Dynamic_Depth_Test) // test iterator unsigned int leaf_count = 0; - std::vector indexVector; + Indices indexVector; // iterate over tree for (auto it = octree.leaf_depth_begin(), it_end = octree.leaf_depth_end(); it != it_end; ++it) @@ -329,13 +329,13 @@ TEST (PCL, Octree_Dynamic_Depth_Test) container.getPointIndices (indexVector); // test points against bounding box of leaf node - std::vector tmpVector; + Indices tmpVector; container.getPointIndices (tmpVector); Eigen::Vector3f min_pt, max_pt; octree.getVoxelBounds (it, min_pt, max_pt); - for (const int &i : tmpVector) + for (const auto &i : tmpVector) { ASSERT_GE ((*cloud)[i].x, min_pt(0)); ASSERT_GE ((*cloud)[i].y, min_pt(1)); @@ -477,7 +477,7 @@ TEST (PCL, Octree2Buf_Test) leafVectorA.pop_back (); bool bFound = false; - for (const int &value : data) + for (const auto &value : data) if (value == leafInt) { bFound = true; @@ -496,7 +496,7 @@ TEST (PCL, Octree2Buf_Test) leafVectorA.pop_back (); bool bFound = false; - for (const int &value : data) + for (const auto &value : data) if (value == leafInt) { bFound = true; @@ -790,12 +790,12 @@ TEST (PCL, Octree_Pointcloud_Test) for (std::size_t i = 0; i < cloudB->size (); i++) { - std::vector pointIdxVec; + Indices pointIdxVec; octreeB.voxelSearch ((*cloudB)[i], pointIdxVec); bool bIdxFound = false; - std::vector::const_iterator current = pointIdxVec.begin (); - while (current != pointIdxVec.end ()) + auto current = pointIdxVec.cbegin (); + while (current != pointIdxVec.cend ()) { if (*current == static_cast (i)) { @@ -869,7 +869,7 @@ TEST (PCL, Octree_Pointcloud_Iterator_Test) octreeA.setInputCloud (cloudIn); octreeA.addPointsFromInputCloud (); - std::vector indexVector; + Indices indexVector; unsigned int leafNodeCounter = 0; for (auto it1 = octreeA.leaf_depth_begin(), it1_end = octreeA.leaf_depth_end(); it1 != it1_end; ++it1) @@ -1007,7 +1007,7 @@ TEST (PCL, Octree_Pointcloud_Change_Detector_Test) cloudIn); } - std::vector newPointIdxVector; + Indices newPointIdxVector; // get a vector of new points, which did not exist in previous buffer octree.getPointIndicesFromNewVoxels (newPointIdxVector); @@ -1136,10 +1136,10 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search) OctreePointCloudSearch octree (0.1); octree.setInputCloud (cloudIn); - std::vector k_indices; + Indices k_indices; std::vector k_sqr_distances; - std::vector k_indices_bruteforce; + Indices k_indices_bruteforce; std::vector k_sqr_distances_bruteforce; for (unsigned int test_id = 0; test_id < test_runs; test_id++) @@ -1235,7 +1235,7 @@ TEST (PCL, Octree_Pointcloud_Box_Search) for (unsigned int test_id = 0; test_id < test_runs; test_id++) { - std::vector k_indices; + Indices k_indices; // generate point cloud cloudIn->width = 300; @@ -1341,7 +1341,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) } - int ANNindex; + index_t ANNindex; float ANNdistance; // octree approx. nearest neighbor search @@ -1415,7 +1415,7 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) } } - std::vector cloudNWRSearch; + Indices cloudNWRSearch; std::vector cloudNWRRadius; // execute octree radius search @@ -1424,8 +1424,8 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) ASSERT_EQ (cloudSearchBruteforce.size (), cloudNWRRadius.size ()); // check if result from octree radius search can be also found in bruteforce search - std::vector::const_iterator current = cloudNWRSearch.begin (); - while (current != cloudNWRSearch.end ()) + auto current = cloudNWRSearch.cbegin (); + while (current != cloudNWRSearch.cend ()) { pointDist = sqrt ( ((*cloudIn)[*current].x - searchPoint.x) * ((*cloudIn)[*current].x - searchPoint.x) @@ -1459,7 +1459,7 @@ TEST (PCL, Octree_Pointcloud_Ray_Traversal) pcl::PointCloud::VectorType voxelsInRay, voxelsInRay2; // Indices in ray - std::vector indicesInRay, indicesInRay2; + Indices indicesInRay, indicesInRay2; srand (static_cast (time (nullptr))); @@ -1620,7 +1620,7 @@ TEST (PCL, Octree_Pointcloud_Bounds) const double LARGE_MAX = 1e7-5*SOME_RESOLUTION; tree.defineBoundingBox (LARGE_MIN, LARGE_MIN, LARGE_MIN, LARGE_MAX, LARGE_MAX, LARGE_MAX); tree.getBoundingBox (min_x, min_y, min_z, max_x, max_y, max_z); - const unsigned int depth = tree.getTreeDepth (); + const auto depth = tree.getTreeDepth (); tree.defineBoundingBox (min_x, min_y, min_z, max_x, max_y, max_z); ASSERT_EQ (depth, tree.getTreeDepth ()); From 36162eb1a3fb39ebe8d87955d3b7b623de035847 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sat, 19 Sep 2020 22:25:41 +0900 Subject: [PATCH 049/431] octree_pointcloud left --- octree/include/pcl/octree/impl/octree_pointcloud.hpp | 2 +- octree/include/pcl/octree/octree_container.h | 4 +--- octree/include/pcl/octree/octree_key.h | 6 ++---- .../pcl/octree/octree_pointcloud_adjacency_container.h | 4 ++-- .../include/pcl/octree/octree_pointcloud_changedetector.h | 4 ++-- octree/include/pcl/octree/octree_pointcloud_density.h | 4 ++-- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index bf3e5a5dc75..22f5b909390 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -605,7 +605,7 @@ pcl::octree::OctreePointCloud expandLeafNode(LeafNode* leaf_node, BranchNode* parent_branch, unsigned char child_idx, - unsigned int depth_mask) + uindex_t depth_mask) { if (depth_mask) { diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index d860f016c1c..049ca9855c2 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -141,9 +141,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Empty addPointIndex implementation. This leaf node does not store any point * indices. */ - void - addPointIndex(int) - {} + void addPointIndex(index_t) {} /** \brief Empty getPointIndex implementation as this leaf node does not store any * point indices. diff --git a/octree/include/pcl/octree/octree_key.h b/octree/include/pcl/octree/octree_key.h index 508f29ad7a7..4e676221140 100644 --- a/octree/include/pcl/octree/octree_key.h +++ b/octree/include/pcl/octree/octree_key.h @@ -55,9 +55,7 @@ class OctreeKey { OctreeKey() : x(0), y(0), z(0) {} /** \brief Constructor for key initialization. */ - OctreeKey(unsigned int keyX, unsigned int keyY, unsigned int keyZ) - : x(keyX), y(keyY), z(keyZ) - {} + OctreeKey(uindex_t keyX, uindex_t keyY, uindex_t keyZ) : x(keyX), y(keyY), z(keyZ) {} /** \brief Copy constructor. */ OctreeKey(const OctreeKey& source) { std::memcpy(key_, source.key_, sizeof(key_)); } @@ -131,7 +129,7 @@ class OctreeKey { * \return child node index * */ inline unsigned char - getChildIdxWithDepthMask(unsigned int depthMask) const + getChildIdxWithDepthMask(uindex_t depthMask) const { return static_cast(((!!(this->x & depthMask)) << 2) | ((!!(this->y & depthMask)) << 1) | diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index 18a0414d657..a5bc2a2a25b 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -94,7 +94,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { } /** \brief Gets the number of points contributing to this leaf */ - int + uindex_t getPointCounter() const { return num_points_; @@ -122,7 +122,7 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { index_t getSize() const override { - return num_points_; + return static_cast(num_points_); } protected: diff --git a/octree/include/pcl/octree/octree_pointcloud_changedetector.h b/octree/include/pcl/octree/octree_pointcloud_changedetector.h index fd06d3beca6..b240fb8b53d 100644 --- a/octree/include/pcl/octree/octree_pointcloud_changedetector.h +++ b/octree/include/pcl/octree/octree_pointcloud_changedetector.h @@ -92,14 +92,14 @@ class OctreePointCloudChangeDetector */ std::size_t getPointIndicesFromNewVoxels(Indices& indicesVector_arg, - const int minPointsPerLeaf_arg = 0) + const index_t minPointsPerLeaf_arg = 0) { std::vector leaf_containers; this->serializeNewLeafs(leaf_containers); for (const auto& leaf_container : leaf_containers) { - if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) + if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) leaf_container->getPointIndices(indicesVector_arg); } diff --git a/octree/include/pcl/octree/octree_pointcloud_density.h b/octree/include/pcl/octree/octree_pointcloud_density.h index 61545019577..1083c20a059 100644 --- a/octree/include/pcl/octree/octree_pointcloud_density.h +++ b/octree/include/pcl/octree/octree_pointcloud_density.h @@ -76,12 +76,12 @@ class OctreePointCloudDensityContainer : public OctreeContainerBase { /** \brief Read input data. Only an internal counter is increased. */ - void addPointIndex(index_t) { point_counter_++; } + void addPointIndex(uindex_t) { point_counter_++; } /** \brief Return point counter. * \return Amount of points */ - unsigned int + uindex_t getPointCounter() { return (point_counter_); From fd2e2e812e9e7907ea35e5c5e9a6c66a824273d8 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 20 Sep 2020 00:14:06 +0900 Subject: [PATCH 050/431] Better octree-pointcloud --- .../pcl/octree/impl/octree_pointcloud.hpp | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 22f5b909390..2d16c658708 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -278,14 +278,14 @@ pcl::octree::OctreePointCloud const float step_size = static_cast(resolution_) * precision; // Ensure we get at least one step for the first voxel. - const int nsteps = std::max(1, static_cast(norm / step_size)); + const auto nsteps = std::max(1, norm / step_size); OctreeKey prev_key; bool bkeyDefined = false; // Walk along the line segment with small steps. - for (int i = 0; i < nsteps; ++i) { + for (std::size_t i = 0; i < nsteps; ++i) { Eigen::Vector3f p = origin + (direction * step_size * static_cast(i)); PointT octree_p; @@ -668,7 +668,7 @@ pcl::octree::OctreePointCloud LeafNode* leaf_node; BranchNode* parent_branch_of_leaf_node; - unsigned int depth_mask = this->createLeafRecursive( + auto depth_mask = this->createLeafRecursive( key, this->depth_mask_, this->root_node_, leaf_node, parent_branch_of_leaf_node); if (this->dynamic_depth_enabled_ && depth_mask) { @@ -716,36 +716,28 @@ void pcl::octree::OctreePointCloud:: getKeyBitSize() { - unsigned int max_voxels; - - unsigned int max_key_x; - unsigned int max_key_y; - unsigned int max_key_z; - - double octree_side_len; - const float minValue = std::numeric_limits::epsilon(); // find maximum key values for x, y, z - max_key_x = - static_cast(std::ceil((max_x_ - min_x_ - minValue) / resolution_)); - max_key_y = - static_cast(std::ceil((max_y_ - min_y_ - minValue) / resolution_)); - max_key_z = - static_cast(std::ceil((max_z_ - min_z_ - minValue) / resolution_)); + const auto max_key_x = + static_cast(std::ceil((max_x_ - min_x_ - minValue) / resolution_)); + const auto max_key_y = + static_cast(std::ceil((max_y_ - min_y_ - minValue) / resolution_)); + const auto max_key_z = + static_cast(std::ceil((max_z_ - min_z_ - minValue) / resolution_)); // find maximum amount of keys - max_voxels = std::max(std::max(std::max(max_key_x, max_key_y), max_key_z), - static_cast(2)); + const auto max_voxels = + std::max(std::max(std::max(max_key_x, max_key_y), max_key_z), 2); // tree depth == amount of bits of max_voxels - this->octree_depth_ = - std::max((std::min(static_cast(OctreeKey::maxDepth), - static_cast( - std::ceil(std::log2(max_voxels) - minValue)))), - static_cast(0)); + this->octree_depth_ = std::max( + std::min(OctreeKey::maxDepth, + std::ceil(std::log2(max_voxels) - minValue)), + 0); - octree_side_len = static_cast(1 << this->octree_depth_) * resolution_; + const auto octree_side_len = + static_cast(1 << this->octree_depth_) * resolution_; if (this->leaf_count_ == 0) { double octree_oversize_x; @@ -793,12 +785,9 @@ pcl::octree::OctreePointCloud genOctreeKeyforPoint(const PointT& point_arg, OctreeKey& key_arg) const { // calculate integer key for point coordinates - key_arg.x = - static_cast((point_arg.x - this->min_x_) / this->resolution_); - key_arg.y = - static_cast((point_arg.y - this->min_y_) / this->resolution_); - key_arg.z = - static_cast((point_arg.z - this->min_z_) / this->resolution_); + key_arg.x = static_cast((point_arg.x - this->min_x_) / this->resolution_); + key_arg.y = static_cast((point_arg.y - this->min_y_) / this->resolution_); + key_arg.z = static_cast((point_arg.z - this->min_z_) / this->resolution_); assert(key_arg.x <= this->max_key_.x); assert(key_arg.y <= this->max_key_.y); From 85bfe05e43d6cfd5ff9ad0119b981a792f888e07 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 20 Sep 2020 00:24:08 +0900 Subject: [PATCH 051/431] tree-depth converted to uindex_t --- octree/include/pcl/octree/impl/octree_pointcloud.hpp | 8 ++++---- octree/include/pcl/octree/impl/octree_search.hpp | 8 ++++---- octree/include/pcl/octree/octree_pointcloud.h | 8 ++++---- octree/include/pcl/octree/octree_pointcloud_density.h | 2 +- octree/include/pcl/octree/octree_search.h | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 2d16c658708..38fc3346bf7 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -859,7 +859,7 @@ template :: genVoxelCenterFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, PointT& point_arg) const { // generate point for voxel center defined by treedepth (bitLen) and key @@ -888,7 +888,7 @@ template :: genVoxelBoundsFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, Eigen::Vector3f& min_pt, Eigen::Vector3f& max_pt) const { @@ -920,7 +920,7 @@ template double pcl::octree::OctreePointCloud:: - getVoxelSquaredSideLen(unsigned int tree_depth_arg) const + getVoxelSquaredSideLen(uindex_t tree_depth_arg) const { double side_len; @@ -941,7 +941,7 @@ template double pcl::octree::OctreePointCloud:: - getVoxelSquaredDiameter(unsigned int tree_depth_arg) const + getVoxelSquaredDiameter(uindex_t tree_depth_arg) const { // return the squared side length of the voxel cube as a function of the octree depth return (getVoxelSquaredSideLen(tree_depth_arg) * 3); diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 6f7563bad00..b9248d41ccc 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -226,7 +226,7 @@ OctreePointCloudSearch:: uindex_t K, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, const double squared_search_radius, std::vector& point_candidates) const { @@ -337,7 +337,7 @@ OctreePointCloudSearch:: const double radiusSquared, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices, std::vector& k_sqr_distances, uindex_t max_nn) const @@ -423,7 +423,7 @@ OctreePointCloudSearch:: approxNearestSearchRecursive(const PointT& point, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, index_t& result_index, float& sqr_distance) { @@ -521,7 +521,7 @@ OctreePointCloudSearch::boxSearchRecur const Eigen::Vector3f& max_pt, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices) const { // iterate over all children diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 66afc625c41..975eeeaa8bf 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -365,7 +365,7 @@ class OctreePointCloud : public OctreeT { * \return squared diameter */ double - getVoxelSquaredDiameter(unsigned int tree_depth_arg) const; + getVoxelSquaredDiameter(uindex_t tree_depth_arg) const; /** \brief Calculates the squared diameter of a voxel at leaf depth * \return squared diameter @@ -381,7 +381,7 @@ class OctreePointCloud : public OctreeT { * \return squared voxel cube side length */ double - getVoxelSquaredSideLen(unsigned int tree_depth_arg) const; + getVoxelSquaredSideLen(uindex_t tree_depth_arg) const; /** \brief Calculates the squared voxel cube side length at leaf level * \return squared voxel cube side length @@ -536,7 +536,7 @@ class OctreePointCloud : public OctreeT { */ void genVoxelCenterFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, PointT& point_arg) const; /** \brief Generate bounds of an octree voxel using octree key and tree depth @@ -548,7 +548,7 @@ class OctreePointCloud : public OctreeT { */ void genVoxelBoundsFromOctreeKey(const OctreeKey& key_arg, - unsigned int tree_depth_arg, + uindex_t tree_depth_arg, Eigen::Vector3f& min_pt, Eigen::Vector3f& max_pt) const; diff --git a/octree/include/pcl/octree/octree_pointcloud_density.h b/octree/include/pcl/octree/octree_pointcloud_density.h index 1083c20a059..35501033697 100644 --- a/octree/include/pcl/octree/octree_pointcloud_density.h +++ b/octree/include/pcl/octree/octree_pointcloud_density.h @@ -129,7 +129,7 @@ class OctreePointCloudDensity * \param[in] point_arg: a point addressing a voxel \return amount of points * that fall within leaf node voxel */ - unsigned int + uindex_t getVoxelDensityAtPoint(const PointT& point_arg) const { uindex_t point_count = 0; diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index df5dffaca9d..8ed045b3189 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -388,7 +388,7 @@ class OctreePointCloudSearch const double radiusSquared, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices, std::vector& k_sqr_distances, uindex_t max_nn) const; @@ -410,7 +410,7 @@ class OctreePointCloudSearch uindex_t K, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, const double squared_search_radius, std::vector& point_candidates) const; @@ -427,7 +427,7 @@ class OctreePointCloudSearch approxNearestSearchRecursive(const PointT& point, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, index_t& result_index, float& sqr_distance); @@ -476,7 +476,7 @@ class OctreePointCloudSearch const Eigen::Vector3f& max_pt, const BranchNode* node, const OctreeKey& key, - unsigned int tree_depth, + uindex_t tree_depth, Indices& k_indices) const; /** \brief Recursively search the tree for all intersected leaf nodes and return a From 0b84314223195cc1864f241c296c26fbad96c029 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 9 Oct 2020 19:26:49 +0900 Subject: [PATCH 052/431] Addressing some of the review comments --- octree/include/pcl/octree/impl/octree_pointcloud.hpp | 4 ++-- .../pcl/octree/impl/octree_pointcloud_adjacency.hpp | 4 ++-- octree/include/pcl/octree/impl/octree_search.hpp | 4 ++-- octree/include/pcl/octree/octree_container.h | 10 +++++----- octree/include/pcl/octree/octree_pointcloud.h | 2 +- .../pcl/octree/octree_pointcloud_adjacency_container.h | 4 ++-- .../pcl/octree/octree_pointcloud_changedetector.h | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index 38fc3346bf7..e89f2d4522b 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -265,7 +265,7 @@ template -pcl::index_t +pcl::uindex_t pcl::octree::OctreePointCloud:: getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, @@ -320,7 +320,7 @@ pcl::octree::OctreePointCloud voxel_center_list.push_back(center); } - return (static_cast(voxel_center_list.size())); + return (static_cast(voxel_center_list.size())); } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index 3bcaf1ce147..d5e4cc05fa9 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -288,13 +288,13 @@ pcl::octree::OctreePointCloudAdjacency direction.normalize(); float precision = 1.0f; const float step_size = static_cast(resolution_) * precision; - const auto nsteps = std::max(1, norm / step_size); + const auto nsteps = std::max(1, norm / step_size); OctreeKey prev_key = key; // Walk along the line segment with small steps. Eigen::Vector3f p = leaf_centroid; PointT octree_p; - for (uindex_t i = 0; i < nsteps; ++i) { + for (std::size_t i = 0; i < nsteps; ++i) { // Start at the leaf voxel, and move back towards sensor. p += (direction * step_size); diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index b9248d41ccc..61fd51738ef 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -107,12 +107,12 @@ OctreePointCloudSearch::nearestKSearch getKNearestNeighborRecursive( p_q, k, this->root_node_, key, 1, smallest_dist, point_candidates); - index_t result_count = static_cast(point_candidates.size()); + const auto result_count = static_cast(point_candidates.size()); k_indices.resize(result_count); k_sqr_distances.resize(result_count); - for (index_t i = 0; i < result_count; ++i) { + for (uindex_t i = 0; i < result_count; ++i) { k_indices[i] = point_candidates[i].point_idx_; k_sqr_distances[i] = point_candidates[i].point_distance_; } diff --git a/octree/include/pcl/octree/octree_container.h b/octree/include/pcl/octree/octree_container.h index 049ca9855c2..f520cbcda86 100644 --- a/octree/include/pcl/octree/octree_container.h +++ b/octree/include/pcl/octree/octree_container.h @@ -76,7 +76,7 @@ class OctreeContainerBase { /** \brief Pure abstract method to get size of container (number of indices) * \return number of points/indices stored in leaf node container. */ - virtual index_t + virtual uindex_t getSize() const { return 0u; @@ -127,7 +127,7 @@ class OctreeContainerEmpty : public OctreeContainerBase { /** \brief Abstract get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - index_t + uindex_t getSize() const override { return 0; @@ -225,7 +225,7 @@ class OctreeContainerPointIndex : public OctreeContainerBase { /** \brief Get size of container (number of DataT objects) * \return number of DataT elements in leaf node container. */ - index_t + uindex_t getSize() const override { return data_ != static_cast(-1) ? 0 : 1; @@ -314,10 +314,10 @@ class OctreeContainerPointIndices : public OctreeContainerBase { /** \brief Get size of container (number of indices) * \return number of point indices in container. */ - index_t + uindex_t getSize() const override { - return static_cast(leafDataTVector_.size()); + return static_cast(leafDataTVector_.size()); } /** \brief Reset leaf node. Clear DataT vector.*/ diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 975eeeaa8bf..6cd91a167f2 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -279,7 +279,7 @@ class OctreePointCloud : public OctreeT { * octree_resolution x precision * \return number of intersected voxels */ - index_t + uindex_t getApproxIntersectedVoxelCentersBySegment(const Eigen::Vector3f& origin, const Eigen::Vector3f& end, AlignedPointTVector& voxel_center_list, diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h index a5bc2a2a25b..6cff9dad137 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency_container.h @@ -119,10 +119,10 @@ class OctreePointCloudAdjacencyContainer : public OctreeContainerBase { /** \brief virtual method to get size of container * \return number of points added to leaf node container. */ - index_t + uindex_t getSize() const override { - return static_cast(num_points_); + return num_points_; } protected: diff --git a/octree/include/pcl/octree/octree_pointcloud_changedetector.h b/octree/include/pcl/octree/octree_pointcloud_changedetector.h index b240fb8b53d..c8ddadf3185 100644 --- a/octree/include/pcl/octree/octree_pointcloud_changedetector.h +++ b/octree/include/pcl/octree/octree_pointcloud_changedetector.h @@ -92,14 +92,14 @@ class OctreePointCloudChangeDetector */ std::size_t getPointIndicesFromNewVoxels(Indices& indicesVector_arg, - const index_t minPointsPerLeaf_arg = 0) + const uindex_t minPointsPerLeaf_arg = 0) { std::vector leaf_containers; this->serializeNewLeafs(leaf_containers); for (const auto& leaf_container : leaf_containers) { - if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) + if (static_cast(leaf_container->getSize()) >= minPointsPerLeaf_arg) leaf_container->getPointIndices(indicesVector_arg); } From 7eb38886c4281e45398865d4f21350e5974d890b Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 19 Feb 2021 00:44:50 +0900 Subject: [PATCH 053/431] Switching on octree on the CI to confirm --- .ci/azure-pipelines/build/ubuntu_indices.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-pipelines/build/ubuntu_indices.yaml b/.ci/azure-pipelines/build/ubuntu_indices.yaml index 28f8340db43..bbdc900ffa6 100644 --- a/.ci/azure-pipelines/build/ubuntu_indices.yaml +++ b/.ci/azure-pipelines/build/ubuntu_indices.yaml @@ -14,7 +14,7 @@ steps: -DBUILD_tools=OFF \ -DBUILD_kdtree=OFF \ -DBUILD_ml=OFF \ - -DBUILD_octree=OFF \ + -DBUILD_octree=ON \ -DBUILD_global_tests=ON # Temporary fix to ensure no tests are skipped cmake $(Build.SourcesDirectory) From 45c2b131be8984a484ca141db221e1257de29b61 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sat, 20 Feb 2021 13:27:40 +0900 Subject: [PATCH 054/431] Making incoming index unsigned --- .../pcl/octree/impl/octree_pointcloud.hpp | 6 +++--- .../impl/octree_pointcloud_adjacency.hpp | 2 +- .../include/pcl/octree/impl/octree_search.hpp | 8 ++++---- octree/include/pcl/octree/octree_pointcloud.h | 6 +++--- .../pcl/octree/octree_pointcloud_adjacency.h | 2 +- .../octree/octree_pointcloud_voxelcentroid.h | 2 +- octree/include/pcl/octree/octree_search.h | 18 +++++++++--------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_pointcloud.hpp b/octree/include/pcl/octree/impl/octree_pointcloud.hpp index e89f2d4522b..9326b64af43 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud.hpp @@ -105,7 +105,7 @@ template void pcl::octree::OctreePointCloud:: - addPointFromCloud(const index_t point_idx_arg, IndicesPtr indices_arg) + addPointFromCloud(const uindex_t point_idx_arg, IndicesPtr indices_arg) { this->addPointIdx(point_idx_arg); if (indices_arg) @@ -652,7 +652,7 @@ template void pcl::octree::OctreePointCloud:: - addPointIdx(const index_t point_idx_arg) + addPointIdx(const uindex_t point_idx_arg) { OctreeKey key; @@ -700,7 +700,7 @@ template const PointT& pcl::octree::OctreePointCloud:: - getPointByIndex(const index_t index_arg) const + getPointByIndex(const uindex_t index_arg) const { // retrieve point from input cloud assert(index_arg < input_->size()); diff --git a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp index d5e4cc05fa9..57590745684 100644 --- a/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp +++ b/octree/include/pcl/octree/impl/octree_pointcloud_adjacency.hpp @@ -147,7 +147,7 @@ pcl::octree::OctreePointCloudAdjacency template void pcl::octree::OctreePointCloudAdjacency:: - addPointIdx(const index_t pointIdx_arg) + addPointIdx(const uindex_t pointIdx_arg) { OctreeKey key; diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 61fd51738ef..d385e185c70 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -71,7 +71,7 @@ OctreePointCloudSearch::voxelSearch( template bool OctreePointCloudSearch::voxelSearch( - const index_t index, Indices& point_idx_data) + const uindex_t index, Indices& point_idx_data) { const PointT search_point = this->getPointByIndex(index); return (this->voxelSearch(search_point, point_idx_data)); @@ -123,7 +123,7 @@ OctreePointCloudSearch::nearestKSearch template uindex_t OctreePointCloudSearch::nearestKSearch( - index_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) + uindex_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) { const PointT search_point = this->getPointByIndex(index); return (nearestKSearch(search_point, k, k_indices, k_sqr_distances)); @@ -150,7 +150,7 @@ OctreePointCloudSearch::approxNearestS template void OctreePointCloudSearch::approxNearestSearch( - index_t query_index, index_t& result_index, float& sqr_distance) + uindex_t query_index, index_t& result_index, float& sqr_distance) { const PointT search_point = this->getPointByIndex(query_index); @@ -189,7 +189,7 @@ OctreePointCloudSearch::radiusSearch( template uindex_t OctreePointCloudSearch::radiusSearch( - index_t index, + uindex_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, diff --git a/octree/include/pcl/octree/octree_pointcloud.h b/octree/include/pcl/octree/octree_pointcloud.h index 6cd91a167f2..be4df0fc1b4 100644 --- a/octree/include/pcl/octree/octree_pointcloud.h +++ b/octree/include/pcl/octree/octree_pointcloud.h @@ -200,7 +200,7 @@ class OctreePointCloud : public OctreeT { * setInputCloud) */ void - addPointFromCloud(index_t point_idx_arg, IndicesPtr indices_arg); + addPointFromCloud(uindex_t point_idx_arg, IndicesPtr indices_arg); /** \brief Add point simultaneously to octree and input point cloud. * \param[in] point_arg point to be added @@ -428,7 +428,7 @@ class OctreePointCloud : public OctreeT { * \a setInputCloud to be added */ virtual void - addPointIdx(index_t point_idx_arg); + addPointIdx(uindex_t point_idx_arg); /** \brief Add point at index from input pointcloud dataset to octree * \param[in] leaf_node to be expanded @@ -448,7 +448,7 @@ class OctreePointCloud : public OctreeT { * \return PointT from input pointcloud dataset */ const PointT& - getPointByIndex(index_t index_arg) const; + getPointByIndex(uindex_t index_arg) const; /** \brief Find octree leaf node at a given point * \param[in] point_arg query point diff --git a/octree/include/pcl/octree/octree_pointcloud_adjacency.h b/octree/include/pcl/octree/octree_pointcloud_adjacency.h index 8b93c9b71d3..0d4ea118478 100644 --- a/octree/include/pcl/octree/octree_pointcloud_adjacency.h +++ b/octree/include/pcl/octree/octree_pointcloud_adjacency.h @@ -195,7 +195,7 @@ class OctreePointCloudAdjacency * \note This virtual implementation allows the use of a transform function to compute * keys. */ void - addPointIdx(index_t point_idx_arg) override; + addPointIdx(uindex_t point_idx_arg) override; /** \brief Fills in the neighbors fields for new voxels. * diff --git a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h index 4c8973f9019..a31113363b8 100644 --- a/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h +++ b/octree/include/pcl/octree/octree_pointcloud_voxelcentroid.h @@ -156,7 +156,7 @@ class OctreePointCloudVoxelCentroid * \param pointIdx_arg */ void - addPointIdx(const index_t pointIdx_arg) override + addPointIdx(const uindex_t pointIdx_arg) override { OctreeKey key; diff --git a/octree/include/pcl/octree/octree_search.h b/octree/include/pcl/octree/octree_search.h index 8ed045b3189..ed29fb2d8e5 100644 --- a/octree/include/pcl/octree/octree_search.h +++ b/octree/include/pcl/octree/octree_search.h @@ -100,7 +100,7 @@ class OctreePointCloudSearch * \return "true" if leaf node exist; "false" otherwise */ bool - voxelSearch(const index_t index, Indices& point_idx_data); + voxelSearch(uindex_t index, Indices& point_idx_data); /** \brief Search for k-nearest neighbors at the query point. * \param[in] cloud the point cloud data @@ -114,7 +114,7 @@ class OctreePointCloudSearch */ inline uindex_t nearestKSearch(const PointCloud& cloud, - index_t index, + uindex_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances) @@ -149,7 +149,7 @@ class OctreePointCloudSearch * \return number of neighbors found */ uindex_t - nearestKSearch(index_t index, + nearestKSearch(uindex_t index, uindex_t k, Indices& k_indices, std::vector& k_sqr_distances); @@ -163,7 +163,7 @@ class OctreePointCloudSearch */ inline void approxNearestSearch(const PointCloud& cloud, - index_t query_index, + uindex_t query_index, index_t& result_index, float& sqr_distance) { @@ -187,7 +187,7 @@ class OctreePointCloudSearch * \return number of neighbors found */ void - approxNearestSearch(index_t query_index, index_t& result_index, float& sqr_distance); + approxNearestSearch(uindex_t query_index, index_t& result_index, float& sqr_distance); /** \brief Search for all neighbors of query point that are within a given radius. * \param[in] cloud the point cloud data @@ -201,7 +201,7 @@ class OctreePointCloudSearch */ uindex_t radiusSearch(const PointCloud& cloud, - index_t index, + uindex_t index, double radius, Indices& k_indices, std::vector& k_sqr_distances, @@ -238,7 +238,7 @@ class OctreePointCloudSearch * \return number of neighbors found in radius */ uindex_t - radiusSearch(index_t index, + radiusSearch(uindex_t index, const double radius, Indices& k_indices, std::vector& k_sqr_distances, @@ -341,7 +341,7 @@ class OctreePointCloudSearch * \param[in] point_idx index for a dataset point given by \a setInputCloud * \param[in] point_distance distance of query point to voxel center */ - prioPointQueueEntry(index_t point_idx, float point_distance) + prioPointQueueEntry(uindex_t point_idx, float point_distance) : point_idx_(point_idx), point_distance_(point_distance) {} @@ -355,7 +355,7 @@ class OctreePointCloudSearch } /** \brief Index representing a point in the dataset given by \a setInputCloud. */ - index_t point_idx_; + uindex_t point_idx_; /** \brief Distance to query point. */ float point_distance_; From 3c0a163b74202ebbe599013d43dad3273a850547 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 19 Feb 2021 03:46:27 +0900 Subject: [PATCH 055/431] Working on IO and Stereo modules --- .ci/azure-pipelines/build/ubuntu_indices.yaml | 3 +- io/include/pcl/compression/color_coding.h | 43 +++++++++---------- .../octree_pointcloud_compression.h | 2 +- io/include/pcl/compression/point_coding.h | 13 +++--- .../pcl/octree/impl/octree_iterator.hpp | 3 +- test/octree/test_octree.cpp | 6 +-- 6 files changed, 33 insertions(+), 37 deletions(-) diff --git a/.ci/azure-pipelines/build/ubuntu_indices.yaml b/.ci/azure-pipelines/build/ubuntu_indices.yaml index bbdc900ffa6..07463d6dca0 100644 --- a/.ci/azure-pipelines/build/ubuntu_indices.yaml +++ b/.ci/azure-pipelines/build/ubuntu_indices.yaml @@ -11,10 +11,11 @@ steps: -DPCL_INDEX_SIGNED=$INDEX_SIGNED \ -DPCL_INDEX_SIZE=$INDEX_SIZE \ -DBUILD_geometry=OFF \ + -DBUILD_io=OFF \ -DBUILD_tools=OFF \ -DBUILD_kdtree=OFF \ -DBUILD_ml=OFF \ - -DBUILD_octree=ON \ + -DBUILD_stereo=OFF \ -DBUILD_global_tests=ON # Temporary fix to ensure no tests are skipped cmake $(Build.SourcesDirectory) diff --git a/io/include/pcl/compression/color_coding.h b/io/include/pcl/compression/color_coding.h index af0e6414df5..92bb9d88e72 100644 --- a/io/include/pcl/compression/color_coding.h +++ b/io/include/pcl/compression/color_coding.h @@ -157,16 +157,14 @@ class ColorCoding void encodeAverageOfPoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { - unsigned int avgRed = 0; - unsigned int avgGreen = 0; - unsigned int avgBlue = 0; + uindex_t avgRed = 0; + uindex_t avgGreen = 0; + uindex_t avgBlue = 0; // iterate over points - std::size_t len = indexVector_arg.size (); - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { // get color information from points - const int& idx = indexVector_arg[i]; const char* idxPointPtr = reinterpret_cast (&(*inputCloud_arg)[idx]); const int& colorInt = *reinterpret_cast (idxPointPtr+rgba_offset_arg); @@ -177,12 +175,13 @@ class ColorCoding } + const uindex_t len = static_cast (indexVector_arg.size()); // calculated average color information if (len > 1) { - avgRed /= static_cast (len); - avgGreen /= static_cast (len); - avgBlue /= static_cast (len); + avgRed /= len; + avgGreen /= len; + avgBlue /= len; } // remove least significant bits @@ -204,19 +203,17 @@ class ColorCoding void encodePoints (const Indices& indexVector_arg, unsigned char rgba_offset_arg, PointCloudConstPtr inputCloud_arg) { - unsigned int avgRed; - unsigned int avgGreen; - unsigned int avgBlue; + uindex_t avgRed; + uindex_t avgGreen; + uindex_t avgBlue; // initialize avgRed = avgGreen = avgBlue = 0; // iterate over points - std::size_t len = indexVector_arg.size (); - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { // get color information from point - const int& idx = indexVector_arg[i]; const char* idxPointPtr = reinterpret_cast (&(*inputCloud_arg)[idx]); const int& colorInt = *reinterpret_cast (idxPointPtr+rgba_offset_arg); @@ -227,6 +224,7 @@ class ColorCoding } + const uindex_t len = static_cast (indexVector_arg.size()); if (len > 1) { unsigned char diffRed; @@ -234,14 +232,13 @@ class ColorCoding unsigned char diffBlue; // calculated average color information - avgRed /= static_cast (len); - avgGreen /= static_cast (len); - avgBlue /= static_cast (len); + avgRed /= len; + avgGreen /= len; + avgBlue /= len; // iterate over points for differential encoding - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { - const int& idx = indexVector_arg[i]; const char* idxPointPtr = reinterpret_cast (&(*inputCloud_arg)[idx]); const int& colorInt = *reinterpret_cast (idxPointPtr+rgba_offset_arg); @@ -281,12 +278,12 @@ class ColorCoding * \param rgba_offset_arg offset to color information */ void - decodePoints (PointCloudPtr outputCloud_arg, std::size_t beginIdx_arg, std::size_t endIdx_arg, unsigned char rgba_offset_arg) + decodePoints (PointCloudPtr outputCloud_arg, uindex_t beginIdx_arg, uindex_t endIdx_arg, unsigned char rgba_offset_arg) { assert (beginIdx_arg <= endIdx_arg); // amount of points to be decoded - unsigned int pointCount = static_cast (endIdx_arg - beginIdx_arg); + const index_t pointCount = endIdx_arg - beginIdx_arg; // get averaged color information for current voxel unsigned char avgRed = *(pointAvgColorDataVector_Iterator_++); @@ -299,7 +296,7 @@ class ColorCoding avgBlue = static_cast (avgBlue << colorBitReduction_); // iterate over points - for (std::size_t i = 0; i < pointCount; i++) + for (index_t i = 0; i < pointCount; i++) { unsigned int colorInt; if (pointCount > 1) diff --git a/io/include/pcl/compression/octree_pointcloud_compression.h b/io/include/pcl/compression/octree_pointcloud_compression.h index 4a742179d91..ad1ef83a3d9 100644 --- a/io/include/pcl/compression/octree_pointcloud_compression.h +++ b/io/include/pcl/compression/octree_pointcloud_compression.h @@ -158,7 +158,7 @@ namespace pcl * \param[in] pointIdx_arg the index representing the point in the dataset given by \a setInputCloud to be added */ void - addPointIdx (const index_t pointIdx_arg) override + addPointIdx (const uindex_t pointIdx_arg) override { ++object_count_; OctreePointCloud::addPointIdx(pointIdx_arg); diff --git a/io/include/pcl/compression/point_coding.h b/io/include/pcl/compression/point_coding.h index d10eb23c44c..79db3a0d412 100644 --- a/io/include/pcl/compression/point_coding.h +++ b/io/include/pcl/compression/point_coding.h @@ -129,15 +129,12 @@ class PointCoding encodePoints (const Indices& indexVector_arg, const double* referencePoint_arg, PointCloudConstPtr inputCloud_arg) { - std::size_t len = indexVector_arg.size (); - // iterate over points within current voxel - for (std::size_t i = 0; i < len; i++) + for (const auto& idx: indexVector_arg) { unsigned char diffX, diffY, diffZ; // retrieve point from cloud - const int& idx = indexVector_arg[i]; const PointT& idxPoint = (*inputCloud_arg)[idx]; // differentially encode point coordinates and truncate overflow @@ -159,15 +156,15 @@ class PointCoding * \param endIdx_arg index indicating last point to be assigned with color information */ void - decodePoints (PointCloudPtr outputCloud_arg, const double* referencePoint_arg, std::size_t beginIdx_arg, - std::size_t endIdx_arg) + decodePoints (PointCloudPtr outputCloud_arg, const double* referencePoint_arg, uindex_t beginIdx_arg, + uindex_t endIdx_arg) { assert (beginIdx_arg <= endIdx_arg); - unsigned int pointCount = static_cast (endIdx_arg - beginIdx_arg); + const uindex_t pointCount = endIdx_arg - beginIdx_arg; // iterate over points within current voxel - for (std::size_t i = 0; i < pointCount; i++) + for (uindex_t i = 0; i < pointCount; i++) { // retrieve differential point information const unsigned char& diffX = static_cast (*(pointDiffDataVectorIterator_++)); diff --git a/octree/include/pcl/octree/impl/octree_iterator.hpp b/octree/include/pcl/octree/impl/octree_iterator.hpp index 6a394ab1545..1398cf5d2a6 100644 --- a/octree/include/pcl/octree/impl/octree_iterator.hpp +++ b/octree/include/pcl/octree/impl/octree_iterator.hpp @@ -257,7 +257,8 @@ OctreeBreadthFirstIterator::operator++() ////////////////////////////////////////////////////////////////////////////////////////////// template -OctreeFixedDepthIterator::OctreeFixedDepthIterator() : fixed_depth_(0u) +OctreeFixedDepthIterator::OctreeFixedDepthIterator() +: OctreeBreadthFirstIterator(nullptr, 0), fixed_depth_(0u) {} ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/test/octree/test_octree.cpp b/test/octree/test_octree.cpp index b2c7e579a93..f04115fa373 100644 --- a/test/octree/test_octree.cpp +++ b/test/octree/test_octree.cpp @@ -797,7 +797,7 @@ TEST (PCL, Octree_Pointcloud_Test) auto current = pointIdxVec.cbegin (); while (current != pointIdxVec.cend ()) { - if (*current == static_cast (i)) + if (*current == static_cast (i)) { bIdxFound = true; break; @@ -1325,7 +1325,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) // brute force search double BFdistance = std::numeric_limits::max (); - int BFindex = 0; + pcl::index_t BFindex = 0; for (std::size_t i = 0; i < cloudIn->size (); i++) { @@ -1335,7 +1335,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) if (pointDist < BFdistance) { - BFindex = static_cast (i); + BFindex = static_cast (i); BFdistance = pointDist; } From 58fe60fae5cb0778a85a292feb5472fa27182df3 Mon Sep 17 00:00:00 2001 From: Harshit Verma Date: Sun, 14 Mar 2021 09:46:42 +0530 Subject: [PATCH 056/431] clean a loop with for-range --- apps/src/openni_tracking.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/src/openni_tracking.cpp b/apps/src/openni_tracking.cpp index bc003de4b3f..d03ad24d0d1 100644 --- a/apps/src/openni_tracking.cpp +++ b/apps/src/openni_tracking.cpp @@ -435,12 +435,12 @@ class OpenNISegmentTracking { result.width = cloud->width; result.height = cloud->height; result.is_dense = cloud->is_dense; - for (std::size_t i = 0; i < cloud->size(); i++) { + for (const auto& pt : *cloud) { RefPointType point; - point.x = (*cloud)[i].x; - point.y = (*cloud)[i].y; - point.z = (*cloud)[i].z; - point.rgba = (*cloud)[i].rgba; + point.x = pt.x; + point.y = pt.y; + point.z = pt.z; + point.rgba = pt.rgba; result.push_back(point); } } From 6b928dc4492917b4c8d5662f7c216ca00f25281f Mon Sep 17 00:00:00 2001 From: AdamKorcz Date: Mon, 15 Mar 2021 13:30:26 +0000 Subject: [PATCH 057/431] Spaces instead of tabs --- test/fuzz/ply_reader_fuzzer.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/fuzz/ply_reader_fuzzer.cpp b/test/fuzz/ply_reader_fuzzer.cpp index d30cdc86e54..dddd5d8534c 100644 --- a/test/fuzz/ply_reader_fuzzer.cpp +++ b/test/fuzz/ply_reader_fuzzer.cpp @@ -6,18 +6,18 @@ #include extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - pcl::PCLPointCloud2 cloud_blob; - pcl::PLYReader reader; - char filename[256]; - sprintf(filename, "/tmp/libfuzzer.%d", getpid()); + pcl::PCLPointCloud2 cloud_blob; + pcl::PLYReader reader; + char filename[256]; + sprintf(filename, "/tmp/libfuzzer.%d", getpid()); - FILE *fp = fopen(filename, "wb"); - if (!fp) - return 0; - fwrite(data, size, 1, fp); - fclose(fp); + FILE *fp = fopen(filename, "wb"); + if (!fp) + return 0; + fwrite(data, size, 1, fp); + fclose(fp); - reader.read (filename, cloud_blob); - unlink(filename); - return 0; + reader.read (filename, cloud_blob); + unlink(filename); + return 0; } From a4641930b03a55ea3c803dbf56c82c113fe64a96 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Mon, 15 Mar 2021 21:05:22 +0100 Subject: [PATCH 058/431] Tests: use better asserts and expects - Use e.g. ASSERT_LE(a, b) instead of ASSERT_TRUE(a<=b) because in a failure case, the former reports the values of a and b, while the latter only reports the failure. Similar for greater, equal, etc - Use ASSERT_TRUE(a) instead of ASSERT_EQ(a, true) for better readability --- test/filters/test_uniform_sampling.cpp | 2 +- test/io/test_ply_io.cpp | 4 ++-- test/octree/test_octree.cpp | 10 +++++----- test/registration/test_registration.cpp | 2 +- test/search/test_flann_search.cpp | 4 ++-- test/search/test_kdtree.cpp | 4 ++-- test/search/test_octree.cpp | 6 +++--- test/search/test_organized.cpp | 6 +++--- test/search/test_organized_index.cpp | 12 ++++++------ 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/filters/test_uniform_sampling.cpp b/test/filters/test_uniform_sampling.cpp index f09a95c3e6c..f9410a9e04d 100644 --- a/test/filters/test_uniform_sampling.cpp +++ b/test/filters/test_uniform_sampling.cpp @@ -71,7 +71,7 @@ TEST(UniformSampling, extractRemovedIndices) ASSERT_EQ(output.size(), 1000); EXPECT_EQ(removed_indices->size(), xyz->size() - 1000); std::set removed_indices_set(removed_indices->begin(), removed_indices->end()); - ASSERT_TRUE(removed_indices_set.size() == removed_indices->size()); + ASSERT_EQ(removed_indices_set.size(), removed_indices->size()); } int diff --git a/test/io/test_ply_io.cpp b/test/io/test_ply_io.cpp index 9756b56da55..f743f31faa1 100644 --- a/test/io/test_ply_io.cpp +++ b/test/io/test_ply_io.cpp @@ -499,7 +499,7 @@ TEST_F (PLYTest, NoEndofLine) pcl::PLYReader Reader; Reader.read(PLYTest::mesh_file_ply_, cloud); - ASSERT_EQ (cloud.empty(), false); + ASSERT_FALSE (cloud.empty()); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -529,7 +529,7 @@ TEST_F (PLYTest, CommentAtTheEnd) pcl::PLYReader Reader; Reader.read(PLYTest::mesh_file_ply_, cloud); - ASSERT_EQ (cloud.empty(), false); + ASSERT_FALSE (cloud.empty()); } /* ---[ */ diff --git a/test/octree/test_octree.cpp b/test/octree/test_octree.cpp index f04115fa373..c0811f996b0 100644 --- a/test/octree/test_octree.cpp +++ b/test/octree/test_octree.cpp @@ -900,7 +900,7 @@ TEST (PCL, Octree_Pointcloud_Iterator_Test) for (auto bfIt = octreeA.breadth_begin(); bfIt != octreeA.breadth_end(); ++bfIt) { // tree depth of visited nodes must grow - ASSERT_TRUE (bfIt.getCurrentOctreeDepth () >= lastDepth); + ASSERT_GE (bfIt.getCurrentOctreeDepth (), lastDepth); lastDepth = bfIt.getCurrentOctreeDepth (); if (bfIt.isBranchNode ()) @@ -1018,7 +1018,7 @@ TEST (PCL, Octree_Pointcloud_Change_Detector_Test) // all point indices found should have an index of >= 1000 for (std::size_t i = 0; i < 1000; i++) { - ASSERT_TRUE (newPointIdxVector[i] >= 1000); + ASSERT_GE (newPointIdxVector[i], 1000); } } @@ -1358,7 +1358,7 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) } // we should have found the absolute nearest neighbor at least once - ASSERT_TRUE (bestMatchCount > 0); + ASSERT_GT (bestMatchCount, 0); } TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) @@ -1432,7 +1432,7 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) + ((*cloudIn)[*current].y - searchPoint.y) * ((*cloudIn)[*current].y - searchPoint.y) + ((*cloudIn)[*current].z - searchPoint.z) * ((*cloudIn)[*current].z - searchPoint.z)); - ASSERT_TRUE (pointDist <= searchRadius); + ASSERT_LE (pointDist, searchRadius); ++current; } @@ -1440,7 +1440,7 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) // check if result limitation works octree.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); - ASSERT_TRUE (cloudNWRRadius.size () <= 5); + ASSERT_LE (cloudNWRRadius.size (), 5); } diff --git a/test/registration/test_registration.cpp b/test/registration/test_registration.cpp index c42a56a5bcc..045fb2eebce 100644 --- a/test/registration/test_registration.cpp +++ b/test/registration/test_registration.cpp @@ -184,7 +184,7 @@ TEST(PCL, ICP_translated) icp.align(Final); // Check that we have sucessfully converged - ASSERT_EQ(icp.hasConverged(), true); + ASSERT_TRUE(icp.hasConverged()); // Test that the fitness score is below acceptable threshold EXPECT_LT(icp.getFitnessScore(), 1e-6); diff --git a/test/search/test_flann_search.cpp b/test/search/test_flann_search.cpp index b5bd3051de8..663157f194e 100644 --- a/test/search/test_flann_search.cpp +++ b/test/search/test_flann_search.cpp @@ -165,8 +165,8 @@ TEST (PCL, FlannSearch_differentPointT) for (std::size_t j = 0; j< no_of_neighbors; j++) { EXPECT_TRUE (k_indices[j] == indices[i][j] || k_distances[j] == dists[i][j]); - //EXPECT_TRUE (k_indices[j] == k_indices_t[j]); - //EXPECT_TRUE (k_distances[j] == k_distances_t[j]); + //EXPECT_EQ (k_indices[j], k_indices_t[j]); + //EXPECT_EQ (k_distances[j], k_distances_t[j]); } } diff --git a/test/search/test_kdtree.cpp b/test/search/test_kdtree.cpp index 571f9760f0a..a47c07f8476 100644 --- a/test/search/test_kdtree.cpp +++ b/test/search/test_kdtree.cpp @@ -159,8 +159,8 @@ TEST (PCL, KdTree_differentPointT) for (std::size_t j=0; j< no_of_neighbors; j++) { EXPECT_TRUE (k_indices[j] == indices[i][j] || k_distances[j] == dists[i][j]); - EXPECT_TRUE (k_indices[j] == k_indices_t[j]); - EXPECT_TRUE (k_distances[j] == k_distances_t[j]); + EXPECT_EQ (k_indices[j], k_indices_t[j]); + EXPECT_EQ (k_distances[j], k_distances_t[j]); } } } diff --git a/test/search/test_octree.cpp b/test/search/test_octree.cpp index 225dbf9152c..215d9186951 100644 --- a/test/search/test_octree.cpp +++ b/test/search/test_octree.cpp @@ -225,7 +225,7 @@ TEST (PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) } } // we should have found the absolute nearest neighbor at least once - //ASSERT_EQ ( (bestMatchCount > 0) , true); + //ASSERT_GT (bestMatchCount, 0); } #endif #if 0 @@ -336,12 +336,12 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) ((*cloudIn)[current].z-searchPoint.z) * ((*cloudIn)[current].z-searchPoint.z) ); - ASSERT_EQ ( (pointDist<=searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } // check if result limitation works octree->radiusSearch(searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); - ASSERT_EQ ( cloudNWRRadius.size() <= 5, true); + ASSERT_LE (cloudNWRRadius.size(), 5); } } diff --git a/test/search/test_organized.cpp b/test/search/test_organized.cpp index faf944bba46..ae2dcb4697c 100644 --- a/test/search/test_organized.cpp +++ b/test/search/test_organized.cpp @@ -252,7 +252,7 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Neighbours_Within_Radius_Search) ((*cloudIn)[current].z-searchPoint.z) * ((*cloudIn)[current].z-searchPoint.z) ); - ASSERT_EQ ( (pointDist<=searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } @@ -265,7 +265,7 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Neighbours_Within_Radius_Search) ((*cloudIn)[current].z-searchPoint.z) * ((*cloudIn)[current].z-searchPoint.z) ); - ASSERT_EQ ( (pointDist<=searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } ASSERT_EQ (cloudNWRRadius.size() , cloudSearchBruteforce.size ()); @@ -273,7 +273,7 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Neighbours_Within_Radius_Search) // check if result limitation works organizedNeighborSearch.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); - ASSERT_EQ (cloudNWRRadius.size () <= 5, true); + ASSERT_LE (cloudNWRRadius.size (), 5); } } diff --git a/test/search/test_organized_index.cpp b/test/search/test_organized_index.cpp index 88aedce6a31..2a5c3c56494 100644 --- a/test/search/test_organized_index.cpp +++ b/test/search/test_organized_index.cpp @@ -320,7 +320,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) for (const auto it : cloudNWRSearch) { auto const pointDist = geometry::distance((*cloudIn)[it], searchPoint); - ASSERT_EQ ( (pointDist <= searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } @@ -328,7 +328,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) for (const auto it : cloudSearchBruteforce) { const auto pointDist = geometry::distance((*cloudIn)[it], searchPoint); - ASSERT_EQ ( (pointDist <= searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } ASSERT_EQ (cloudNWRRadius.size() , cloudSearchBruteforce.size ()); @@ -336,7 +336,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) // check if result limitation works organizedNeighborSearch.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); - ASSERT_EQ (cloudNWRRadius.size () <= 5, true); + ASSERT_LE (cloudNWRRadius.size (), 5); } } @@ -523,7 +523,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ for (const auto it : cloudNWRSearch) { double pointDist = geometry::distance((*cloudIn)[it], searchPoint); - ASSERT_EQ ( (pointDist <= searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } @@ -531,7 +531,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ for (const auto it : cloudSearchBruteforce) { double pointDist = geometry::distance((*cloudIn)[it], searchPoint); - ASSERT_EQ ( (pointDist <= searchRadius) , true); + ASSERT_LE (pointDist, searchRadius); } ASSERT_EQ (cloudNWRRadius.size() , cloudSearchBruteforce.size ()); @@ -539,7 +539,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ // check if result limitation works organizedNeighborSearch.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); - ASSERT_EQ (cloudNWRRadius.size () <= 5, true); + ASSERT_LE (cloudNWRRadius.size (), 5); } } From 810a77f70ff6d3797723f6f84079c86d78d7af10 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 16 Mar 2021 07:07:03 +0530 Subject: [PATCH 059/431] [tracking] Use SFINAE instead of relying on macro `PCL_TRACKING_NORMAL_SUPPORTED` (#4643) --- .../pcl/tracking/impl/particle_filter.hpp | 11 +-------- .../include/pcl/tracking/particle_filter.h | 17 ++++++++++++++ tracking/src/kld_adaptive_particle_filter.cpp | 23 +++++++------------ tracking/src/particle_filter.cpp | 21 ++++++----------- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/tracking/include/pcl/tracking/impl/particle_filter.hpp b/tracking/include/pcl/tracking/impl/particle_filter.hpp index 36fdcc90a6e..14c3e85bcd3 100644 --- a/tracking/include/pcl/tracking/impl/particle_filter.hpp +++ b/tracking/include/pcl/tracking/impl/particle_filter.hpp @@ -293,15 +293,11 @@ ParticleFilterTracker::computeTransformedPointCloudWithoutNorm ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template +template > void ParticleFilterTracker::computeTransformedPointCloudWithNormal( -#ifdef PCL_TRACKING_NORMAL_SUPPORTED const StateT& hypothesis, pcl::Indices& indices, PointCloudIn& cloud) -#else - const StateT&, pcl::Indices&, PointCloudIn&) -#endif { -#ifdef PCL_TRACKING_NORMAL_SUPPORTED const Eigen::Affine3f trans = toEigenMatrix(hypothesis); // destructively assigns to cloud pcl::transformPointCloudWithNormals(*ref_, cloud, trans); @@ -318,11 +314,6 @@ ParticleFilterTracker::computeTransformedPointCloudWithNormal( if (theta > occlusion_angle_thr_) indices.push_back(i); } -#else - PCL_WARN("[pcl::%s::computeTransformedPointCloudWithoutNormal] " - "use_normal_ == true is not supported in this Point Type.\n", - getClassName().c_str()); -#endif } template diff --git a/tracking/include/pcl/tracking/particle_filter.h b/tracking/include/pcl/tracking/particle_filter.h index 7af302da10b..ce3ebf24d31 100644 --- a/tracking/include/pcl/tracking/particle_filter.h +++ b/tracking/include/pcl/tracking/particle_filter.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace pcl { namespace tracking { @@ -438,6 +439,7 @@ class ParticleFilterTracker : public Tracker { pcl::Indices& indices, PointCloudIn& cloud); +#ifdef DOXYGEN_ONLY /** \brief Compute a reference pointcloud transformed to the pose that hypothesis * represents and calculate indices taking occlusion into account. * \param[in] hypothesis a particle which represents a hypothesis. @@ -449,6 +451,21 @@ class ParticleFilterTracker : public Tracker { computeTransformedPointCloudWithNormal(const StateT& hypothesis, pcl::Indices& indices, PointCloudIn& cloud); +#else + template = true> + void + computeTransformedPointCloudWithNormal(const StateT& hypothesis, + pcl::Indices& indices, + PointCloudIn& cloud); + template = true> + void + computeTransformedPointCloudWithNormal(const StateT&, pcl::Indices&, PointCloudIn&) + { + PCL_WARN("[pcl::%s::computeTransformedPointCloudWithoutNormal] " + "use_normal_ == true is not supported in this Point Type.\n", + getClassName().c_str()); + } +#endif /** \brief Compute a reference pointcloud transformed to the pose that hypothesis * represents and calculate indices without taking occlusion into account. diff --git a/tracking/src/kld_adaptive_particle_filter.cpp b/tracking/src/kld_adaptive_particle_filter.cpp index b11d00adc08..2642364fdbe 100644 --- a/tracking/src/kld_adaptive_particle_filter.cpp +++ b/tracking/src/kld_adaptive_particle_filter.cpp @@ -40,24 +40,13 @@ #ifndef PCL_NO_PRECOMPILE #include #include -#define PCL_TRACKING_NORMAL_SUPPORTED // clang-format off PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterTracker, ((pcl::PointNormal) (pcl::PointXYZINormal) - (pcl::PointXYZRGBNormal)) - (PCL_STATE_POINT_TYPES)) -PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker, - ((pcl::PointNormal) - (pcl::PointXYZINormal) - (pcl::PointXYZRGBNormal)) - (PCL_STATE_POINT_TYPES)) -// clang-format on -#undef PCL_TRACKING_NORMAL_SUPPORTED -// clang-format off -PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker, - ((pcl::PointXYZ) + (pcl::PointXYZRGBNormal) + (pcl::PointXYZ) (pcl::PointXYZI) (pcl::PointXYZRGBA) (pcl::PointXYZRGB) @@ -66,8 +55,12 @@ PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker, (pcl::PointWithViewpoint) (pcl::PointWithScale)) (PCL_STATE_POINT_TYPES)) -PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterTracker, - ((pcl::PointXYZ) + +PCL_INSTANTIATE_PRODUCT(KLDAdaptiveParticleFilterOMPTracker, + ((pcl::PointNormal) + (pcl::PointXYZINormal) + (pcl::PointXYZRGBNormal) + (pcl::PointXYZ) (pcl::PointXYZI) (pcl::PointXYZRGBA) (pcl::PointXYZRGB) diff --git a/tracking/src/particle_filter.cpp b/tracking/src/particle_filter.cpp index 71e2600148d..96e09f9c869 100644 --- a/tracking/src/particle_filter.cpp +++ b/tracking/src/particle_filter.cpp @@ -40,24 +40,13 @@ #ifndef PCL_NO_PRECOMPILE #include #include -#define PCL_TRACKING_NORMAL_SUPPORTED // clang-format off PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker, ((pcl::PointNormal) (pcl::PointXYZINormal) - (pcl::PointXYZRGBNormal)) - (PCL_STATE_POINT_TYPES)) -PCL_INSTANTIATE_PRODUCT(ParticleFilterOMPTracker, - ((pcl::PointNormal) - (pcl::PointXYZINormal) - (pcl::PointXYZRGBNormal)) - (PCL_STATE_POINT_TYPES)) -// clang-format on -#undef PCL_TRACKING_NORMAL_SUPPORTED -// clang-format off -PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker, - ((pcl::PointXYZ) + (pcl::PointXYZRGBNormal) + (pcl::PointXYZ) (pcl::PointXYZI) (pcl::PointXYZRGBA) (pcl::PointXYZRGB) @@ -66,8 +55,12 @@ PCL_INSTANTIATE_PRODUCT(ParticleFilterTracker, (pcl::PointWithViewpoint) (pcl::PointWithScale)) (PCL_STATE_POINT_TYPES)) + PCL_INSTANTIATE_PRODUCT(ParticleFilterOMPTracker, - ((pcl::PointXYZ) + ((pcl::PointNormal) + (pcl::PointXYZINormal) + (pcl::PointXYZRGBNormal) + (pcl::PointXYZ) (pcl::PointXYZI) (pcl::PointXYZRGBA) (pcl::PointXYZRGB) From 08ee38b2ddc23d023e774b0367ef5f87c7bc0b1e Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Tue, 16 Mar 2021 08:22:19 +0100 Subject: [PATCH 060/431] Don't make vtk a hard requirement. --- surface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surface/CMakeLists.txt b/surface/CMakeLists.txt index 6ab1917f084..9ccf3b3c0fb 100644 --- a/surface/CMakeLists.txt +++ b/surface/CMakeLists.txt @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree) set(build TRUE) PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON) -PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} EXT_DEPS vtk OPT_DEPS qhull) +PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS} OPT_DEPS qhull vtk) PCL_ADD_DOC("${SUBSYS_NAME}") From ea4d0b62d184349dbf4c245d9e79c71d070ff9fe Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Thu, 18 Mar 2021 03:15:09 +0100 Subject: [PATCH 061/431] [CI] Install boost using vcpkg. (#4660) --- .ci/azure-pipelines/build/windows.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.ci/azure-pipelines/build/windows.yaml b/.ci/azure-pipelines/build/windows.yaml index 0e0c90473be..813089ce405 100644 --- a/.ci/azure-pipelines/build/windows.yaml +++ b/.ci/azure-pipelines/build/windows.yaml @@ -2,16 +2,15 @@ steps: - checkout: self # find the commit hash on a quick non-forced update too fetchDepth: 10 - - script: | - echo ##vso[task.setvariable variable=BOOST_ROOT]%BOOST_ROOT_1_72_0% - displayName: 'Set BOOST_ROOT Environment Variable' - - script: | - echo ##vso[task.prependpath]%BOOST_ROOT_1_72_0%\lib - displayName: 'Include Boost Libraries In System PATH' - pwsh: Get-PSDrive displayName: "Check free space" - script: | - vcpkg.exe install eigen3 flann gtest qhull --triplet %PLATFORM%-windows && vcpkg.exe list + vcpkg.exe install eigen3 flann gtest qhull ^ + boost-date-time boost-filesystem boost-iostreams ^ + boost-property-tree boost-graph boost-interprocess ^ + boost-signals2 boost-sort boost-multi-array boost-asio ^ + boost-ptr-container ^ + --triplet %PLATFORM%-windows && vcpkg.exe list displayName: 'Install C++ Dependencies Via Vcpkg' - script: | mkdir %BUILD_DIR% && cd %BUILD_DIR% From f1b096d3f5adbe58511150c210396653af5e1426 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 19 Mar 2021 15:48:08 +0530 Subject: [PATCH 062/431] Adding README to explain LICENSE for metslib --- .../pcl/recognition/3rdparty/metslib/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 recognition/include/pcl/recognition/3rdparty/metslib/README.md diff --git a/recognition/include/pcl/recognition/3rdparty/metslib/README.md b/recognition/include/pcl/recognition/3rdparty/metslib/README.md new file mode 100644 index 00000000000..bc268bbb76a --- /dev/null +++ b/recognition/include/pcl/recognition/3rdparty/metslib/README.md @@ -0,0 +1,15 @@ +# License + +PCL carries a custom (old) version of METSlib which was added (after relicensing for compatibility with PCL) under BSD 3 clause. The details for the addition are: +* author: Mirko Maischberger +* commit: e4d6501af048215ce84b4ee436ff0e18dba2d30d +* URL: https://projects.coin-or.org/metslib + +This has been modified to work with system installed METSlib as well. +Though METSlib is available primarily under GPLv3, it is dually licensed to be available under EPL-1.0 (a commercial friendly license) as well. + +# TL;DR +This implies the following: +* While using PCL with the METSlib shipped with it, everything is licensed under BSD +* While using PCL with system installed METSlib, PCL adheres to the API available under the EPL-1.0 license +* PCL doesn't use the system installed METSlib released under GPLv3 for testing/reference/linking From ad332bb10200cbe5a33347a0f2116df7cbd92cc3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 14 Mar 2021 22:19:27 +0100 Subject: [PATCH 063/431] Improve documentation Fix typos, correct formatting, etc --- common/include/pcl/common/random.h | 2 +- doc/advanced/content/index.rst | 2 +- doc/tutorials/content/bspline_fitting.rst | 2 +- doc/tutorials/content/compiling_pcl_posix.rst | 2 +- doc/tutorials/content/ensenso_cameras.rst | 1 + .../content/global_hypothesis_verification.rst | 8 ++++---- doc/tutorials/content/gpu_install.rst | 6 +++--- doc/tutorials/content/index.rst | 2 +- doc/tutorials/content/octree.rst | 4 ++-- doc/tutorials/content/octree_change.rst | 2 +- doc/tutorials/content/tracking.rst | 2 +- octree/include/pcl/octree/octree2buf_base.h | 3 ++- ...correspondence_estimation_normal_shooting.h | 6 ++++-- ...spondence_estimation_organized_projection.h | 1 + .../registration/correspondence_rejection.h | 4 ++-- .../include/pcl/registration/ia_ransac.h | 4 ++-- registration/include/pcl/registration/icp.h | 5 +++-- .../registration/incremental_registration.h | 5 +++-- .../pcl/registration/meta_registration.h | 5 +++-- .../include/pcl/registration/registration.h | 18 ++++++++++-------- registration/registration.doxy | 2 +- .../segmentation/extract_labeled_clusters.h | 4 ++-- 22 files changed, 50 insertions(+), 40 deletions(-) diff --git a/common/include/pcl/common/random.h b/common/include/pcl/common/random.h index 6262172b9e1..6f8a2bc39fb 100644 --- a/common/include/pcl/common/random.h +++ b/common/include/pcl/common/random.h @@ -69,7 +69,7 @@ namespace pcl }; /** \brief UniformGenerator class generates a random number from range [min, max] at each run picked - * according to a uniform distribution i.e eaach number within [min, max] has almost the same + * according to a uniform distribution i.e each number within [min, max] has almost the same * probability of being drawn. * * \author Nizar Sallem diff --git a/doc/advanced/content/index.rst b/doc/advanced/content/index.rst index cb2c4beb1fb..93d4a1a1f18 100644 --- a/doc/advanced/content/index.rst +++ b/doc/advanced/content/index.rst @@ -97,7 +97,7 @@ development that everyone should follow: An in-depth discussion about the PCL 2.x API can be found here. Committing changes to the git master ------------------------------------ +------------------------------------ In order to oversee the commit messages more easier and that the changelist looks homogenous please keep the following format: "* X in @@ (#)" diff --git a/doc/tutorials/content/bspline_fitting.rst b/doc/tutorials/content/bspline_fitting.rst index 62be34d5071..968fd607156 100644 --- a/doc/tutorials/content/bspline_fitting.rst +++ b/doc/tutorials/content/bspline_fitting.rst @@ -59,7 +59,7 @@ You can find the input file at *pcl/test/bunny.pcd*. .. literalinclude:: sources/bspline_fitting/bspline_fitting.cpp :language: cpp :linenos: - :lines: 1-220 + :lines: 1-219 The explanation diff --git a/doc/tutorials/content/compiling_pcl_posix.rst b/doc/tutorials/content/compiling_pcl_posix.rst index ddf28a99a52..3265435ef80 100644 --- a/doc/tutorials/content/compiling_pcl_posix.rst +++ b/doc/tutorials/content/compiling_pcl_posix.rst @@ -84,7 +84,7 @@ Mandatory The following code libraries are **required** for the compilation and usage of the PCL libraries shown below: .. note:: -pcl_* denotes all PCL libraries, meaning that the particular dependency is a strict requirement for the usage of anything in PCL. + pcl_* denotes all PCL libraries, meaning that the particular dependency is a strict requirement for the usage of anything in PCL. +---------------------------------------------------------------+-----------------+-------------------------+-------------------+ | Logo | Library | Minimum version | Mandatory | diff --git a/doc/tutorials/content/ensenso_cameras.rst b/doc/tutorials/content/ensenso_cameras.rst index c993b787bc9..a69d75904aa 100644 --- a/doc/tutorials/content/ensenso_cameras.rst +++ b/doc/tutorials/content/ensenso_cameras.rst @@ -47,6 +47,7 @@ If you have performed and stored an extrinsic calibration it will be temporary r If you are using an Ensenso X device you have to calibrate the device before trying to run the PCL driver. If you don't you will get an error like this: .. code-block:: cpp + Initialising nxLib Opening Ensenso stereo camera id = 0 openDevice: NxLib error ExecutionFailed (17) occurred while accessing item /Execute. diff --git a/doc/tutorials/content/global_hypothesis_verification.rst b/doc/tutorials/content/global_hypothesis_verification.rst index aee55182f9d..e0a41121352 100644 --- a/doc/tutorials/content/global_hypothesis_verification.rst +++ b/doc/tutorials/content/global_hypothesis_verification.rst @@ -110,21 +110,21 @@ We create a ``instances`` list to store the "coarse" transformations : .. literalinclude:: sources/global_hypothesis_verification/global_hypothesis_verification.cpp :language: c++ - :lines: 389-399 + :lines: 387-397 then, we run ICP on the ``instances`` wrt. the ``scene`` to obtain the ``registered_instances``: .. literalinclude:: sources/global_hypothesis_verification/global_hypothesis_verification.cpp :language: c++ - :lines: 401-431 + :lines: 399-429 Hypotheses Verification *********************** .. literalinclude:: sources/global_hypothesis_verification/global_hypothesis_verification.cpp :language: c++ - :lines: 433-466 + :lines: 431-465 ``GlobalHypothesesVerification`` takes as input a list of ``registered_instances`` and a ``scene`` so we can ``verify()`` them to get a ``hypotheses_mask``: this is a `bool` array where ``hypotheses_mask[i]`` is ``TRUE`` if ``registered_instances[i]`` is a @@ -142,7 +142,7 @@ Each ``registered_instances[i]`` will be displayed with two optional colors: ``s .. literalinclude:: sources/global_hypothesis_verification/global_hypothesis_verification.cpp :language: c++ - :lines: 468-525 + :lines: 467-524 Compiling and running the program diff --git a/doc/tutorials/content/gpu_install.rst b/doc/tutorials/content/gpu_install.rst index a7beb2fb74f..5b58a5ceb9a 100644 --- a/doc/tutorials/content/gpu_install.rst +++ b/doc/tutorials/content/gpu_install.rst @@ -9,7 +9,7 @@ This tutorial is for Ubuntu, other Linux distrubutions can follow a similar proc Windows is currently **not** officially supported for the GPU methods. Checking CUDA Version ---------------- +--------------------- In order to run the code you will need a system with an Nvidia GPU, having CUDA Toolkit v9.2+ installed. We will not be covering CUDA toolkit installation in this tutorial as there already exists many great tutorials for the same. @@ -20,7 +20,7 @@ You can check your CUDA toolkit version using the following command:: Checking C++ Version ---------------- +-------------------- The GPU methods in PCL require a min version of GCC 7 or Clang 6 onwards (min version unknown). This will not be a problem if you are running Ubuntu 18.04 or later. However on Ubuntu 16.04, you will need to install GCC 7 or Clang 6 (lower versions not tested) manually because the versions available by default are: GCC 5 and Clang 3.8 @@ -46,7 +46,7 @@ $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave $ sudo update-alternatives --config gcc Installing Eigen ---------------- +---------------- You will also need Eigen v3.3.7+, since the previous versions are incompatible with the latest CUDA versions. If you are on Ubuntu 20 or newer, then there is no issue since Eigen 3.3.7 is shipped by default. diff --git a/doc/tutorials/content/index.rst b/doc/tutorials/content/index.rst index f286330a230..a922b33c8cf 100644 --- a/doc/tutorials/content/index.rst +++ b/doc/tutorials/content/index.rst @@ -2,7 +2,7 @@ Introduction ------------ +------------ The following links describe a set of basic PCL tutorials. Please note that their source codes may already be provided as part of the PCL regular releases, diff --git a/doc/tutorials/content/octree.rst b/doc/tutorials/content/octree.rst index f38adfdcd84..fbafcb1b4bc 100644 --- a/doc/tutorials/content/octree.rst +++ b/doc/tutorials/content/octree.rst @@ -22,7 +22,7 @@ The explanation Now, let's explain the code in detail. -We fist define and instantiate a shared PointCloud structure and fill it with random points. +We first define and instantiate a shared PointCloud structure and fill it with random points. .. literalinclude:: sources/octree_search/octree_search.cpp :language: cpp @@ -38,7 +38,7 @@ Then we assign a pointer to the PointCloud and add all points to the octree. :language: cpp :lines: 27-32 -Once the PointCloud is associated with an octree, we can perform search operations. The fist search method used here is "Neighbors within Voxel Search". It assigns the search point to the corresponding +Once the PointCloud is associated with an octree, we can perform search operations. The first search method used here is "Neighbors within Voxel Search". It assigns the search point to the corresponding leaf node voxel and returns a vector of point indices. These indices relate to points which fall within the same voxel. The distance between the search point and the search result depend therefore on the resolution parameter of the octree. diff --git a/doc/tutorials/content/octree_change.rst b/doc/tutorials/content/octree_change.rst index 536627c9808..dc553683d3c 100644 --- a/doc/tutorials/content/octree_change.rst +++ b/doc/tutorials/content/octree_change.rst @@ -23,7 +23,7 @@ The explanation Now, let's discuss the code in detail. -We fist instantiate the OctreePointCloudChangeDetector class and define its voxel resolution. +We first instantiate the OctreePointCloudChangeDetector class and define its voxel resolution. .. literalinclude:: sources/octree_change_detection/octree_change_detection.cpp :language: cpp diff --git a/doc/tutorials/content/tracking.rst b/doc/tutorials/content/tracking.rst index 3c4df9ea8c7..a9ba99d8505 100644 --- a/doc/tutorials/content/tracking.rst +++ b/doc/tutorials/content/tracking.rst @@ -4,7 +4,7 @@ Tracking object in real time ---------------------------- This tutorial explains 6D object tracking and show example code(tracking_sample.cpp) using pcl::tracking libraries. Implementing this example code, you can see the segment track the target object even if you move tracked object or your sensor device. In example, first, you should initialize tracker and you have to pass target object's point cloud to tracker so that tracker should know what to track. So, before this tutorial, you need to make segmented model with PCD file beforehand. Setting the model to tracker, it starts tracking the object. -Following figure shows how looks like when trakcing works successfully. +Following figure shows how looks like when tracking works successfully. .. figure:: images/tracking/mergePicture.png :height: 600 diff --git a/octree/include/pcl/octree/octree2buf_base.h b/octree/include/pcl/octree/octree2buf_base.h index 84d735c3bea..6554e70517b 100644 --- a/octree/include/pcl/octree/octree2buf_base.h +++ b/octree/include/pcl/octree/octree2buf_base.h @@ -984,7 +984,8 @@ class Octree2BufBase { /** \brief Currently active octree buffer **/ unsigned char buffer_selector_; - // flags indicating if unused branches and leafs might exist in previous buffer + /** \brief flags indicating if unused branches and leafs might exist in previous + * buffer **/ bool tree_dirty_flag_; /** \brief Octree depth */ diff --git a/registration/include/pcl/registration/correspondence_estimation_normal_shooting.h b/registration/include/pcl/registration/correspondence_estimation_normal_shooting.h index a4b17bf5697..b73128f3bd3 100644 --- a/registration/include/pcl/registration/correspondence_estimation_normal_shooting.h +++ b/registration/include/pcl/registration/correspondence_estimation_normal_shooting.h @@ -54,8 +54,10 @@ namespace registration { * \code * pcl::PointCloud::Ptr source, target; * // ... read or fill in source and target - * pcl::CorrespondenceEstimationNormalShooting est; est.setInputSource (source); est.setSourceNormals (source); + * pcl::CorrespondenceEstimationNormalShooting + * est; + * est.setInputSource (source); + * est.setSourceNormals (source); * * est.setInputTarget (target); * diff --git a/registration/include/pcl/registration/correspondence_estimation_organized_projection.h b/registration/include/pcl/registration/correspondence_estimation_organized_projection.h index 253adfdb583..4f351fe1e49 100644 --- a/registration/include/pcl/registration/correspondence_estimation_organized_projection.h +++ b/registration/include/pcl/registration/correspondence_estimation_organized_projection.h @@ -54,6 +54,7 @@ namespace registration { * the source) and the target point cloud must be given in the camera coordinate frame. * Any other transformation is specified by the src_to_tgt_transformation_ variable. * \author Alex Ichim + * \ingroup registration */ template class CorrespondenceEstimationOrganizedProjection diff --git a/registration/include/pcl/registration/correspondence_rejection.h b/registration/include/pcl/registration/correspondence_rejection.h index 5e4e586db19..938d2844f10 100644 --- a/registration/include/pcl/registration/correspondence_rejection.h +++ b/registration/include/pcl/registration/correspondence_rejection.h @@ -205,8 +205,8 @@ class CorrespondenceRejector { }; /** @b DataContainerInterface provides a generic interface for computing correspondence - * scores between correspondent points in the input and target clouds \ingroup - * registration + * scores between correspondent points in the input and target clouds + * \ingroup registration */ class DataContainerInterface { public: diff --git a/registration/include/pcl/registration/ia_ransac.h b/registration/include/pcl/registration/ia_ransac.h index bff64bea724..c0ae8812375 100644 --- a/registration/include/pcl/registration/ia_ransac.h +++ b/registration/include/pcl/registration/ia_ransac.h @@ -47,8 +47,8 @@ namespace pcl { /** \brief @b SampleConsensusInitialAlignment is an implementation of the initial * alignment algorithm described in section IV of "Fast Point Feature Histograms (FPFH) - * for 3D Registration," Rusu et al. \author Michael Dixon, Radu B. Rusu \ingroup - * registration + * for 3D Registration," Rusu et al. \author Michael Dixon, Radu B. Rusu + * \ingroup registration */ template class SampleConsensusInitialAlignment : public Registration { diff --git a/registration/include/pcl/registration/icp.h b/registration/include/pcl/registration/icp.h index 6198358fed1..3a3240a10e3 100644 --- a/registration/include/pcl/registration/icp.h +++ b/registration/include/pcl/registration/icp.h @@ -74,7 +74,8 @@ namespace pcl { * icp.setInputTarget (cloud_target); * * // Set the max correspondence distance to 5cm (e.g., correspondences with higher - * distances will be ignored) icp.setMaxCorrespondenceDistance (0.05); + * // distances will be ignored) + * icp.setMaxCorrespondenceDistance (0.05); * // Set the maximum number of iterations (criterion 1) * icp.setMaximumIterations (50); * // Set the transformation epsilon (criterion 2) @@ -269,7 +270,7 @@ class IterativeClosestPoint : public Registration::Ptr icp (new - * IterativeClosestPoint); icp->setMaxCorrespondenceDistance (0.05); + * IterativeClosestPoint::Ptr icp + * (new IterativeClosestPoint); + * icp->setMaxCorrespondenceDistance (0.05); * icp->setMaximumIterations (50); * * IncrementalRegistration iicp; diff --git a/registration/include/pcl/registration/meta_registration.h b/registration/include/pcl/registration/meta_registration.h index ccd85f6aee1..cab4e4c5b14 100644 --- a/registration/include/pcl/registration/meta_registration.h +++ b/registration/include/pcl/registration/meta_registration.h @@ -51,8 +51,9 @@ namespace registration { * will be aligned to the conglomerate of all previous clouds. * * \code - * IterativeClosestPoint::Ptr icp (new - * IterativeClosestPoint); icp->setMaxCorrespondenceDistance (0.05); + * IterativeClosestPoint::Ptr icp + * (new IterativeClosestPoint); + * icp->setMaxCorrespondenceDistance (0.05); * icp->setMaximumIterations (50); * * MetaRegistration mreg; diff --git a/registration/include/pcl/registration/registration.h b/registration/include/pcl/registration/registration.h index 368c553aeaa..ede9bdad9af 100644 --- a/registration/include/pcl/registration/registration.h +++ b/registration/include/pcl/registration/registration.h @@ -144,13 +144,14 @@ class Registration : public PCLBase { * Code example: * * \code - * TransformationEstimationPointToPlaneLLS::Ptr trans_lls (new - * TransformationEstimationPointToPlaneLLS); + * TransformationEstimationPointToPlaneLLS::Ptr trans_lls + * (new TransformationEstimationPointToPlaneLLS); * icp.setTransformationEstimation (trans_lls); * // or... - * TransformationEstimationSVD::Ptr trans_svd (new - * TransformationEstimationSVD); icp.setTransformationEstimation - * (trans_svd); \endcode + * TransformationEstimationSVD::Ptr trans_svd + * (new TransformationEstimationSVD); + * icp.setTransformationEstimation (trans_svd); + * \endcode */ void setTransformationEstimation(const TransformationEstimationPtr& te) @@ -166,13 +167,14 @@ class Registration : public PCLBase { * Code example: * * \code - * CorrespondenceEstimation::Ptr ce (new - * CorrespondenceEstimation); ce->setInputSource (source); + * CorrespondenceEstimation::Ptr + * ce (new CorrespondenceEstimation); + * ce->setInputSource (source); * ce->setInputTarget (target); * icp.setCorrespondenceEstimation (ce); * // or... * CorrespondenceEstimationNormalShooting::Ptr - * cens (new CorrespondenceEstimationNormalShooting); + * cens (new CorrespondenceEstimationNormalShooting); * ce->setInputSource (source); * ce->setInputTarget (target); * ce->setSourceNormals (source); diff --git a/registration/registration.doxy b/registration/registration.doxy index 8b6363ce2b3..eb49a954f94 100644 --- a/registration/registration.doxy +++ b/registration/registration.doxy @@ -12,7 +12,7 @@ position and orientation of the data sets. Once the alignment errors fall below a given threshold, the registration is said to be complete. The pcl_registration library implements a plethora of point cloud -registration algorithms for both organized an unorganized (general purpose) +registration algorithms for both organized and unorganized (general purpose) datasets. \image html http://www.pointclouds.org/assets/images/contents/documentation/registration_outdoor.png diff --git a/segmentation/include/pcl/segmentation/extract_labeled_clusters.h b/segmentation/include/pcl/segmentation/extract_labeled_clusters.h index 5c25ee4b73a..cd9594b6cf4 100644 --- a/segmentation/include/pcl/segmentation/extract_labeled_clusters.h +++ b/segmentation/include/pcl/segmentation/extract_labeled_clusters.h @@ -91,8 +91,8 @@ extractLabeledEuclideanClusters( ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** \brief @b LabeledEuclideanClusterExtraction represents a segmentation class for - * cluster extraction in an Euclidean sense, with label info. \author Koen Buys \ingroup - * segmentation + * cluster extraction in an Euclidean sense, with label info. \author Koen Buys + * \ingroup segmentation */ template class LabeledEuclideanClusterExtraction : public PCLBase { From ca6fdd10b0213d6f8223bec378c128014db189b3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 20 Mar 2021 20:04:11 +0100 Subject: [PATCH 064/431] Remove try-catch in test_octree_compression --- test/io/test_octree_compression.cpp | 119 ++++++++++++---------------- 1 file changed, 49 insertions(+), 70 deletions(-) diff --git a/test/io/test_octree_compression.cpp b/test/io/test_octree_compression.cpp index 73d0736ff84..ca65c61dd22 100644 --- a/test/io/test_octree_compression.cpp +++ b/test/io/test_octree_compression.cpp @@ -65,49 +65,42 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) // iterate over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - try + int point_count; + do { // empty point cloud hangs decoder + point_count = MAX_POINTS * rand() / RAND_MAX; + } while (point_count < 1); + // create shared pointcloud instances + pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); + // assign input point clouds to octree + // create random point cloud + for (int point = 0; point < point_count; point++) { - int point_count; - do { // empty point cloud hangs decoder - point_count = MAX_POINTS * rand() / RAND_MAX; - } while (point_count < 1); - // create shared pointcloud instances - pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); - // assign input point clouds to octree - // create random point cloud - for (int point = 0; point < point_count; point++) - { - // generate a random point - pcl::PointXYZRGBA new_point; - new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), - new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); - // OctreePointCloudPointVector can store all points.. - cloud->push_back(new_point); - } - EXPECT_EQ(cloud->height, 1); + // generate a random point + pcl::PointXYZRGBA new_point; + new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); + new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), + new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); + new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); + new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); + // OctreePointCloudPointVector can store all points.. + cloud->push_back(new_point); + } + EXPECT_EQ(cloud->height, 1); // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; - std::stringstream compressed_data; - pointcloud_encoder.encodePointCloud(cloud, compressed_data); - pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); - if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { - EXPECT_GT(cloud_out->width, 0); - EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; - } - else { - EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; - } - EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; + std::stringstream compressed_data; + pointcloud_encoder.encodePointCloud(cloud, compressed_data); + pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); + if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { + EXPECT_GT(cloud_out->width, 0); + EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; } - catch (std::exception& e) - { - std::cout << e.what() << std::endl; + else { + EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; } + EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; } // runs } // compression profiles } // small clouds, large clouds @@ -147,23 +140,16 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZ) EXPECT_EQ(cloud->height, 1); // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; std::stringstream compressed_data; - try - { // decodePointCloud() throws exceptions on errors - pointcloud_encoder.encodePointCloud(cloud, compressed_data); - pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); - if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { - EXPECT_GT(cloud_out->width, 0); - EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; - } - else { - EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; - } - EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; + pointcloud_encoder.encodePointCloud(cloud, compressed_data); + pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); + if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { + EXPECT_GT(cloud_out->width, 0); + EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; } - catch (std::exception& e) - { - std::cout << e.what() << std::endl; + else { + EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; } + EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; } // runs } // compression profiles } // small clouds, large clouds @@ -209,26 +195,19 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBASameCloud) // iterate over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - try - { // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; - std::stringstream compressed_data; - pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); - pointcloud_encoder.encodePointCloud(cloud, compressed_data); - pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); - if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { - EXPECT_GT(cloud_out->width, 0); - EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; - } - else { - EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; - } - EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; + std::stringstream compressed_data; + pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); + pointcloud_encoder.encodePointCloud(cloud, compressed_data); + pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); + if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { + EXPECT_GT(cloud_out->width, 0); + EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; } - catch (std::exception& e) - { - std::cout << e.what() << std::endl; + else { + EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; } + EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; } // runs } // compression profiles } // TEST From 8bd1213e914bcf9cd0729ed34c0c8351d41d342c Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 21 Mar 2021 11:07:49 +0100 Subject: [PATCH 065/431] Improve test_octree: test search functions also on trees with dynamic depth And remove unused variable cloudOut --- test/octree/test_octree.cpp | 422 +++++++++++++++++++----------------- 1 file changed, 218 insertions(+), 204 deletions(-) diff --git a/test/octree/test_octree.cpp b/test/octree/test_octree.cpp index c0811f996b0..0a4df9e6e3d 100644 --- a/test/octree/test_octree.cpp +++ b/test/octree/test_octree.cpp @@ -1142,80 +1142,84 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search) Indices k_indices_bruteforce; std::vector k_sqr_distances_bruteforce; - for (unsigned int test_id = 0; test_id < test_runs; test_id++) - { - // define a random search point + for (const std::size_t maxObjsPerLeaf: {0, 5}) { + if (maxObjsPerLeaf != 0) + octree.enableDynamicDepth (maxObjsPerLeaf); + for (unsigned int test_id = 0; test_id < test_runs; test_id++) + { + // define a random search point - PointXYZ searchPoint (static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX)); + PointXYZ searchPoint (static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX)); - unsigned int K = 1 + rand () % 10; + unsigned int K = 1 + rand () % 10; - // generate point cloud - cloudIn->width = 1000; - cloudIn->height = 1; - cloudIn->points.resize (cloudIn->width * cloudIn->height); - for (std::size_t i = 0; i < 1000; i++) - { - (*cloudIn)[i] = PointXYZ (static_cast (5.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX)); - } + // generate point cloud + cloudIn->width = 1000; + cloudIn->height = 1; + cloudIn->points.resize (cloudIn->width * cloudIn->height); + for (std::size_t i = 0; i < 1000; i++) + { + (*cloudIn)[i] = PointXYZ (static_cast (5.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX)); + } - k_indices.clear (); - k_sqr_distances.clear (); + k_indices.clear (); + k_sqr_distances.clear (); - k_indices_bruteforce.clear (); - k_sqr_distances_bruteforce.clear (); + k_indices_bruteforce.clear (); + k_sqr_distances_bruteforce.clear (); - // push all points and their distance to the search point into a priority queue - bruteforce approach. - for (std::size_t i = 0; i < cloudIn->size (); i++) - { - double pointDist = (((*cloudIn)[i].x - searchPoint.x) * ((*cloudIn)[i].x - searchPoint.x) + - ((*cloudIn)[i].y - searchPoint.y) * ((*cloudIn)[i].y - searchPoint.y) + - ((*cloudIn)[i].z - searchPoint.z) * ((*cloudIn)[i].z - searchPoint.z)); + // push all points and their distance to the search point into a priority queue - bruteforce approach. + for (std::size_t i = 0; i < cloudIn->size (); i++) + { + double pointDist = (((*cloudIn)[i].x - searchPoint.x) * ((*cloudIn)[i].x - searchPoint.x) + + ((*cloudIn)[i].y - searchPoint.y) * ((*cloudIn)[i].y - searchPoint.y) + + ((*cloudIn)[i].z - searchPoint.z) * ((*cloudIn)[i].z - searchPoint.z)); - prioPointQueueEntry pointEntry ((*cloudIn)[i], pointDist, static_cast (i)); + prioPointQueueEntry pointEntry ((*cloudIn)[i], pointDist, static_cast (i)); - pointCandidates.push (pointEntry); - } + pointCandidates.push (pointEntry); + } - // pop priority queue until we have the nearest K elements - while (pointCandidates.size () > K) - pointCandidates.pop (); + // pop priority queue until we have the nearest K elements + while (pointCandidates.size () > K) + pointCandidates.pop (); - // copy results into vectors - unsigned idx = static_cast (pointCandidates.size ()); - k_indices_bruteforce.resize (idx); - k_sqr_distances_bruteforce.resize (idx); - while (!pointCandidates.empty ()) - { - --idx; - k_indices_bruteforce [idx] = pointCandidates.top ().pointIdx_; - k_sqr_distances_bruteforce [idx] = static_cast (pointCandidates.top ().pointDistance_); + // copy results into vectors + unsigned idx = static_cast (pointCandidates.size ()); + k_indices_bruteforce.resize (idx); + k_sqr_distances_bruteforce.resize (idx); + while (!pointCandidates.empty ()) + { + --idx; + k_indices_bruteforce [idx] = pointCandidates.top ().pointIdx_; + k_sqr_distances_bruteforce [idx] = static_cast (pointCandidates.top ().pointDistance_); - pointCandidates.pop (); - } + pointCandidates.pop (); + } - // octree nearest neighbor search - octree.deleteTree (); - octree.addPointsFromInputCloud (); - octree.nearestKSearch (searchPoint, static_cast (K), k_indices, k_sqr_distances); + // octree nearest neighbor search + octree.deleteTree (); + octree.addPointsFromInputCloud (); + octree.nearestKSearch (searchPoint, static_cast (K), k_indices, k_sqr_distances); - ASSERT_EQ (k_indices_bruteforce.size (), k_indices.size()); + ASSERT_EQ (k_indices_bruteforce.size (), k_indices.size()); - // compare nearest neighbor results of octree with bruteforce search - while (!k_indices_bruteforce.empty ()) - { - ASSERT_EQ (k_indices_bruteforce.back(), k_indices.back ()); - EXPECT_NEAR (k_sqr_distances_bruteforce.back (), k_sqr_distances.back (), 1e-4); + // compare nearest neighbor results of octree with bruteforce search + while (!k_indices_bruteforce.empty ()) + { + ASSERT_EQ (k_indices_bruteforce.back(), k_indices.back ()); + EXPECT_NEAR (k_sqr_distances_bruteforce.back (), k_sqr_distances.back (), 1e-4); - k_indices_bruteforce.pop_back (); - k_indices.pop_back (); + k_indices_bruteforce.pop_back (); + k_indices.pop_back (); - k_sqr_distances_bruteforce.pop_back (); - k_sqr_distances.pop_back (); + k_sqr_distances_bruteforce.pop_back (); + k_sqr_distances.pop_back (); + } } } } @@ -1233,56 +1237,60 @@ TEST (PCL, Octree_Pointcloud_Box_Search) OctreePointCloudSearch octree (1); octree.setInputCloud (cloudIn); - for (unsigned int test_id = 0; test_id < test_runs; test_id++) - { - Indices k_indices; - - // generate point cloud - cloudIn->width = 300; - cloudIn->height = 1; - cloudIn->points.resize (cloudIn->width * cloudIn->height); - for (auto &point : cloudIn->points) + for (const std::size_t maxObjsPerLeaf: {0, 5}) { + if (maxObjsPerLeaf != 0) + octree.enableDynamicDepth (maxObjsPerLeaf); + for (unsigned int test_id = 0; test_id < test_runs; test_id++) { - point = PointXYZ (static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX)); - } + Indices k_indices; + // generate point cloud + cloudIn->width = 300; + cloudIn->height = 1; + cloudIn->points.resize (cloudIn->width * cloudIn->height); + for (auto &point : cloudIn->points) + { + point = PointXYZ (static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX)); + } - // octree points to octree - octree.deleteTree (); - octree.addPointsFromInputCloud (); - - // define a random search area - Eigen::Vector3f lowerBoxCorner (static_cast (4.0 * rand () / RAND_MAX), - static_cast (4.0 * rand () / RAND_MAX), - static_cast (4.0 * rand () / RAND_MAX)); - Eigen::Vector3f upperBoxCorner (static_cast (5.0 + 4.0 * rand () / RAND_MAX), - static_cast (5.0 + 4.0 * rand () / RAND_MAX), - static_cast (5.0 + 4.0 * rand () / RAND_MAX)); + // octree points to octree + octree.deleteTree (); + octree.addPointsFromInputCloud (); - octree.boxSearch (lowerBoxCorner, upperBoxCorner, k_indices); + // define a random search area - // test every point in point cloud - for (std::size_t i = 0; i < 300; i++) - { - bool inBox; - bool idxInResults; - const PointXYZ& pt = (*cloudIn)[i]; + Eigen::Vector3f lowerBoxCorner (static_cast (4.0 * rand () / RAND_MAX), + static_cast (4.0 * rand () / RAND_MAX), + static_cast (4.0 * rand () / RAND_MAX)); + Eigen::Vector3f upperBoxCorner (static_cast (5.0 + 4.0 * rand () / RAND_MAX), + static_cast (5.0 + 4.0 * rand () / RAND_MAX), + static_cast (5.0 + 4.0 * rand () / RAND_MAX)); - inBox = (pt.x >= lowerBoxCorner (0)) && (pt.x <= upperBoxCorner (0)) && - (pt.y >= lowerBoxCorner (1)) && (pt.y <= upperBoxCorner (1)) && - (pt.z >= lowerBoxCorner (2)) && (pt.z <= upperBoxCorner (2)); + octree.boxSearch (lowerBoxCorner, upperBoxCorner, k_indices); - idxInResults = false; - for (std::size_t j = 0; (j < k_indices.size ()) && (!idxInResults); ++j) + // test every point in point cloud + for (std::size_t i = 0; i < cloudIn->size(); i++) { - if (i == static_cast (k_indices[j])) - idxInResults = true; - } + bool inBox; + bool idxInResults; + const PointXYZ& pt = (*cloudIn)[i]; - ASSERT_EQ (idxInResults, inBox); + inBox = (pt.x >= lowerBoxCorner (0)) && (pt.x <= upperBoxCorner (0)) && + (pt.y >= lowerBoxCorner (1)) && (pt.y <= upperBoxCorner (1)) && + (pt.z >= lowerBoxCorner (2)) && (pt.z <= upperBoxCorner (2)); + + idxInResults = false; + for (std::size_t j = 0; (j < k_indices.size ()) && (!idxInResults); ++j) + { + if (i == static_cast (k_indices[j])) + idxInResults = true; + } + + ASSERT_EQ (idxInResults, inBox); + } } } } @@ -1291,74 +1299,78 @@ TEST(PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) { constexpr unsigned int test_runs = 100; - unsigned int bestMatchCount = 0; - - // instantiate point cloud - PointCloud::Ptr cloudIn (new PointCloud ()); - - srand (static_cast (time (nullptr))); + for (const std::size_t maxObjsPerLeaf: {0, 5}) { + unsigned int bestMatchCount = 0; - constexpr double voxelResolution = 0.1; + // instantiate point cloud + PointCloud::Ptr cloudIn (new PointCloud ()); - // create octree - OctreePointCloudSearch octree (voxelResolution); - octree.setInputCloud (cloudIn); + srand (static_cast (time (nullptr))); - for (unsigned int test_id = 0; test_id < test_runs; test_id++) - { - // define a random search point + constexpr double voxelResolution = 0.1; - PointXYZ searchPoint (static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX)); + // create octree + OctreePointCloudSearch octree (voxelResolution); + octree.setInputCloud (cloudIn); + if (maxObjsPerLeaf != 0) + octree.enableDynamicDepth (maxObjsPerLeaf); - // generate point cloud - cloudIn->width = 1000; - cloudIn->height = 1; - cloudIn->points.resize (cloudIn->width * cloudIn->height); - for (std::size_t i = 0; i < 1000; i++) + for (unsigned int test_id = 0; test_id < test_runs; test_id++) { - (*cloudIn)[i] = PointXYZ (static_cast (5.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX)); - } + // define a random search point - // brute force search - double BFdistance = std::numeric_limits::max (); - pcl::index_t BFindex = 0; + PointXYZ searchPoint (static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX)); - for (std::size_t i = 0; i < cloudIn->size (); i++) - { - double pointDist = (((*cloudIn)[i].x - searchPoint.x) * ((*cloudIn)[i].x - searchPoint.x) + - ((*cloudIn)[i].y - searchPoint.y) * ((*cloudIn)[i].y - searchPoint.y) + - ((*cloudIn)[i].z - searchPoint.z) * ((*cloudIn)[i].z - searchPoint.z)); + // generate point cloud + cloudIn->width = 1000; + cloudIn->height = 1; + cloudIn->points.resize (cloudIn->width * cloudIn->height); + for (std::size_t i = 0; i < 1000; i++) + { + (*cloudIn)[i] = PointXYZ (static_cast (5.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX)); + } - if (pointDist < BFdistance) + // brute force search + double BFdistance = std::numeric_limits::max (); + pcl::index_t BFindex = 0; + + for (std::size_t i = 0; i < cloudIn->size (); i++) { - BFindex = static_cast (i); - BFdistance = pointDist; + double pointDist = (((*cloudIn)[i].x - searchPoint.x) * ((*cloudIn)[i].x - searchPoint.x) + + ((*cloudIn)[i].y - searchPoint.y) * ((*cloudIn)[i].y - searchPoint.y) + + ((*cloudIn)[i].z - searchPoint.z) * ((*cloudIn)[i].z - searchPoint.z)); + + if (pointDist < BFdistance) + { + BFindex = static_cast (i); + BFdistance = pointDist; + } + } - } + index_t ANNindex; + float ANNdistance; - index_t ANNindex; - float ANNdistance; + // octree approx. nearest neighbor search + octree.deleteTree (); + octree.addPointsFromInputCloud (); + octree.approxNearestSearch (searchPoint, ANNindex, ANNdistance); - // octree approx. nearest neighbor search - octree.deleteTree (); - octree.addPointsFromInputCloud (); - octree.approxNearestSearch (searchPoint, ANNindex, ANNdistance); + if (BFindex == ANNindex) + { + EXPECT_NEAR (ANNdistance, BFdistance, 1e-4); + bestMatchCount++; + } - if (BFindex == ANNindex) - { - EXPECT_NEAR (ANNdistance, BFdistance, 1e-4); - bestMatchCount++; } + // we should have found the absolute nearest neighbor at least once + ASSERT_GT (bestMatchCount, 0); } - - // we should have found the absolute nearest neighbor at least once - ASSERT_GT (bestMatchCount, 0); } TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) @@ -1367,83 +1379,85 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) // instantiate point clouds PointCloud::Ptr cloudIn (new PointCloud ()); - PointCloud::Ptr cloudOut (new PointCloud ()); srand (static_cast (time (nullptr))); - for (unsigned int test_id = 0; test_id < test_runs; test_id++) - { - // define a random search point - PointXYZ searchPoint (static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX)); - - cloudIn->width = 1000; - cloudIn->height = 1; - cloudIn->points.resize (cloudIn->width * cloudIn->height); - - // generate point cloud data - for (std::size_t i = 0; i < 1000; i++) + for (const std::size_t maxObjsPerLeaf: {0, 5}) { + for (unsigned int test_id = 0; test_id < test_runs; test_id++) { - (*cloudIn)[i] = PointXYZ (static_cast (10.0 * rand () / RAND_MAX), - static_cast (10.0 * rand () / RAND_MAX), - static_cast (5.0 * rand () / RAND_MAX)); - } + // define a random search point + PointXYZ searchPoint (static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX)); - OctreePointCloudSearch octree (0.001); + cloudIn->width = 1000; + cloudIn->height = 1; + cloudIn->points.resize (cloudIn->width * cloudIn->height); - // build octree - octree.setInputCloud (cloudIn); - octree.addPointsFromInputCloud (); + // generate point cloud data + for (std::size_t i = 0; i < 1000; i++) + { + (*cloudIn)[i] = PointXYZ (static_cast (10.0 * rand () / RAND_MAX), + static_cast (10.0 * rand () / RAND_MAX), + static_cast (5.0 * rand () / RAND_MAX)); + } - double pointDist; - double searchRadius = 5.0 * static_cast (rand () / RAND_MAX); + OctreePointCloudSearch octree (0.001); - // bruteforce radius search - std::vector cloudSearchBruteforce; - for (std::size_t i = 0; i < cloudIn->size (); i++) - { - pointDist = sqrt ( - ((*cloudIn)[i].x - searchPoint.x) * ((*cloudIn)[i].x - searchPoint.x) - + ((*cloudIn)[i].y - searchPoint.y) * ((*cloudIn)[i].y - searchPoint.y) - + ((*cloudIn)[i].z - searchPoint.z) * ((*cloudIn)[i].z - searchPoint.z)); + // build octree + octree.setInputCloud (cloudIn); + if (maxObjsPerLeaf != 0) + octree.enableDynamicDepth (maxObjsPerLeaf); + octree.addPointsFromInputCloud (); - if (pointDist <= searchRadius) + double pointDist; + double searchRadius = 5.0 * static_cast (rand () / RAND_MAX); + + // bruteforce radius search + std::vector cloudSearchBruteforce; + for (std::size_t i = 0; i < cloudIn->size (); i++) { - // add point candidates to vector list - cloudSearchBruteforce.push_back (static_cast (i)); + pointDist = sqrt ( + ((*cloudIn)[i].x - searchPoint.x) * ((*cloudIn)[i].x - searchPoint.x) + + ((*cloudIn)[i].y - searchPoint.y) * ((*cloudIn)[i].y - searchPoint.y) + + ((*cloudIn)[i].z - searchPoint.z) * ((*cloudIn)[i].z - searchPoint.z)); + + if (pointDist <= searchRadius) + { + // add point candidates to vector list + cloudSearchBruteforce.push_back (static_cast (i)); + } } - } - Indices cloudNWRSearch; - std::vector cloudNWRRadius; + Indices cloudNWRSearch; + std::vector cloudNWRRadius; - // execute octree radius search - octree.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius); + // execute octree radius search + octree.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius); - ASSERT_EQ (cloudSearchBruteforce.size (), cloudNWRRadius.size ()); + ASSERT_EQ (cloudSearchBruteforce.size (), cloudNWRRadius.size ()); - // check if result from octree radius search can be also found in bruteforce search - auto current = cloudNWRSearch.cbegin (); - while (current != cloudNWRSearch.cend ()) - { - pointDist = sqrt ( - ((*cloudIn)[*current].x - searchPoint.x) * ((*cloudIn)[*current].x - searchPoint.x) - + ((*cloudIn)[*current].y - searchPoint.y) * ((*cloudIn)[*current].y - searchPoint.y) - + ((*cloudIn)[*current].z - searchPoint.z) * ((*cloudIn)[*current].z - searchPoint.z)); + // check if result from octree radius search can be also found in bruteforce search + auto current = cloudNWRSearch.cbegin (); + while (current != cloudNWRSearch.cend ()) + { + pointDist = sqrt ( + ((*cloudIn)[*current].x - searchPoint.x) * ((*cloudIn)[*current].x - searchPoint.x) + + ((*cloudIn)[*current].y - searchPoint.y) * ((*cloudIn)[*current].y - searchPoint.y) + + ((*cloudIn)[*current].z - searchPoint.z) * ((*cloudIn)[*current].z - searchPoint.z)); - ASSERT_LE (pointDist, searchRadius); + ASSERT_LE (pointDist, searchRadius); - ++current; - } + ++current; + } - // check if result limitation works - octree.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); + // check if result limitation works + octree.radiusSearch (searchPoint, searchRadius, cloudNWRSearch, cloudNWRRadius, 5); - ASSERT_LE (cloudNWRRadius.size (), 5); + ASSERT_LE (cloudNWRRadius.size (), 5); + } } - } TEST (PCL, Octree_Pointcloud_Ray_Traversal) From 582da42cdc85d70fa00762686c22479c629b8aad Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 21 Mar 2021 11:09:01 +0100 Subject: [PATCH 066/431] Octree search: check node type before casting This fixes segmentation faults for octrees with dynamic depth when a node was cast to a branch node, but was actually a leaf node. --- octree/include/pcl/octree/impl/octree_search.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index d385e185c70..07ad568c83c 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -277,7 +277,7 @@ OctreePointCloudSearch:: child_node = search_heap.back().node; new_key = search_heap.back().key; - if (tree_depth < this->octree_depth_) { + if (child_node->getNodeType() == BRANCH_NODE) { // we have not reached maximum tree depth smallest_squared_dist = getKNearestNeighborRecursive(point, @@ -373,7 +373,7 @@ OctreePointCloudSearch:: voxel_squared_diameter / 4.0 + radiusSquared + sqrt(voxel_squared_diameter * radiusSquared)) { - if (tree_depth < this->octree_depth_) { + if (child_node->getNodeType() == BRANCH_NODE) { // we have not reached maximum tree depth getNeighborsWithinRadiusRecursive(point, radiusSquared, @@ -468,7 +468,7 @@ OctreePointCloudSearch:: child_node = this->getBranchChildPtr(*node, min_child_idx); - if (tree_depth < this->octree_depth_) { + if (child_node->getNodeType() == BRANCH_NODE) { // we have not reached maximum tree depth approxNearestSearchRecursive(point, static_cast(child_node), @@ -552,7 +552,7 @@ OctreePointCloudSearch::boxSearchRecur (lower_voxel_corner(1) > max_pt(1)) || (min_pt(1) > upper_voxel_corner(1)) || (lower_voxel_corner(2) > max_pt(2)) || (min_pt(2) > upper_voxel_corner(2)))) { - if (tree_depth < this->octree_depth_) { + if (child_node->getNodeType() == BRANCH_NODE) { // we have not reached maximum tree depth boxSearchRecursive(min_pt, max_pt, From 7abcd66865ca2a382d7d8eca0092a9584a7083b1 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 21 Mar 2021 11:09:47 +0100 Subject: [PATCH 067/431] Octree search: use more float instead of double pointSquaredDist returns a float, so it makes no sense to cast it back-and-forth --- octree/include/pcl/octree/impl/octree_search.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/octree/include/pcl/octree/impl/octree_search.hpp b/octree/include/pcl/octree/impl/octree_search.hpp index 07ad568c83c..548b97fc413 100644 --- a/octree/include/pcl/octree/impl/octree_search.hpp +++ b/octree/include/pcl/octree/impl/octree_search.hpp @@ -483,7 +483,7 @@ OctreePointCloudSearch:: const LeafNode* child_leaf = static_cast(child_node); - double smallest_squared_dist = std::numeric_limits::max(); + float smallest_squared_dist = std::numeric_limits::max(); // decode leaf node into decoded_point_vector (**child_leaf).getPointIndices(decoded_point_vector); @@ -493,7 +493,7 @@ OctreePointCloudSearch:: const PointT& candidate_point = this->getPointByIndex(index); // calculate point distance to search point - double squared_dist = pointSquaredDist(candidate_point, point); + float squared_dist = pointSquaredDist(candidate_point, point); // check if a closer match is found if (squared_dist >= smallest_squared_dist) @@ -501,7 +501,7 @@ OctreePointCloudSearch:: result_index = index; smallest_squared_dist = squared_dist; - sqr_distance = static_cast(squared_dist); + sqr_distance = squared_dist; } } } From 2932286548b2e79f7b2ec0fcbf78f25de6df9ed3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 18 Mar 2021 15:15:23 +0100 Subject: [PATCH 068/431] Tracking: pyramidal klt: switch keypoints_status_ from PointIndices to int vector It has nothing to do with indices, the elements of the vector are not and should not be used as indices. Furthermore, the status can be negative (-1, -2). This commit also deprecates a getter-function with a PointIndices return type and adds a replacement. --- apps/src/openni_klt.cpp | 6 +++--- .../pcl/tracking/impl/pyramidal_klt.hpp | 6 +++--- tracking/include/pcl/tracking/pyramidal_klt.h | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index ff17a983fe8..e0adcdcb551 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -251,14 +251,14 @@ class OpenNIViewer { if (tracker_->getInitialized() && cloud_) { if (points_mutex_.try_lock()) { keypoints_ = tracker_->getTrackedPoints(); - points_status_ = tracker_->getPointsToTrackStatus(); + points_status_ = tracker_->getStatusOfPointsToTrack(); points_mutex_.unlock(); } std::vector markers; markers.reserve(keypoints_->size() * 2); for (std::size_t i = 0; i < keypoints_->size(); ++i) { - if (points_status_->indices[i] < 0) + if ((*points_status_)[i] < 0) continue; const pcl::PointUV& uv = (*keypoints_)[i]; markers.push_back(uv.u); @@ -295,7 +295,7 @@ class OpenNIViewer { typename pcl::tracking::PyramidalKLTTracker::Ptr tracker_; pcl::PointCloud::ConstPtr keypoints_; pcl::PointIndicesConstPtr points_; - pcl::PointIndicesConstPtr points_status_; + pcl::shared_ptr> points_status_; int counter_; }; diff --git a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp index dc9bd1474dc..ebee0a184e4 100644 --- a/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp +++ b/tracking/include/pcl/tracking/impl/pyramidal_klt.hpp @@ -69,8 +69,8 @@ PyramidalKLTTracker::setPointsToTrack( keypoints_ = p; } - keypoints_status_.reset(new pcl::PointIndices); - keypoints_status_->indices.resize(keypoints_->size(), 0); + keypoints_status_.reset(new std::vector); + keypoints_status_->resize(keypoints_->size(), 0); } /////////////////////////////////////////////////////////////////////////////////////////////// @@ -723,7 +723,7 @@ PyramidalKLTTracker::computeTracking() ref_ = input_; ref_pyramid_ = pyramid; keypoints_ = keypoints; - keypoints_status_->indices = status; + *keypoints_status_ = status; } } // namespace tracking diff --git a/tracking/include/pcl/tracking/pyramidal_klt.h b/tracking/include/pcl/tracking/pyramidal_klt.h index bdc0e812835..6f8436163e3 100644 --- a/tracking/include/pcl/tracking/pyramidal_klt.h +++ b/tracking/include/pcl/tracking/pyramidal_klt.h @@ -260,8 +260,24 @@ class PyramidalKLTTracker : public Tracker { * Status == -1 --> point is out of bond; * Status == -2 --> optical flow can not be computed for this point. */ + PCL_DEPRECATED(1, 15, "use getStatusOfPointsToTrack instead") inline pcl::PointIndicesConstPtr getPointsToTrackStatus() const + { + pcl::PointIndicesPtr res(new pcl::PointIndices); + res->indices.insert( + res->indices.end(), keypoints_status_->begin(), keypoints_status_->end()); + return (res); + } + + /** \return the status of points to track. + * Status == 0 --> points successfully tracked; + * Status < 0 --> point is lost; + * Status == -1 --> point is out of bond; + * Status == -2 --> optical flow can not be computed for this point. + */ + inline pcl::shared_ptr> + getStatusOfPointsToTrack() const { return (keypoints_status_); } @@ -398,7 +414,7 @@ class PyramidalKLTTracker : public Tracker { /** \brief detected keypoints 2D coordinates */ pcl::PointCloud::ConstPtr keypoints_; /** \brief status of keypoints of t-1 at t */ - pcl::PointIndicesPtr keypoints_status_; + pcl::shared_ptr> keypoints_status_; /** \brief number of points to detect */ std::size_t keypoints_nbr_; /** \brief tracking width */ From 739afc3ac49c4d3a30d417d4edbe3648e6041692 Mon Sep 17 00:00:00 2001 From: Rabah Nouri Date: Wed, 24 Mar 2021 23:16:24 -0400 Subject: [PATCH 069/431] Add unit tests to new functions in PointCloud (#4618) --- test/common/test_common.cpp | 287 ++++++++++++++++++++++++++++++++++-- 1 file changed, 278 insertions(+), 9 deletions(-) diff --git a/test/common/test_common.cpp b/test/common/test_common.cpp index 485675dc2fe..ff78e02a7ca 100644 --- a/test/common/test_common.cpp +++ b/test/common/test_common.cpp @@ -173,17 +173,39 @@ TEST (PCL, Eigen) } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -TEST (PCL, PointCloud) +struct pointCloudTest : public testing::Test { + protected: + // virtual void SetUp() {} + // virtual void Teardown() {} + PointCloud cloud; +}; + +struct pointCloudTestEx : public pointCloudTest { + protected: + void SetUp() override + { + cloud.resize (640, 480, PointXYZ (1, 1, 1)); + } + // void Teardown() override {} +}; + +TEST_F (pointCloudTest, is_organized) { - PointCloud cloud; cloud.width = 640; cloud.height = 480; - EXPECT_TRUE (cloud.isOrganized ()); +} +TEST_F (pointCloudTest, not_organized) +{ + cloud.width = 640; cloud.height = 1; EXPECT_FALSE (cloud.isOrganized ()); +} +TEST_F (pointCloudTest, getMatrixXfMap) +{ + cloud.height = 1; cloud.width = 10; for (std::uint32_t i = 0; i < cloud.width*cloud.height; ++i) { @@ -253,39 +275,286 @@ TEST (PCL, PointCloud) } } #endif +} + +TEST_F (pointCloudTest, clear) +{ + cloud.insert (cloud.end (), PointXYZ (1, 1, 1)); + EXPECT_EQ (cloud.size(), 1); cloud.clear (); EXPECT_EQ (cloud.width, 0); EXPECT_EQ (cloud.height, 0); +} - cloud.width = 640; - cloud.height = 480; - +TEST_F (pointCloudTest, insert) +{ cloud.insert (cloud.end (), PointXYZ (1, 1, 1)); EXPECT_FALSE (cloud.isOrganized ()); EXPECT_EQ (cloud.width, 1); +} +TEST_F (pointCloudTest, insert_with_height) +{ cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 6); + EXPECT_EQ (cloud.width, 5); +} +TEST_F (pointCloudTest, erase_at_position) +{ + cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); cloud.erase (cloud.end () - 1); EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 5); + EXPECT_EQ (cloud.width, 4); +} +TEST_F (pointCloudTest, erase_with_iterator) +{ + cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); cloud.erase (cloud.begin (), cloud.end ()); EXPECT_FALSE (cloud.isOrganized ()); EXPECT_EQ (cloud.width, 0); +} +TEST_F (pointCloudTest, emplace) +{ cloud.emplace (cloud.end (), 1, 1, 1); EXPECT_FALSE (cloud.isOrganized ()); EXPECT_EQ (cloud.width, 1); +} +TEST_F (pointCloudTest, emplace_back) +{ auto& new_point = cloud.emplace_back (1, 1, 1); EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 2); + EXPECT_EQ (cloud.width, 1); EXPECT_EQ (&new_point, &cloud.back ()); } +TEST_F (pointCloudTest, resize_with_count_elements) +{ + cloud.resize (640*360); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, resize_with_new_width_and_height) +{ + cloud.resize (640, 480); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.height, 480); +} + +TEST_F (pointCloudTest, resize_with_initialized_count_elements) +{ + cloud.resize (640*360, PointXYZ (1, 1, 1)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, resize_with_initialized_count_and_new_width_and_height) +{ + cloud.resize (640, 480, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTest, assign_with_copies) +{ + cloud.assign (640*360, PointXYZ (1, 1, 1)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, assign_with_new_width_and_height_copies) +{ + cloud.assign(640, 480, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTest, assign_with_copies_in_range) +{ + std::vector pointVec; + pointVec.resize (640*360, PointXYZ (2, 3, 4)); + cloud.assign (pointVec.begin(), pointVec.end()); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, assign_with_copies_in_range_and_new_width) +{ + std::vector pointVec; + pointVec.resize (640*360, PointXYZ (2, 3, 4)); + cloud.assign (pointVec.begin(), pointVec.end(), 640); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTest, assign_mismatch_size_and_width_height) +{ + std::vector pointVec; + pointVec.resize (640*480, PointXYZ (7, 7, 7)); + cloud.assign (pointVec.begin(), pointVec.end(), 460); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*480); +} + +TEST_F (pointCloudTest, assign_initializer_list) +{ + cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 3); +} + +TEST_F (pointCloudTest, assign_initializer_list_with_new_width) +{ + cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}, 2); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 2); +} + +TEST_F (pointCloudTest, assign_initializer_list_with_unorganized_cloud) +{ + cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}, 6); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 3); +} + +TEST_F (pointCloudTest, push_back_to_unorganized_cloud) +{ + cloud.push_back (PointXYZ (3, 4, 5)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 1); +} + +TEST_F (pointCloudTest, push_back_to_organized_cloud) +{ + cloud.resize (80, 80, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + cloud.push_back (PointXYZ (3, 4, 5)); + EXPECT_EQ (cloud.width, (80*80) + 1); +} + +TEST_F (pointCloudTestEx, transient_push_back) +{ + cloud.transient_push_back (PointXYZ(2, 2, 2)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) + 1); +} + +TEST_F (pointCloudTestEx, transient_emplace_back) +{ + auto& new_pointXYZ = cloud.transient_emplace_back (3, 3, 3); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) + 1); + EXPECT_EQ (&new_pointXYZ, &cloud.back ()); +} + +TEST_F (pointCloudTestEx, transient_insert_one_element) +{ + cloud.transient_insert (cloud.end (), PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.size(), (640*480) + 1); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTestEx, transient_insert_with_n_elements) +{ + cloud.transient_insert (cloud.end (), 10, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.size(), (640*480) + 10); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTestEx, transient_emplace) +{ + cloud.transient_emplace (cloud.end (), 4, 4, 4); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) + 1); +} + +TEST_F (pointCloudTestEx, transient_erase_at_position) +{ + cloud.transient_erase (cloud.end () - 1); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) - 1); +} + +TEST_F (pointCloudTestEx, transient_erase_with_iterator) +{ + cloud.transient_erase (cloud.begin (), cloud.end ()); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), 0); +} + +TEST_F (pointCloudTestEx, unorganized_concatenate) +{ + PointCloud new_unorganized_cloud; + PointCloud::concatenate (new_unorganized_cloud, cloud); + EXPECT_FALSE (new_unorganized_cloud.isOrganized ()); + EXPECT_EQ (new_unorganized_cloud.width, 640*480); +} + +TEST_F (pointCloudTestEx, unorganized_concatenate_with_argument_return) +{ + PointCloud new_unorganized_cloud; + PointCloud::concatenate (new_unorganized_cloud, cloud); + PointCloud unorganized_cloud_out; + PointCloud::concatenate (new_unorganized_cloud, cloud, unorganized_cloud_out); + EXPECT_FALSE (unorganized_cloud_out.isOrganized ()); + EXPECT_EQ (unorganized_cloud_out.width, 640*480*2); +} + +TEST_F (pointCloudTestEx, unorganized_concatenate_with_assignment_return) +{ + PointCloud unorganized_cloud; + PointCloud::concatenate (unorganized_cloud, cloud); + PointCloud unorganized_cloud_out = cloud + unorganized_cloud; + EXPECT_FALSE (unorganized_cloud_out.isOrganized ()); + EXPECT_EQ (unorganized_cloud_out.width, 640*480*2); +} + +TEST_F (pointCloudTestEx, unorganized_concatenate_with_plus_operator) +{ + PointCloud unorganized_cloud; + unorganized_cloud += cloud; + EXPECT_FALSE (unorganized_cloud.isOrganized ()); + EXPECT_EQ (unorganized_cloud.width, 640*480); +} + +TEST_F (pointCloudTestEx, at_with_throw) +{ + PointCloud unorganized_cloud; + unorganized_cloud += cloud; + EXPECT_THROW({unorganized_cloud.at (5, 5);}, UnorganizedPointCloudException); +} + +TEST_F (pointCloudTestEx, at_no_throw) +{ + const auto& point_at = cloud.at (cloud.width - 1, cloud.height - 1); + EXPECT_EQ(&point_at, &cloud.back()); +} + +TEST_F (pointCloudTestEx, organized_concatenate) +{ + PointCloud organized_cloud1 = cloud; + PointCloud organized_cloud2 = cloud; + EXPECT_TRUE (organized_cloud1.isOrganized ()); + EXPECT_TRUE (organized_cloud2.isOrganized ()); + PointCloud organized_cloud_out = organized_cloud1 + organized_cloud2; + std::size_t total_size = organized_cloud1.size() + organized_cloud2.size(); + EXPECT_FALSE (organized_cloud_out.isOrganized ()); + EXPECT_EQ(total_size, 614400); + EXPECT_EQ (organized_cloud_out.width, total_size); +} + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TEST (PCL, PointTypes) { From 7c094f30c2e699349af033dc04a0048272a55bf0 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Thu, 25 Mar 2021 09:00:01 +0530 Subject: [PATCH 070/431] Refactor test_common to have a separate test_pointcloud --- test/common/CMakeLists.txt | 1 + test/common/test_common.cpp | 383 ------------------------------ test/common/test_pointcloud.cpp | 405 ++++++++++++++++++++++++++++++++ 3 files changed, 406 insertions(+), 383 deletions(-) create mode 100644 test/common/test_pointcloud.cpp diff --git a/test/common/CMakeLists.txt b/test/common/CMakeLists.txt index c3c0d1e5a3e..cf349414d72 100644 --- a/test/common/CMakeLists.txt +++ b/test/common/CMakeLists.txt @@ -17,6 +17,7 @@ PCL_ADD_TEST(common_test_wrappers test_wrappers FILES test_wrappers.cpp LINK_WIT PCL_ADD_TEST(common_test_macros test_macros FILES test_macros.cpp LINK_WITH pcl_gtest pcl_common) PCL_ADD_TEST(common_vector_average test_vector_average FILES test_vector_average.cpp LINK_WITH pcl_gtest) PCL_ADD_TEST(common_common test_common FILES test_common.cpp LINK_WITH pcl_gtest pcl_common) +PCL_ADD_TEST(common_pointcloud test_pointcloud FILES test_pointcloud.cpp LINK_WITH pcl_gtest pcl_common) PCL_ADD_TEST(common_parse test_parse FILES test_parse.cpp LINK_WITH pcl_gtest pcl_common) PCL_ADD_TEST(common_geometry test_geometry FILES test_geometry.cpp LINK_WITH pcl_gtest pcl_common) PCL_ADD_TEST(common_copy_point test_copy_point FILES test_copy_point.cpp LINK_WITH pcl_gtest pcl_common) diff --git a/test/common/test_common.cpp b/test/common/test_common.cpp index ff78e02a7ca..964bf2b0984 100644 --- a/test/common/test_common.cpp +++ b/test/common/test_common.cpp @@ -172,389 +172,6 @@ TEST (PCL, Eigen) } -////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -struct pointCloudTest : public testing::Test { - protected: - // virtual void SetUp() {} - // virtual void Teardown() {} - PointCloud cloud; -}; - -struct pointCloudTestEx : public pointCloudTest { - protected: - void SetUp() override - { - cloud.resize (640, 480, PointXYZ (1, 1, 1)); - } - // void Teardown() override {} -}; - -TEST_F (pointCloudTest, is_organized) -{ - cloud.width = 640; - cloud.height = 480; - EXPECT_TRUE (cloud.isOrganized ()); -} - -TEST_F (pointCloudTest, not_organized) -{ - cloud.width = 640; - cloud.height = 1; - EXPECT_FALSE (cloud.isOrganized ()); -} - -TEST_F (pointCloudTest, getMatrixXfMap) -{ - cloud.height = 1; - cloud.width = 10; - for (std::uint32_t i = 0; i < cloud.width*cloud.height; ++i) - { - float j = static_cast (i); - cloud.emplace_back(3.0f * j + 0.0f, 3.0f * j + 1.0f, 3.0f * j + 2.0f); - } - - Eigen::MatrixXf mat_xyz1 = cloud.getMatrixXfMap (); - Eigen::MatrixXf mat_xyz = cloud.getMatrixXfMap (3, 4, 0); - - if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit) - { - EXPECT_EQ (mat_xyz1.cols (), 4); - EXPECT_EQ (mat_xyz1.rows (), cloud.width); - EXPECT_EQ (mat_xyz1 (0, 0), 0); - EXPECT_EQ (mat_xyz1 (cloud.width - 1, 2), 3 * cloud.width - 1); // = 29 - - EXPECT_EQ (mat_xyz.cols (), 3); - EXPECT_EQ (mat_xyz.rows (), cloud.width); - EXPECT_EQ (mat_xyz (0, 0), 0); - EXPECT_EQ (mat_xyz (cloud.width - 1, 2), 3 * cloud.width - 1); // = 29 - } - else - { - EXPECT_EQ (mat_xyz1.cols (), cloud.width); - EXPECT_EQ (mat_xyz1.rows (), 4); - EXPECT_EQ (mat_xyz1 (0, 0), 0); - EXPECT_EQ (mat_xyz1 (2, cloud.width - 1), 3 * cloud.width - 1); // = 29 - - EXPECT_EQ (mat_xyz.cols (), cloud.width); - EXPECT_EQ (mat_xyz.rows (), 3); - EXPECT_EQ (mat_xyz (0, 0), 0); - EXPECT_EQ (mat_xyz (2, cloud.width - 1), 3 * cloud.width - 1); // = 29 - } - -#ifdef NDEBUG - if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit) - { - Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, 1); - EXPECT_EQ (mat_yz.cols (), 2); - EXPECT_EQ (mat_yz.rows (), cloud.width); - EXPECT_EQ (mat_yz (0, 0), 1); - EXPECT_EQ (mat_yz (cloud.width - 1, 1), 3 * cloud.width - 1); - std::uint32_t j = 1; - for (std::uint32_t i = 1; i < cloud.width*cloud.height; i+=4, j+=3) - { - Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, i); - EXPECT_EQ (mat_yz.cols (), 2); - EXPECT_EQ (mat_yz.rows (), cloud.width); - EXPECT_EQ (mat_yz (0, 0), j); - } - } - else - { - Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, 1); - EXPECT_EQ (mat_yz.cols (), cloud.width); - EXPECT_EQ (mat_yz.rows (), 2); - EXPECT_EQ (mat_yz (0, 0), 1); - EXPECT_EQ (mat_yz (1, cloud.width - 1), 3 * cloud.width - 1); - std::uint32_t j = 1; - for (std::uint32_t i = 1; i < cloud.width*cloud.height; i+=4, j+=3) - { - Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, i); - EXPECT_EQ (mat_yz.cols (), cloud.width); - EXPECT_EQ (mat_yz.rows (), 2); - EXPECT_EQ (mat_yz (0, 0), j); - } - } -#endif -} - -TEST_F (pointCloudTest, clear) -{ - cloud.insert (cloud.end (), PointXYZ (1, 1, 1)); - EXPECT_EQ (cloud.size(), 1); - cloud.clear (); - EXPECT_EQ (cloud.width, 0); - EXPECT_EQ (cloud.height, 0); -} - -TEST_F (pointCloudTest, insert) -{ - cloud.insert (cloud.end (), PointXYZ (1, 1, 1)); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 1); -} - -TEST_F (pointCloudTest, insert_with_height) -{ - cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 5); -} - -TEST_F (pointCloudTest, erase_at_position) -{ - cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); - cloud.erase (cloud.end () - 1); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 4); -} - -TEST_F (pointCloudTest, erase_with_iterator) -{ - cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); - cloud.erase (cloud.begin (), cloud.end ()); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 0); -} - -TEST_F (pointCloudTest, emplace) -{ - cloud.emplace (cloud.end (), 1, 1, 1); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 1); -} - -TEST_F (pointCloudTest, emplace_back) -{ - auto& new_point = cloud.emplace_back (1, 1, 1); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 1); - EXPECT_EQ (&new_point, &cloud.back ()); -} - -TEST_F (pointCloudTest, resize_with_count_elements) -{ - cloud.resize (640*360); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640*360); -} - -TEST_F (pointCloudTest, resize_with_new_width_and_height) -{ - cloud.resize (640, 480); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); - EXPECT_EQ (cloud.height, 480); -} - -TEST_F (pointCloudTest, resize_with_initialized_count_elements) -{ - cloud.resize (640*360, PointXYZ (1, 1, 1)); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640*360); -} - -TEST_F (pointCloudTest, resize_with_initialized_count_and_new_width_and_height) -{ - cloud.resize (640, 480, PointXYZ (1, 1, 1)); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); -} - -TEST_F (pointCloudTest, assign_with_copies) -{ - cloud.assign (640*360, PointXYZ (1, 1, 1)); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640*360); -} - -TEST_F (pointCloudTest, assign_with_new_width_and_height_copies) -{ - cloud.assign(640, 480, PointXYZ (1, 1, 1)); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); -} - -TEST_F (pointCloudTest, assign_with_copies_in_range) -{ - std::vector pointVec; - pointVec.resize (640*360, PointXYZ (2, 3, 4)); - cloud.assign (pointVec.begin(), pointVec.end()); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640*360); -} - -TEST_F (pointCloudTest, assign_with_copies_in_range_and_new_width) -{ - std::vector pointVec; - pointVec.resize (640*360, PointXYZ (2, 3, 4)); - cloud.assign (pointVec.begin(), pointVec.end(), 640); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); -} - -TEST_F (pointCloudTest, assign_mismatch_size_and_width_height) -{ - std::vector pointVec; - pointVec.resize (640*480, PointXYZ (7, 7, 7)); - cloud.assign (pointVec.begin(), pointVec.end(), 460); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640*480); -} - -TEST_F (pointCloudTest, assign_initializer_list) -{ - cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 3); -} - -TEST_F (pointCloudTest, assign_initializer_list_with_new_width) -{ - cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}, 2); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 2); -} - -TEST_F (pointCloudTest, assign_initializer_list_with_unorganized_cloud) -{ - cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}, 6); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 3); -} - -TEST_F (pointCloudTest, push_back_to_unorganized_cloud) -{ - cloud.push_back (PointXYZ (3, 4, 5)); - EXPECT_FALSE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 1); -} - -TEST_F (pointCloudTest, push_back_to_organized_cloud) -{ - cloud.resize (80, 80, PointXYZ (1, 1, 1)); - EXPECT_TRUE (cloud.isOrganized ()); - cloud.push_back (PointXYZ (3, 4, 5)); - EXPECT_EQ (cloud.width, (80*80) + 1); -} - -TEST_F (pointCloudTestEx, transient_push_back) -{ - cloud.transient_push_back (PointXYZ(2, 2, 2)); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); - EXPECT_EQ (cloud.size(), (640*480) + 1); -} - -TEST_F (pointCloudTestEx, transient_emplace_back) -{ - auto& new_pointXYZ = cloud.transient_emplace_back (3, 3, 3); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); - EXPECT_EQ (cloud.size(), (640*480) + 1); - EXPECT_EQ (&new_pointXYZ, &cloud.back ()); -} - -TEST_F (pointCloudTestEx, transient_insert_one_element) -{ - cloud.transient_insert (cloud.end (), PointXYZ (1, 1, 1)); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.size(), (640*480) + 1); - EXPECT_EQ (cloud.width, 640); -} - -TEST_F (pointCloudTestEx, transient_insert_with_n_elements) -{ - cloud.transient_insert (cloud.end (), 10, PointXYZ (1, 1, 1)); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.size(), (640*480) + 10); - EXPECT_EQ (cloud.width, 640); -} - -TEST_F (pointCloudTestEx, transient_emplace) -{ - cloud.transient_emplace (cloud.end (), 4, 4, 4); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); - EXPECT_EQ (cloud.size(), (640*480) + 1); -} - -TEST_F (pointCloudTestEx, transient_erase_at_position) -{ - cloud.transient_erase (cloud.end () - 1); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); - EXPECT_EQ (cloud.size(), (640*480) - 1); -} - -TEST_F (pointCloudTestEx, transient_erase_with_iterator) -{ - cloud.transient_erase (cloud.begin (), cloud.end ()); - EXPECT_TRUE (cloud.isOrganized ()); - EXPECT_EQ (cloud.width, 640); - EXPECT_EQ (cloud.size(), 0); -} - -TEST_F (pointCloudTestEx, unorganized_concatenate) -{ - PointCloud new_unorganized_cloud; - PointCloud::concatenate (new_unorganized_cloud, cloud); - EXPECT_FALSE (new_unorganized_cloud.isOrganized ()); - EXPECT_EQ (new_unorganized_cloud.width, 640*480); -} - -TEST_F (pointCloudTestEx, unorganized_concatenate_with_argument_return) -{ - PointCloud new_unorganized_cloud; - PointCloud::concatenate (new_unorganized_cloud, cloud); - PointCloud unorganized_cloud_out; - PointCloud::concatenate (new_unorganized_cloud, cloud, unorganized_cloud_out); - EXPECT_FALSE (unorganized_cloud_out.isOrganized ()); - EXPECT_EQ (unorganized_cloud_out.width, 640*480*2); -} - -TEST_F (pointCloudTestEx, unorganized_concatenate_with_assignment_return) -{ - PointCloud unorganized_cloud; - PointCloud::concatenate (unorganized_cloud, cloud); - PointCloud unorganized_cloud_out = cloud + unorganized_cloud; - EXPECT_FALSE (unorganized_cloud_out.isOrganized ()); - EXPECT_EQ (unorganized_cloud_out.width, 640*480*2); -} - -TEST_F (pointCloudTestEx, unorganized_concatenate_with_plus_operator) -{ - PointCloud unorganized_cloud; - unorganized_cloud += cloud; - EXPECT_FALSE (unorganized_cloud.isOrganized ()); - EXPECT_EQ (unorganized_cloud.width, 640*480); -} - -TEST_F (pointCloudTestEx, at_with_throw) -{ - PointCloud unorganized_cloud; - unorganized_cloud += cloud; - EXPECT_THROW({unorganized_cloud.at (5, 5);}, UnorganizedPointCloudException); -} - -TEST_F (pointCloudTestEx, at_no_throw) -{ - const auto& point_at = cloud.at (cloud.width - 1, cloud.height - 1); - EXPECT_EQ(&point_at, &cloud.back()); -} - -TEST_F (pointCloudTestEx, organized_concatenate) -{ - PointCloud organized_cloud1 = cloud; - PointCloud organized_cloud2 = cloud; - EXPECT_TRUE (organized_cloud1.isOrganized ()); - EXPECT_TRUE (organized_cloud2.isOrganized ()); - PointCloud organized_cloud_out = organized_cloud1 + organized_cloud2; - std::size_t total_size = organized_cloud1.size() + organized_cloud2.size(); - EXPECT_FALSE (organized_cloud_out.isOrganized ()); - EXPECT_EQ(total_size, 614400); - EXPECT_EQ (organized_cloud_out.width, total_size); -} - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TEST (PCL, PointTypes) { diff --git a/test/common/test_pointcloud.cpp b/test/common/test_pointcloud.cpp new file mode 100644 index 00000000000..2e43620bfa8 --- /dev/null +++ b/test/common/test_pointcloud.cpp @@ -0,0 +1,405 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2021-, Open Perception + * + * All rights reserved + */ + +#include +#include +#include +#include + +using namespace pcl; + +////////////////////////////////////////////// +struct pointCloudTest : public testing::Test { + protected: + PointCloud cloud; +}; + +TEST_F (pointCloudTest, is_organized) +{ + cloud.width = 640; + cloud.height = 480; + EXPECT_TRUE (cloud.isOrganized ()); +} + +TEST_F (pointCloudTest, not_organized) +{ + cloud.width = 640; + cloud.height = 1; + EXPECT_FALSE (cloud.isOrganized ()); +} + +TEST_F (pointCloudTest, getMatrixXfMap) +{ + cloud.height = 1; + cloud.width = 10; + for (std::uint32_t i = 0; i < cloud.width*cloud.height; ++i) + { + float j = static_cast (i); + cloud.emplace_back(3.0f * j + 0.0f, 3.0f * j + 1.0f, 3.0f * j + 2.0f); + } + + Eigen::MatrixXf mat_xyz1 = cloud.getMatrixXfMap (); + Eigen::MatrixXf mat_xyz = cloud.getMatrixXfMap (3, 4, 0); + + if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit) + { + EXPECT_EQ (mat_xyz1.cols (), 4); + EXPECT_EQ (mat_xyz1.rows (), cloud.width); + EXPECT_EQ (mat_xyz1 (0, 0), 0); + EXPECT_EQ (mat_xyz1 (cloud.width - 1, 2), 3 * cloud.width - 1); // = 29 + + EXPECT_EQ (mat_xyz.cols (), 3); + EXPECT_EQ (mat_xyz.rows (), cloud.width); + EXPECT_EQ (mat_xyz (0, 0), 0); + EXPECT_EQ (mat_xyz (cloud.width - 1, 2), 3 * cloud.width - 1); // = 29 + } + else + { + EXPECT_EQ (mat_xyz1.cols (), cloud.width); + EXPECT_EQ (mat_xyz1.rows (), 4); + EXPECT_EQ (mat_xyz1 (0, 0), 0); + EXPECT_EQ (mat_xyz1 (2, cloud.width - 1), 3 * cloud.width - 1); // = 29 + + EXPECT_EQ (mat_xyz.cols (), cloud.width); + EXPECT_EQ (mat_xyz.rows (), 3); + EXPECT_EQ (mat_xyz (0, 0), 0); + EXPECT_EQ (mat_xyz (2, cloud.width - 1), 3 * cloud.width - 1); // = 29 + } + +#ifdef NDEBUG + if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit) + { + Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, 1); + EXPECT_EQ (mat_yz.cols (), 2); + EXPECT_EQ (mat_yz.rows (), cloud.width); + EXPECT_EQ (mat_yz (0, 0), 1); + EXPECT_EQ (mat_yz (cloud.width - 1, 1), 3 * cloud.width - 1); + std::uint32_t j = 1; + for (std::uint32_t i = 1; i < cloud.width*cloud.height; i+=4, j+=3) + { + Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, i); + EXPECT_EQ (mat_yz.cols (), 2); + EXPECT_EQ (mat_yz.rows (), cloud.width); + EXPECT_EQ (mat_yz (0, 0), j); + } + } + else + { + Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, 1); + EXPECT_EQ (mat_yz.cols (), cloud.width); + EXPECT_EQ (mat_yz.rows (), 2); + EXPECT_EQ (mat_yz (0, 0), 1); + EXPECT_EQ (mat_yz (1, cloud.width - 1), 3 * cloud.width - 1); + std::uint32_t j = 1; + for (std::uint32_t i = 1; i < cloud.width*cloud.height; i+=4, j+=3) + { + Eigen::MatrixXf mat_yz = cloud.getMatrixXfMap (2, 4, i); + EXPECT_EQ (mat_yz.cols (), cloud.width); + EXPECT_EQ (mat_yz.rows (), 2); + EXPECT_EQ (mat_yz (0, 0), j); + } + } +#endif +} + +TEST_F (pointCloudTest, clear) +{ + cloud.insert (cloud.end (), PointXYZ (1, 1, 1)); + EXPECT_EQ (cloud.size(), 1); + cloud.clear (); + EXPECT_EQ (cloud.width, 0); + EXPECT_EQ (cloud.height, 0); +} + +TEST_F (pointCloudTest, insert) +{ + cloud.insert (cloud.end (), PointXYZ (1, 1, 1)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 1); +} + +TEST_F (pointCloudTest, insert_with_height) +{ + cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 5); +} + +TEST_F (pointCloudTest, erase_at_position) +{ + cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); + cloud.erase (cloud.end () - 1); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 4); +} + +TEST_F (pointCloudTest, erase_with_iterator) +{ + cloud.insert (cloud.end (), 5, PointXYZ (1, 1, 1)); + cloud.erase (cloud.begin (), cloud.end ()); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 0); +} + +TEST_F (pointCloudTest, emplace) +{ + cloud.emplace (cloud.end (), 1, 1, 1); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 1); +} + +TEST_F (pointCloudTest, emplace_back) +{ + auto& new_point = cloud.emplace_back (1, 1, 1); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 1); + EXPECT_EQ (&new_point, &cloud.back ()); +} + +TEST_F (pointCloudTest, resize_with_count_elements) +{ + cloud.resize (640*360); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, resize_with_new_width_and_height) +{ + cloud.resize (640, 480); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.height, 480); +} + +TEST_F (pointCloudTest, resize_with_initialized_count_elements) +{ + cloud.resize (640*360, PointXYZ (1, 1, 1)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, resize_with_initialized_count_and_new_width_and_height) +{ + cloud.resize (640, 480, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTest, assign_with_copies) +{ + cloud.assign (640*360, PointXYZ (1, 1, 1)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, assign_with_new_width_and_height_copies) +{ + cloud.assign(640, 480, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTest, assign_with_copies_in_range) +{ + std::vector pointVec; + pointVec.resize (640*360, PointXYZ (2, 3, 4)); + cloud.assign (pointVec.begin(), pointVec.end()); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*360); +} + +TEST_F (pointCloudTest, assign_with_copies_in_range_and_new_width) +{ + std::vector pointVec; + pointVec.resize (640*360, PointXYZ (2, 3, 4)); + cloud.assign (pointVec.begin(), pointVec.end(), 640); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (pointCloudTest, assign_mismatch_size_and_width_height) +{ + std::vector pointVec; + pointVec.resize (640*480, PointXYZ (7, 7, 7)); + cloud.assign (pointVec.begin(), pointVec.end(), 460); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640*480); +} + +TEST_F (pointCloudTest, assign_initializer_list) +{ + cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 3); +} + +TEST_F (pointCloudTest, assign_initializer_list_with_new_width) +{ + cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}, 2); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 2); +} + +TEST_F (pointCloudTest, assign_initializer_list_with_unorganized_cloud) +{ + cloud.assign ({PointXYZ (3, 4, 5), PointXYZ (3, 4, 5), PointXYZ (3, 4, 5)}, 6); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 3); +} + +TEST_F (pointCloudTest, push_back_to_unorganized_cloud) +{ + cloud.push_back (PointXYZ (3, 4, 5)); + EXPECT_FALSE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 1); +} + +TEST_F (pointCloudTest, push_back_to_organized_cloud) +{ + cloud.resize (80, 80, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + cloud.push_back (PointXYZ (3, 4, 5)); + EXPECT_EQ (cloud.width, (80*80) + 1); +} + +///////////////////////////////////////////////// +struct organizedPointCloudTest : public pointCloudTest { + protected: + void SetUp() override + { + cloud.resize (640, 480, PointXYZ (1, 1, 1)); + } +}; + +TEST_F (organizedPointCloudTest, transient_push_back) +{ + cloud.transient_push_back (PointXYZ(2, 2, 2)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) + 1); +} + +TEST_F (organizedPointCloudTest, transient_emplace_back) +{ + auto& new_pointXYZ = cloud.transient_emplace_back (3, 3, 3); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) + 1); + EXPECT_EQ (&new_pointXYZ, &cloud.back ()); +} + +TEST_F (organizedPointCloudTest, transient_insert_one_element) +{ + cloud.transient_insert (cloud.end (), PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.size(), (640*480) + 1); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (organizedPointCloudTest, transient_insert_with_n_elements) +{ + cloud.transient_insert (cloud.end (), 10, PointXYZ (1, 1, 1)); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.size(), (640*480) + 10); + EXPECT_EQ (cloud.width, 640); +} + +TEST_F (organizedPointCloudTest, transient_emplace) +{ + cloud.transient_emplace (cloud.end (), 4, 4, 4); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) + 1); +} + +TEST_F (organizedPointCloudTest, transient_erase_at_position) +{ + cloud.transient_erase (cloud.end () - 1); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), (640*480) - 1); +} + +TEST_F (organizedPointCloudTest, transient_erase_with_iterator) +{ + cloud.transient_erase (cloud.begin (), cloud.end ()); + EXPECT_TRUE (cloud.isOrganized ()); + EXPECT_EQ (cloud.width, 640); + EXPECT_EQ (cloud.size(), 0); +} + +TEST_F (organizedPointCloudTest, unorganized_concatenate) +{ + PointCloud new_unorganized_cloud; + PointCloud::concatenate (new_unorganized_cloud, cloud); + EXPECT_FALSE (new_unorganized_cloud.isOrganized ()); + EXPECT_EQ (new_unorganized_cloud.width, 640*480); +} + +TEST_F (organizedPointCloudTest, unorganized_concatenate_with_argument_return) +{ + PointCloud new_unorganized_cloud; + PointCloud::concatenate (new_unorganized_cloud, cloud); + PointCloud unorganized_cloud_out; + PointCloud::concatenate (new_unorganized_cloud, cloud, unorganized_cloud_out); + EXPECT_FALSE (unorganized_cloud_out.isOrganized ()); + EXPECT_EQ (unorganized_cloud_out.width, 640*480*2); +} + +TEST_F (organizedPointCloudTest, unorganized_concatenate_with_assignment_return) +{ + PointCloud unorganized_cloud; + PointCloud::concatenate (unorganized_cloud, cloud); + PointCloud unorganized_cloud_out = cloud + unorganized_cloud; + EXPECT_FALSE (unorganized_cloud_out.isOrganized ()); + EXPECT_EQ (unorganized_cloud_out.width, 640*480*2); +} + +TEST_F (organizedPointCloudTest, unorganized_concatenate_with_plus_operator) +{ + PointCloud unorganized_cloud; + unorganized_cloud += cloud; + EXPECT_FALSE (unorganized_cloud.isOrganized ()); + EXPECT_EQ (unorganized_cloud.width, 640*480); +} + +TEST_F (organizedPointCloudTest, at_with_throw) +{ + PointCloud unorganized_cloud; + unorganized_cloud += cloud; + EXPECT_THROW({unorganized_cloud.at (5, 5);}, UnorganizedPointCloudException); +} + +TEST_F (organizedPointCloudTest, at_no_throw) +{ + const auto& point_at = cloud.at (cloud.width - 1, cloud.height - 1); + EXPECT_EQ(&point_at, &cloud.back()); +} + +TEST_F (organizedPointCloudTest, organized_concatenate) +{ + PointCloud organized_cloud1 = cloud; + PointCloud organized_cloud2 = cloud; + EXPECT_TRUE (organized_cloud1.isOrganized ()); + EXPECT_TRUE (organized_cloud2.isOrganized ()); + PointCloud organized_cloud_out = organized_cloud1 + organized_cloud2; + std::size_t total_size = organized_cloud1.size() + organized_cloud2.size(); + EXPECT_FALSE (organized_cloud_out.isOrganized ()); + EXPECT_EQ(total_size, 614400); + EXPECT_EQ (organized_cloud_out.width, total_size); +} + +/* ---[ */ +int +main (int argc, char** argv) +{ + testing::InitGoogleTest (&argc, argv); + return (RUN_ALL_TESTS ()); +} +/* ]--- */ From 91a9fbb656c16958f612c6a08f9442edabd79e0d Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Thu, 25 Mar 2021 14:48:24 +0530 Subject: [PATCH 071/431] Fix the output by adding a newline to PCL_WARN --- common/include/pcl/point_cloud.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/include/pcl/point_cloud.h b/common/include/pcl/point_cloud.h index 905a1647c68..11d856f0eec 100644 --- a/common/include/pcl/point_cloud.h +++ b/common/include/pcl/point_cloud.h @@ -591,7 +591,7 @@ namespace pcl height = size() / width; if (width * height != size()) { PCL_WARN("Mismatch in assignment. Requested width (%zu) doesn't divide " - "provided size (%zu) cleanly. Setting height to 1", + "provided size (%zu) cleanly. Setting height to 1\n", static_cast(width), static_cast(size())); width = size(); @@ -626,7 +626,7 @@ namespace pcl height = size() / width; if (width * height != size()) { PCL_WARN("Mismatch in assignment. Requested width (%zu) doesn't divide " - "provided size (%zu) cleanly. Setting height to 1", + "provided size (%zu) cleanly. Setting height to 1\n", static_cast(width), static_cast(size())); width = size(); From 48f084181e7be97885fdb82e18c8bf3f60c53ed9 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 18 Mar 2021 15:08:21 +0100 Subject: [PATCH 072/431] Use more pcl::Indices (mainly in registration) --- .../feature_wrapper/local/local_estimator.h | 4 +- apps/src/ni_linemod.cpp | 4 +- filters/src/passthrough.cpp | 19 +++--- .../include/pcl/recognition/impl/hv/hv_go.hpp | 2 +- .../correspondence_rejection_poly.h | 4 +- .../pcl/registration/correspondence_types.h | 4 +- .../include/pcl/registration/ia_fpcs.h | 28 ++++----- .../include/pcl/registration/ia_kfpcs.h | 4 +- .../include/pcl/registration/ia_ransac.h | 12 ++-- ...respondence_estimation_normal_shooting.hpp | 6 +- .../impl/correspondence_types.hpp | 4 +- .../include/pcl/registration/impl/ia_fpcs.hpp | 58 +++++++++---------- .../pcl/registration/impl/ia_kfpcs.hpp | 8 +-- .../pcl/registration/impl/ia_ransac.hpp | 24 ++++---- .../include/pcl/registration/impl/ndt.hpp | 2 +- .../registration/impl/ppf_registration.hpp | 2 +- .../impl/sample_consensus_prerejective.hpp | 20 +++---- .../impl/transformation_estimation_2D.hpp | 6 +- .../impl/transformation_estimation_3point.hpp | 6 +- .../impl/transformation_estimation_dq.hpp | 6 +- ...nsformation_estimation_dual_quaternion.hpp | 6 +- .../impl/transformation_estimation_lm.hpp | 16 ++--- ...ormation_estimation_point_to_plane_lls.hpp | 6 +- .../impl/transformation_estimation_svd.hpp | 6 +- ...stimation_symmetric_point_to_plane_lls.hpp | 6 +- .../include/pcl/registration/registration.h | 6 +- .../sample_consensus_prerejective.h | 14 ++--- .../registration/transformation_estimation.h | 6 +- .../transformation_estimation_2D.h | 6 +- .../transformation_estimation_3point.h | 6 +- .../transformation_estimation_dq.h | 6 +- ...ransformation_estimation_dual_quaternion.h | 6 +- .../transformation_estimation_lm.h | 10 ++-- ...sformation_estimation_point_to_plane_lls.h | 6 +- .../transformation_estimation_svd.h | 6 +- ..._estimation_symmetric_point_to_plane_lls.h | 6 +- .../correspondence_rejection_one_to_one.cpp | 3 +- .../impl/grabcut_segmentation.hpp | 2 +- 38 files changed, 175 insertions(+), 171 deletions(-) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h index 328aee83853..c37229b958a 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/local/local_estimator.h @@ -77,7 +77,7 @@ class UniformSamplingExtractor : public KeypointExtractor { using KeypointExtractor::input_; using KeypointExtractor::radius_; float sampling_density_; - std::shared_ptr>> neighborhood_indices_; + std::shared_ptr> neighborhood_indices_; std::shared_ptr>> neighborhood_dist_; void @@ -92,7 +92,7 @@ class UniformSamplingExtractor : public KeypointExtractor { tree.reset(new pcl::search::KdTree(false)); tree->setInputCloud(input); - neighborhood_indices_.reset(new std::vector>); + neighborhood_indices_.reset(new std::vector); neighborhood_indices_->resize(keypoints_cloud->size()); neighborhood_dist_.reset(new std::vector>); neighborhood_dist_->resize(keypoints_cloud->size()); diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index 54473f9794d..b4e04aa385d 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -208,7 +208,7 @@ class NILinemod { * \param[out] object the segmented resultant object */ void - segmentObject(int picked_idx, + segmentObject(pcl::index_t picked_idx, const CloudConstPtr& cloud, const PointIndices::Ptr& plane_indices, const PointIndices::Ptr& plane_boundary_indices, @@ -293,7 +293,7 @@ class NILinemod { ///////////////////////////////////////////////////////////////////////// void segment(const PointT& picked_point, - int picked_idx, + pcl::index_t picked_idx, PlanarRegion& region, PointIndices&, CloudPtr& object) diff --git a/filters/src/passthrough.cpp b/filters/src/passthrough.cpp index 00ecf579eb6..77964e9fcca 100644 --- a/filters/src/passthrough.cpp +++ b/filters/src/passthrough.cpp @@ -297,8 +297,11 @@ pcl::PassThrough::applyFilter (Indices &indices) indices.resize (indices_->size ()); removed_indices_->resize (indices_->size ()); int oii = 0, rii = 0; // oii = output indices iterator, rii = removed indices iterator - const std::uint32_t xyz_offset[3] = {input_->fields[x_idx_].offset, input_->fields[y_idx_].offset, input_->fields[z_idx_].offset}; - PCL_DEBUG ("[pcl::%s::applyFilter] Field offsets: x: %u, y: %u, z: %u.\n", filter_name_.c_str (), xyz_offset[0], xyz_offset[1], xyz_offset[2]); + const auto x_offset = input_->fields[x_idx_].offset, + y_offset = input_->fields[y_idx_].offset, + z_offset = input_->fields[z_idx_].offset; + PCL_DEBUG ("[pcl::%s::applyFilter] Field offsets: x: %zu, y: %zu, z: %zu.\n", filter_name_.c_str (), + static_cast(x_offset), static_cast(y_offset), static_cast(z_offset)); // Has a field name been specified? if (filter_field_name_.empty ()) @@ -307,9 +310,9 @@ pcl::PassThrough::applyFilter (Indices &indices) for (const auto ii : indices) // ii = input index { float pt[3]; - memcpy (&pt[0], &input_->data[ii * input_->point_step + xyz_offset[0]], sizeof(float)); - memcpy (&pt[1], &input_->data[ii * input_->point_step + xyz_offset[1]], sizeof(float)); - memcpy (&pt[2], &input_->data[ii * input_->point_step + xyz_offset[2]], sizeof(float)); + memcpy (&pt[0], &input_->data[ii * input_->point_step + x_offset], sizeof(float)); + memcpy (&pt[1], &input_->data[ii * input_->point_step + y_offset], sizeof(float)); + memcpy (&pt[2], &input_->data[ii * input_->point_step + z_offset], sizeof(float)); // Non-finite entries are always passed to removed indices if (!std::isfinite (pt[0]) || !std::isfinite (pt[1]) || @@ -338,9 +341,9 @@ pcl::PassThrough::applyFilter (Indices &indices) for (const auto ii : indices) // ii = input index { float pt[3]; - memcpy (&pt[0], &input_->data[ii * input_->point_step + xyz_offset[0]], sizeof(float)); - memcpy (&pt[1], &input_->data[ii * input_->point_step + xyz_offset[1]], sizeof(float)); - memcpy (&pt[2], &input_->data[ii * input_->point_step + xyz_offset[2]], sizeof(float)); + memcpy (&pt[0], &input_->data[ii * input_->point_step + x_offset], sizeof(float)); + memcpy (&pt[1], &input_->data[ii * input_->point_step + y_offset], sizeof(float)); + memcpy (&pt[2], &input_->data[ii * input_->point_step + z_offset], sizeof(float)); // Non-finite entries are always passed to removed indices if (!std::isfinite (pt[0]) || !std::isfinite (pt[1]) || diff --git a/recognition/include/pcl/recognition/impl/hv/hv_go.hpp b/recognition/include/pcl/recognition/impl/hv/hv_go.hpp index 0d3e4a6a164..70a7222c342 100644 --- a/recognition/include/pcl/recognition/impl/hv/hv_go.hpp +++ b/recognition/include/pcl/recognition/impl/hv/hv_go.hpp @@ -65,7 +65,7 @@ inline void extractEuclideanClustersSmooth(const typename pcl::PointCloud processed (cloud.size (), false); - std::vector nn_indices; + pcl::Indices nn_indices; std::vector nn_distances; // Process all points in the indices vector int size = static_cast (cloud.size ()); diff --git a/registration/include/pcl/registration/correspondence_rejection_poly.h b/registration/include/pcl/registration/correspondence_rejection_poly.h index 4c6e7eb5e30..8f4f8007a60 100644 --- a/registration/include/pcl/registration/correspondence_rejection_poly.h +++ b/registration/include/pcl/registration/correspondence_rejection_poly.h @@ -240,8 +240,8 @@ class PCL_EXPORTS CorrespondenceRejectorPoly : public CorrespondenceRejector { * all edge length ratios are larger than or equal to \ref similarity_threshold_ */ inline bool - thresholdPolygon(const std::vector& source_indices, - const std::vector& target_indices) + thresholdPolygon(const pcl::Indices& source_indices, + const pcl::Indices& target_indices) { // Convert indices to correspondences and an index vector pointing to each element pcl::Correspondences corr(cardinality_); diff --git a/registration/include/pcl/registration/correspondence_types.h b/registration/include/pcl/registration/correspondence_types.h index ee8c75bb5c8..895a23e3b6b 100644 --- a/registration/include/pcl/registration/correspondence_types.h +++ b/registration/include/pcl/registration/correspondence_types.h @@ -61,7 +61,7 @@ getCorDistMeanStd(const pcl::Correspondences& correspondences, * \note order of indices corresponds to input list of descriptor correspondences */ inline void -getQueryIndices(const pcl::Correspondences& correspondences, std::vector& indices); +getQueryIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices); /** \brief extracts the match indices * \param[in] correspondences list of correspondences @@ -69,7 +69,7 @@ getQueryIndices(const pcl::Correspondences& correspondences, std::vector& i * \note order of indices corresponds to input list of descriptor correspondences */ inline void -getMatchIndices(const pcl::Correspondences& correspondences, std::vector& indices); +getMatchIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices); } // namespace registration } // namespace pcl diff --git a/registration/include/pcl/registration/ia_fpcs.h b/registration/include/pcl/registration/ia_fpcs.h index 3c84e0e601f..171a98d7c48 100644 --- a/registration/include/pcl/registration/ia_fpcs.h +++ b/registration/include/pcl/registration/ia_fpcs.h @@ -64,7 +64,7 @@ getMeanPointDensity(const typename pcl::PointCloud::ConstPtr& cloud, template inline float getMeanPointDensity(const typename pcl::PointCloud::ConstPtr& cloud, - const std::vector& indices, + const pcl::Indices& indices, float max_dist, int nr_threads = 1); @@ -318,7 +318,7 @@ class FPCSInitialAlignment : public Registration& base_indices, float (&ratio)[2]); + selectBase(pcl::Indices& base_indices, float (&ratio)[2]); /** \brief Select randomly a triplet of points with large point-to-point distances. * The minimum point sampling distance is calculated based on the estimated point @@ -330,7 +330,7 @@ class FPCSInitialAlignment : public Registration& base_indices); + selectBaseTriangle(pcl::Indices& base_indices); /** \brief Setup the base (four coplanar points) by ordering the points and computing * intersection ratios and segment to segment distances of base diagonal. @@ -339,14 +339,14 @@ class FPCSInitialAlignment : public Registration& base_indices, float (&ratio)[2]); + setupBase(pcl::Indices& base_indices, float (&ratio)[2]); /** \brief Calculate intersection ratios and segment to segment distances of base * diagonals. \param[in] base_indices indices of base B \param[out] ratio diagonal * intersection ratios of base points \return quality value of diagonal intersection */ float - segmentToSegmentDist(const std::vector& base_indices, float (&ratio)[2]); + segmentToSegmentDist(const pcl::Indices& base_indices, float (&ratio)[2]); /** \brief Search for corresponding point pairs given the distance between two base * points. @@ -375,8 +375,8 @@ class FPCSInitialAlignment : public Registration& base_indices, - std::vector>& matches, + determineBaseMatches(const pcl::Indices& base_indices, + std::vector& matches, const pcl::Correspondences& pairs_a, const pcl::Correspondences& pairs_b, const float (&ratio)[2]); @@ -391,7 +391,7 @@ class FPCSInitialAlignment : public Registration& match_indices, const float (&ds)[4]); + checkBaseMatch(const pcl::Indices& match_indices, const float (&ds)[4]); /** \brief Method to handle current candidate matches. Here we validate and evaluate * the matches w.r.t the base and store the best fitting match (together with its @@ -404,8 +404,8 @@ class FPCSInitialAlignment : public Registration& base_indices, - std::vector>& matches, + handleMatches(const pcl::Indices& base_indices, + std::vector& matches, MatchingCandidates& candidates); /** \brief Sets the correspondences between the base B and the match M by using the @@ -416,8 +416,8 @@ class FPCSInitialAlignment : public Registration& base_indices, - std::vector& match_indices, + linkMatchWithBase(const pcl::Indices& base_indices, + pcl::Indices& match_indices, pcl::Correspondences& correspondences); /** \brief Validate the matching by computing the transformation between the source @@ -434,8 +434,8 @@ class FPCSInitialAlignment : public Registration& base_indices, - const std::vector& match_indices, + validateMatch(const pcl::Indices& base_indices, + const pcl::Indices& match_indices, const pcl::Correspondences& correspondences, Eigen::Matrix4f& transformation); diff --git a/registration/include/pcl/registration/ia_kfpcs.h b/registration/include/pcl/registration/ia_kfpcs.h index 2af9610f580..8f2fb106325 100644 --- a/registration/include/pcl/registration/ia_kfpcs.h +++ b/registration/include/pcl/registration/ia_kfpcs.h @@ -205,8 +205,8 @@ class KFPCSInitialAlignment * contains the candidates matches M */ void - handleMatches(const std::vector& base_indices, - std::vector>& matches, + handleMatches(const pcl::Indices& base_indices, + std::vector& matches, MatchingCandidates& candidates) override; /** \brief Validate the transformation by calculating the score value after diff --git a/registration/include/pcl/registration/ia_ransac.h b/registration/include/pcl/registration/ia_ransac.h index bff64bea724..1776e1b87ef 100644 --- a/registration/include/pcl/registration/ia_ransac.h +++ b/registration/include/pcl/registration/ia_ransac.h @@ -261,10 +261,10 @@ class SampleConsensusInitialAlignment : public Registration(n * (rand() / (RAND_MAX + 1.0)))); + return (static_cast(n * (rand() / (RAND_MAX + 1.0)))); }; /** \brief Select \a nr_samples sample points from cloud while making sure that their @@ -275,9 +275,9 @@ class SampleConsensusInitialAlignment : public Registration& sample_indices); + pcl::Indices& sample_indices); /** \brief For each of the sample points, find a list of points in the target cloud * whose features are similar to the sample points' features. From these, select one @@ -288,8 +288,8 @@ class SampleConsensusInitialAlignment : public Registration& sample_indices, - std::vector& corresponding_indices); + const pcl::Indices& sample_indices, + pcl::Indices& corresponding_indices); /** \brief An error metric for that computes the quality of the alignment between the * given cloud and the target. \param cloud the input cloud \param threshold distances diff --git a/registration/include/pcl/registration/impl/correspondence_estimation_normal_shooting.hpp b/registration/include/pcl/registration/impl/correspondence_estimation_normal_shooting.hpp index e4e7f13c526..16f9daf0060 100644 --- a/registration/include/pcl/registration/impl/correspondence_estimation_normal_shooting.hpp +++ b/registration/include/pcl/registration/impl/correspondence_estimation_normal_shooting.hpp @@ -73,7 +73,7 @@ CorrespondenceEstimationNormalShootingsize()); - std::vector nn_indices(k_); + pcl::Indices nn_indices(k_); std::vector nn_dists(k_); int min_index = 0; @@ -188,9 +188,9 @@ CorrespondenceEstimationNormalShootingsize()); - std::vector nn_indices(k_); + pcl::Indices nn_indices(k_); std::vector nn_dists(k_); - std::vector index_reciprocal(1); + pcl::Indices index_reciprocal(1); std::vector distance_reciprocal(1); int min_index = 0; diff --git a/registration/include/pcl/registration/impl/correspondence_types.hpp b/registration/include/pcl/registration/impl/correspondence_types.hpp index 1903084ec6e..c5cefbde498 100644 --- a/registration/include/pcl/registration/impl/correspondence_types.hpp +++ b/registration/include/pcl/registration/impl/correspondence_types.hpp @@ -68,7 +68,7 @@ getCorDistMeanStd(const pcl::Correspondences& correspondences, } inline void -getQueryIndices(const pcl::Correspondences& correspondences, std::vector& indices) +getQueryIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices) { indices.resize(correspondences.size()); for (std::size_t i = 0; i < correspondences.size(); ++i) @@ -76,7 +76,7 @@ getQueryIndices(const pcl::Correspondences& correspondences, std::vector& i } inline void -getMatchIndices(const pcl::Correspondences& correspondences, std::vector& indices) +getMatchIndices(const pcl::Correspondences& correspondences, pcl::Indices& indices) { indices.resize(correspondences.size()); for (std::size_t i = 0; i < correspondences.size(); ++i) diff --git a/registration/include/pcl/registration/impl/ia_fpcs.hpp b/registration/include/pcl/registration/impl/ia_fpcs.hpp index d235d53cb3f..61f610523b9 100644 --- a/registration/include/pcl/registration/impl/ia_fpcs.hpp +++ b/registration/include/pcl/registration/impl/ia_fpcs.hpp @@ -86,7 +86,7 @@ pcl::getMeanPointDensity(const typename pcl::PointCloud::ConstPtr& cloud template inline float pcl::getMeanPointDensity(const typename pcl::PointCloud::ConstPtr& cloud, - const std::vector& indices, + const pcl::Indices& indices, float max_dist, int nr_threads) { @@ -98,7 +98,7 @@ pcl::getMeanPointDensity(const typename pcl::PointCloud::ConstPtr& cloud float mean_dist = 0.f; int num = 0; - std::vector ids(2); + pcl::Indices ids(2); std::vector dists_sqr(2); pcl::utils::ignore(nr_threads); @@ -185,7 +185,7 @@ pcl::registration::FPCSInitialAlignment base_indices(4); + pcl::Indices base_indices(4); all_candidates[i] = candidates; if (!abort) { @@ -200,7 +200,7 @@ pcl::registration::FPCSInitialAlignment> matches; + std::vector matches; if (determineBaseMatches(base_indices, matches, pairs_a, pairs_b, ratio) == 0) { // check and evaluate candidate matches and store them @@ -250,9 +250,9 @@ pcl::registration::FPCSInitialAlignmentempty()) { - target_indices_.reset(new std::vector(static_cast(target_->size()))); + target_indices_.reset(new pcl::Indices(target_->size())); int index = 0; - for (int& target_index : *target_indices_) + for (auto& target_index : *target_indices_) target_index = index++; target_cloud_updated_ = true; } @@ -263,7 +263,7 @@ pcl::registration::FPCSInitialAlignment(indices_->size()); const int sample_fraction_src = std::max(1, static_cast(ss / nr_samples_)); - source_indices_ = pcl::IndicesPtr(new std::vector); + source_indices_ = pcl::IndicesPtr(new pcl::Indices); for (int i = 0; i < ss; i++) if (rand() % sample_fraction_src == 0) source_indices_->push_back((*indices_)[i]); @@ -339,7 +339,7 @@ pcl::registration::FPCSInitialAlignment int pcl::registration::FPCSInitialAlignment:: - selectBase(std::vector& base_indices, float (&ratio)[2]) + selectBase(pcl::Indices& base_indices, float (&ratio)[2]) { const float too_close_sqr = max_base_diameter_sqr_ * 0.01; @@ -356,7 +356,7 @@ pcl::registration::FPCSInitialAlignment base_triple(base_indices.begin(), base_indices.end() - 1); + pcl::Indices base_triple(base_indices.begin(), base_indices.end() - 1); plane.computeModelCoefficients(base_triple, coefficients); pcl::compute3DCentroid(*target_, base_triple, centre_pt); @@ -405,19 +405,19 @@ pcl::registration::FPCSInitialAlignment int pcl::registration::FPCSInitialAlignment:: - selectBaseTriangle(std::vector& base_indices) + selectBaseTriangle(pcl::Indices& base_indices) { int nr_points = static_cast(target_indices_->size()); float best_t = 0.f; // choose random first point base_indices[0] = (*target_indices_)[rand() % nr_points]; - int* index1 = &base_indices[0]; + auto* index1 = &base_indices[0]; // random search for 2 other points (as far away as overlap allows) for (int i = 0; i < ransac_iterations_; i++) { - int* index2 = &(*target_indices_)[rand() % nr_points]; - int* index3 = &(*target_indices_)[rand() % nr_points]; + auto* index2 = &(*target_indices_)[rand() % nr_points]; + auto* index3 = &(*target_indices_)[rand() % nr_points]; Eigen::Vector3f u = (*target_)[*index2].getVector3fMap() - (*target_)[*index1].getVector3fMap(); @@ -443,11 +443,11 @@ pcl::registration::FPCSInitialAlignment void pcl::registration::FPCSInitialAlignment:: - setupBase(std::vector& base_indices, float (&ratio)[2]) + setupBase(pcl::Indices& base_indices, float (&ratio)[2]) { float best_t = FLT_MAX; const std::vector copy(base_indices.begin(), base_indices.end()); - std::vector temp(base_indices.begin(), base_indices.end()); + pcl::Indices temp(base_indices.begin(), base_indices.end()); // loop over all combinations of base points for (std::vector::const_iterator i = copy.begin(), i_e = copy.end(); i != i_e; @@ -490,7 +490,7 @@ pcl::registration::FPCSInitialAlignment float pcl::registration::FPCSInitialAlignment:: - segmentToSegmentDist(const std::vector& base_indices, float (&ratio)[2]) + segmentToSegmentDist(const pcl::Indices& base_indices, float (&ratio)[2]) { // get point vectors Eigen::Vector3f u = (*target_)[base_indices[1]].getVector3fMap() - @@ -629,8 +629,8 @@ pcl::registration::FPCSInitialAlignment int pcl::registration::FPCSInitialAlignment:: - determineBaseMatches(const std::vector& base_indices, - std::vector>& matches, + determineBaseMatches(const pcl::Indices& base_indices, + std::vector& matches, const pcl::Correspondences& pairs_a, const pcl::Correspondences& pairs_b, const float (&ratio)[2]) @@ -667,7 +667,7 @@ pcl::registration::FPCSInitialAlignmentsetInputCloud(cloud_e); - std::vector ids; + pcl::Indices ids; std::vector dists_sqr; // loop over second point pair correspondences @@ -685,7 +685,7 @@ pcl::registration::FPCSInitialAlignmentradiusSearch(pt_e, coincidation_limit_, ids, dists_sqr); for (const auto& id : ids) { - std::vector match_indices(4); + pcl::Indices match_indices(4); match_indices[0] = pairs_a[static_cast(std::floor((float)(id / 2.f)))].index_match; @@ -711,7 +711,7 @@ pcl::registration::FPCSInitialAlignment int pcl::registration::FPCSInitialAlignment:: - checkBaseMatch(const std::vector& match_indices, const float (&dist_ref)[4]) + checkBaseMatch(const pcl::Indices& match_indices, const float (&dist_ref)[4]) { float d0 = pcl::euclideanDistance((*input_)[match_indices[0]], (*input_)[match_indices[2]]); @@ -735,8 +735,8 @@ pcl::registration::FPCSInitialAlignment void pcl::registration::FPCSInitialAlignment:: - handleMatches(const std::vector& base_indices, - std::vector>& matches, + handleMatches(const pcl::Indices& base_indices, + std::vector& matches, MatchingCandidates& candidates) { candidates.resize(1); @@ -773,8 +773,8 @@ pcl::registration::FPCSInitialAlignment void pcl::registration::FPCSInitialAlignment:: - linkMatchWithBase(const std::vector& base_indices, - std::vector& match_indices, + linkMatchWithBase(const pcl::Indices& base_indices, + pcl::Indices& match_indices, pcl::Correspondences& correspondences) { // calculate centroid of base and target @@ -793,7 +793,7 @@ pcl::registration::FPCSInitialAlignment copy = match_indices; + pcl::Indices copy = match_indices; auto it_match_orig = match_indices.begin(); for (auto it_base = base_indices.cbegin(), it_base_e = base_indices.cend(); @@ -826,8 +826,8 @@ pcl::registration::FPCSInitialAlignment int pcl::registration::FPCSInitialAlignment:: - validateMatch(const std::vector& base_indices, - const std::vector& match_indices, + validateMatch(const pcl::Indices& base_indices, + const pcl::Indices& match_indices, const pcl::Correspondences& correspondences, Eigen::Matrix4f& transformation) { @@ -871,7 +871,7 @@ pcl::registration::FPCSInitialAlignment((1.f - fitness_score) * nr_points); float inlier_score_temp = 0; - std::vector ids; + pcl::Indices ids; std::vector dists_sqr; PointCloudSourceIterator it = source_transformed.begin(); diff --git a/registration/include/pcl/registration/impl/ia_kfpcs.hpp b/registration/include/pcl/registration/impl/ia_kfpcs.hpp index 96b2cbd3537..9358ced8e72 100644 --- a/registration/include/pcl/registration/impl/ia_kfpcs.hpp +++ b/registration/include/pcl/registration/impl/ia_kfpcs.hpp @@ -48,7 +48,7 @@ KFPCSInitialAlignment:: , upper_trl_boundary_(-1.f) , lambda_(0.5f) , use_trl_score_(false) -, indices_validation_(new std::vector) +, indices_validation_(new pcl::Indices) { reg_name_ = "pcl::registration::KFPCSInitialAlignment"; } @@ -105,8 +105,8 @@ KFPCSInitialAlignment::initCompute() template void KFPCSInitialAlignment::handleMatches( - const std::vector& base_indices, - std::vector>& matches, + const pcl::Indices& base_indices, + std::vector& matches, MatchingCandidates& candidates) { candidates.clear(); @@ -151,7 +151,7 @@ KFPCSInitialAlignment:: float score_a = 0.f, score_b = 0.f; // residual costs based on mse - std::vector ids; + pcl::Indices ids; std::vector dists_sqr; for (PointCloudSourceIterator it = source_transformed.begin(), it_e = source_transformed.end(); diff --git a/registration/include/pcl/registration/impl/ia_ransac.hpp b/registration/include/pcl/registration/impl/ia_ransac.hpp index fa99cba2f7c..1cb077115de 100644 --- a/registration/include/pcl/registration/impl/ia_ransac.hpp +++ b/registration/include/pcl/registration/impl/ia_ransac.hpp @@ -78,13 +78,13 @@ template void SampleConsensusInitialAlignment::selectSamples( const PointCloudSource& cloud, - int nr_samples, + unsigned int nr_samples, float min_sample_distance, - std::vector& sample_indices) + pcl::Indices& sample_indices) { - if (nr_samples > static_cast(cloud.size())) { + if (nr_samples > cloud.size()) { PCL_ERROR("[pcl::%s::selectSamples] ", getClassName().c_str()); - PCL_ERROR("The number of samples (%d) must not be greater than the number of " + PCL_ERROR("The number of samples (%u) must not be greater than the number of " "points (%zu)!\n", nr_samples, static_cast(cloud.size())); @@ -95,9 +95,9 @@ SampleConsensusInitialAlignment::selectSampl index_t iterations_without_a_sample = 0; const auto max_iterations_without_a_sample = 3 * cloud.size(); sample_indices.clear(); - while (static_cast(sample_indices.size()) < nr_samples) { + while (sample_indices.size() < nr_samples) { // Choose a sample at random - int sample_index = getRandomIndex(static_cast(cloud.size())); + const auto sample_index = getRandomIndex(cloud.size()); // Check to see if the sample is 1) unique and 2) far away from the other samples bool valid_sample = true; @@ -140,10 +140,10 @@ template void SampleConsensusInitialAlignment:: findSimilarFeatures(const FeatureCloud& input_features, - const std::vector& sample_indices, - std::vector& corresponding_indices) + const pcl::Indices& sample_indices, + pcl::Indices& corresponding_indices) { - std::vector nn_indices(k_correspondences_); + pcl::Indices nn_indices(k_correspondences_); std::vector nn_distances(k_correspondences_); corresponding_indices.resize(sample_indices.size()); @@ -156,7 +156,7 @@ SampleConsensusInitialAlignment:: nn_distances); // Select one at random and add it to corresponding_indices - int random_correspondence = getRandomIndex(k_correspondences_); + const auto random_correspondence = getRandomIndex(k_correspondences_); corresponding_indices[i] = nn_indices[random_correspondence]; } } @@ -223,8 +223,8 @@ SampleConsensusInitialAlignment:: if (!error_functor_) error_functor_.reset(new TruncatedError(static_cast(corr_dist_threshold_))); - std::vector sample_indices(nr_samples_); - std::vector corresponding_indices(nr_samples_); + pcl::Indices sample_indices(nr_samples_); + pcl::Indices corresponding_indices(nr_samples_); PointCloudSource input_transformed; float lowest_error(0); diff --git a/registration/include/pcl/registration/impl/ndt.hpp b/registration/include/pcl/registration/impl/ndt.hpp index 2df43d48047..c6d65c753be 100644 --- a/registration/include/pcl/registration/impl/ndt.hpp +++ b/registration/include/pcl/registration/impl/ndt.hpp @@ -151,7 +151,7 @@ NormalDistributionsTransform::computeTransformation( // Update Visualizer (untested) if (update_visualizer_) - update_visualizer_(output, std::vector(), *target_, std::vector()); + update_visualizer_(output, pcl::Indices(), *target_, pcl::Indices()); const double cos_angle = 0.5 * transformation_.template block<3, 3>(0, 0).trace() - 1; diff --git a/registration/include/pcl/registration/impl/ppf_registration.hpp b/registration/include/pcl/registration/impl/ppf_registration.hpp index c58df563ea8..42c42545f73 100644 --- a/registration/include/pcl/registration/impl/ppf_registration.hpp +++ b/registration/include/pcl/registration/impl/ppf_registration.hpp @@ -113,7 +113,7 @@ pcl::PPFRegistration::computeTransformation( rotation_sg); // For every other point in the scene => now have pair (s_r, s_i) fixed - std::vector indices; + pcl::Indices indices; std::vector distances; scene_search_tree_->radiusSearch((*target_)[scene_reference_index], search_method_->getModelDiameter() / 2, diff --git a/registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp b/registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp index dbe6558b2b6..d62d02eefe4 100644 --- a/registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp +++ b/registration/include/pcl/registration/impl/sample_consensus_prerejective.hpp @@ -75,7 +75,7 @@ SampleConsensusPrerejective::setTargetFeatur template void SampleConsensusPrerejective::selectSamples( - const PointCloudSource& cloud, int nr_samples, std::vector& sample_indices) + const PointCloudSource& cloud, int nr_samples, pcl::Indices& sample_indices) { if (nr_samples > static_cast(cloud.size())) { PCL_ERROR("[pcl::%s::selectSamples] ", getClassName().c_str()); @@ -118,9 +118,9 @@ SampleConsensusPrerejective::selectSamples( template void SampleConsensusPrerejective::findSimilarFeatures( - const std::vector& sample_indices, - std::vector>& similar_features, - std::vector& corresponding_indices) + const pcl::Indices& sample_indices, + std::vector& similar_features, + pcl::Indices& corresponding_indices) { // Allocate results corresponding_indices.resize(sample_indices.size()); @@ -222,7 +222,7 @@ SampleConsensusPrerejective::computeTransfor converged_ = false; // Temporaries - std::vector inliers; + pcl::Indices inliers; float inlier_fraction; float error; @@ -240,13 +240,13 @@ SampleConsensusPrerejective::computeTransfor } // Feature correspondence cache - std::vector> similar_features(input_->size()); + std::vector similar_features(input_->size()); // Start for (int i = 0; i < max_iterations_; ++i) { // Temporary containers - std::vector sample_indices; - std::vector corresponding_indices; + pcl::Indices sample_indices; + pcl::Indices corresponding_indices; // Draw nr_samples_ random samples selectSamples(*input_, nr_samples_, sample_indices); @@ -305,7 +305,7 @@ SampleConsensusPrerejective::computeTransfor template void SampleConsensusPrerejective::getFitness( - std::vector& inliers, float& fitness_score) + pcl::Indices& inliers, float& fitness_score) { // Initialize variables inliers.clear(); @@ -323,7 +323,7 @@ SampleConsensusPrerejective::getFitness( // For each point in the source dataset for (std::size_t i = 0; i < input_transformed.size(); ++i) { // Find its nearest neighbor in the target - std::vector nn_indices(1); + pcl::Indices nn_indices(1); std::vector nn_dists(1); tree_->nearestKSearch(input_transformed[i], 1, nn_indices, nn_dists); diff --git a/registration/include/pcl/registration/impl/transformation_estimation_2D.hpp b/registration/include/pcl/registration/impl/transformation_estimation_2D.hpp index 005ab5211ad..c2aae92c166 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_2D.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_2D.hpp @@ -67,7 +67,7 @@ template void TransformationEstimation2D:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -88,9 +88,9 @@ template inline void TransformationEstimation2D:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { if (indices_src.size() != indices_tgt.size()) { diff --git a/registration/include/pcl/registration/impl/transformation_estimation_3point.hpp b/registration/include/pcl/registration/impl/transformation_estimation_3point.hpp index eaef08c1cc2..cceac5530db 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_3point.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_3point.hpp @@ -66,7 +66,7 @@ template void pcl::registration::TransformationEstimation3Point:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -89,9 +89,9 @@ template inline void pcl::registration::TransformationEstimation3Point:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { if (indices_src.size() != 3 || indices_tgt.size() != 3) { diff --git a/registration/include/pcl/registration/impl/transformation_estimation_dq.hpp b/registration/include/pcl/registration/impl/transformation_estimation_dq.hpp index c69fa011466..fce6079d3da 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_dq.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_dq.hpp @@ -75,7 +75,7 @@ template void TransformationEstimationDQ:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -96,9 +96,9 @@ template inline void TransformationEstimationDQ:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { if (indices_src.size() != indices_tgt.size()) { diff --git a/registration/include/pcl/registration/impl/transformation_estimation_dual_quaternion.hpp b/registration/include/pcl/registration/impl/transformation_estimation_dual_quaternion.hpp index b45762846ff..927a324ad22 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_dual_quaternion.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_dual_quaternion.hpp @@ -74,7 +74,7 @@ template void TransformationEstimationDualQuaternion:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -95,9 +95,9 @@ template inline void TransformationEstimationDualQuaternion:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { if (indices_src.size() != indices_tgt.size()) { diff --git a/registration/include/pcl/registration/impl/transformation_estimation_lm.hpp b/registration/include/pcl/registration/impl/transformation_estimation_lm.hpp index 95e9896e20f..fe01a34a633 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_lm.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_lm.hpp @@ -122,7 +122,7 @@ template void pcl::registration::TransformationEstimationLM:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -139,7 +139,7 @@ pcl::registration::TransformationEstimationLM indices_tgt; + pcl::Indices indices_tgt; indices_tgt.resize(nr_correspondences); for (std::size_t i = 0; i < nr_correspondences; ++i) indices_tgt[i] = i; @@ -153,9 +153,9 @@ template inline void pcl::registration::TransformationEstimationLM:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { if (indices_src.size() != indices_tgt.size()) { @@ -225,8 +225,8 @@ pcl::registration::TransformationEstimationLM indices_src(nr_correspondences); - std::vector indices_tgt(nr_correspondences); + pcl::Indices indices_src(nr_correspondences); + pcl::Indices indices_tgt(nr_correspondences); for (std::size_t i = 0; i < nr_correspondences; ++i) { indices_src[i] = correspondences[i].index_query; indices_tgt[i] = correspondences[i].index_match; @@ -272,8 +272,8 @@ pcl::registration::TransformationEstimationLM& src_points = *estimator_->tmp_src_; const PointCloud& tgt_points = *estimator_->tmp_tgt_; - const std::vector& src_indices = *estimator_->tmp_idx_src_; - const std::vector& tgt_indices = *estimator_->tmp_idx_tgt_; + const pcl::Indices& src_indices = *estimator_->tmp_idx_src_; + const pcl::Indices& tgt_indices = *estimator_->tmp_idx_tgt_; // Initialize the warp function with the given parameters estimator_->warp_point_->setParam(x); diff --git a/registration/include/pcl/registration/impl/transformation_estimation_point_to_plane_lls.hpp b/registration/include/pcl/registration/impl/transformation_estimation_point_to_plane_lls.hpp index 1e45e65e009..18591d32516 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_point_to_plane_lls.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_point_to_plane_lls.hpp @@ -73,7 +73,7 @@ template void TransformationEstimationPointToPlaneLLS:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -96,9 +96,9 @@ template inline void TransformationEstimationPointToPlaneLLS:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { const auto nr_points = indices_src.size(); diff --git a/registration/include/pcl/registration/impl/transformation_estimation_svd.hpp b/registration/include/pcl/registration/impl/transformation_estimation_svd.hpp index 454e51b2516..8c726f9cf2a 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_svd.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_svd.hpp @@ -72,7 +72,7 @@ template void TransformationEstimationSVD:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -93,9 +93,9 @@ template inline void TransformationEstimationSVD:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { if (indices_src.size() != indices_tgt.size()) { diff --git a/registration/include/pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp b/registration/include/pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp index aff4d35497f..261e48fd47a 100644 --- a/registration/include/pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp +++ b/registration/include/pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp @@ -69,7 +69,7 @@ template void TransformationEstimationSymmetricPointToPlaneLLS:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const { @@ -92,9 +92,9 @@ template inline void TransformationEstimationSymmetricPointToPlaneLLS:: estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const { const auto nr_points = indices_src.size(); diff --git a/registration/include/pcl/registration/registration.h b/registration/include/pcl/registration/registration.h index 368c553aeaa..5bfa502edb9 100644 --- a/registration/include/pcl/registration/registration.h +++ b/registration/include/pcl/registration/registration.h @@ -101,9 +101,9 @@ class Registration : public PCLBase { * cloud_tgt */ using UpdateVisualizerCallbackSignature = void(const pcl::PointCloud&, - const std::vector&, + const pcl::Indices&, const pcl::PointCloud&, - const std::vector&); + const pcl::Indices&); /** \brief Empty constructor. */ Registration() @@ -670,7 +670,7 @@ class Registration : public PCLBase { inline bool searchForNeighbors(const PointCloudSource& cloud, int index, - std::vector& indices, + pcl::Indices& indices, std::vector& distances) { int k = tree_->nearestKSearch(cloud, index, 1, indices, distances); diff --git a/registration/include/pcl/registration/sample_consensus_prerejective.h b/registration/include/pcl/registration/sample_consensus_prerejective.h index d7ff45c0a6a..d33882247bf 100644 --- a/registration/include/pcl/registration/sample_consensus_prerejective.h +++ b/registration/include/pcl/registration/sample_consensus_prerejective.h @@ -240,7 +240,7 @@ class SampleConsensusPrerejective : public Registration& + inline const pcl::Indices& getInliers() const { return inliers_; @@ -264,7 +264,7 @@ class SampleConsensusPrerejective : public Registration& sample_indices); + pcl::Indices& sample_indices); /** \brief For each of the sample points, find a list of points in the target cloud * whose features are similar to the sample points' features. From these, select one @@ -275,9 +275,9 @@ class SampleConsensusPrerejective : public Registration& sample_indices, - std::vector>& similar_features, - std::vector& corresponding_indices); + findSimilarFeatures(const pcl::Indices& sample_indices, + std::vector& similar_features, + pcl::Indices& corresponding_indices); /** \brief Rigid transformation computation method. * \param output the transformed input point cloud dataset using the rigid @@ -296,7 +296,7 @@ class SampleConsensusPrerejective : public Registration& inliers, float& fitness_score); + getFitness(pcl::Indices& inliers, float& fitness_score); /** \brief The source point cloud's feature descriptors. */ FeatureCloudConstPtr input_features_; @@ -322,7 +322,7 @@ class SampleConsensusPrerejective : public Registration inliers_; + pcl::Indices inliers_; }; } // namespace pcl diff --git a/registration/include/pcl/registration/transformation_estimation.h b/registration/include/pcl/registration/transformation_estimation.h index 39766c1abc2..c07ae01af85 100644 --- a/registration/include/pcl/registration/transformation_estimation.h +++ b/registration/include/pcl/registration/transformation_estimation.h @@ -84,7 +84,7 @@ class TransformationEstimation { */ virtual void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const = 0; @@ -98,9 +98,9 @@ class TransformationEstimation { */ virtual void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const = 0; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/include/pcl/registration/transformation_estimation_2D.h b/registration/include/pcl/registration/transformation_estimation_2D.h index beb3cde8bb7..6729f60be5c 100644 --- a/registration/include/pcl/registration/transformation_estimation_2D.h +++ b/registration/include/pcl/registration/transformation_estimation_2D.h @@ -86,7 +86,7 @@ class TransformationEstimation2D */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const; @@ -99,9 +99,9 @@ class TransformationEstimation2D */ virtual void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const; /** \brief Estimate a rigid transformation between a source and a target point cloud diff --git a/registration/include/pcl/registration/transformation_estimation_3point.h b/registration/include/pcl/registration/transformation_estimation_3point.h index 61509765e7d..8ee7ab0aae9 100644 --- a/registration/include/pcl/registration/transformation_estimation_3point.h +++ b/registration/include/pcl/registration/transformation_estimation_3point.h @@ -91,7 +91,7 @@ class TransformationEstimation3Point */ void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const override; @@ -105,9 +105,9 @@ class TransformationEstimation3Point */ void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const override; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/include/pcl/registration/transformation_estimation_dq.h b/registration/include/pcl/registration/transformation_estimation_dq.h index fd28170e651..4c7512c0b62 100644 --- a/registration/include/pcl/registration/transformation_estimation_dq.h +++ b/registration/include/pcl/registration/transformation_estimation_dq.h @@ -88,7 +88,7 @@ class TransformationEstimationDQ */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const; @@ -102,9 +102,9 @@ class TransformationEstimationDQ */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h b/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h index 608e7e7d44e..e52937af88d 100644 --- a/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h +++ b/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h @@ -85,7 +85,7 @@ class TransformationEstimationDualQuaternion */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const override; @@ -99,9 +99,9 @@ class TransformationEstimationDualQuaternion */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const override; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/include/pcl/registration/transformation_estimation_lm.h b/registration/include/pcl/registration/transformation_estimation_lm.h index b2c9dda59cd..2680f6460bd 100644 --- a/registration/include/pcl/registration/transformation_estimation_lm.h +++ b/registration/include/pcl/registration/transformation_estimation_lm.h @@ -124,7 +124,7 @@ class TransformationEstimationLM */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const override; @@ -138,9 +138,9 @@ class TransformationEstimationLM */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const override; /** \brief Estimate a rigid rotation transformation between a source and a target @@ -205,10 +205,10 @@ class TransformationEstimationLM mutable const PointCloudTarget* tmp_tgt_; /** \brief Temporary pointer to the source dataset indices. */ - mutable const std::vector* tmp_idx_src_; + mutable const pcl::Indices* tmp_idx_src_; /** \brief Temporary pointer to the target dataset indices. */ - mutable const std::vector* tmp_idx_tgt_; + mutable const pcl::Indices* tmp_idx_tgt_; /** \brief The parameterized function used to warp the source to the target. */ typename pcl::registration::WarpPointRigid::Ptr diff --git a/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h b/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h index 16e24423532..c41ec430000 100644 --- a/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h +++ b/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h @@ -92,7 +92,7 @@ class TransformationEstimationPointToPlaneLLS */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const override; @@ -106,9 +106,9 @@ class TransformationEstimationPointToPlaneLLS */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const override; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/include/pcl/registration/transformation_estimation_svd.h b/registration/include/pcl/registration/transformation_estimation_svd.h index 16e8c7212c7..e6d003abef7 100644 --- a/registration/include/pcl/registration/transformation_estimation_svd.h +++ b/registration/include/pcl/registration/transformation_estimation_svd.h @@ -88,7 +88,7 @@ class TransformationEstimationSVD */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const override; @@ -102,9 +102,9 @@ class TransformationEstimationSVD */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const override; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h b/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h index dec86cc40ad..9bf47a8c894 100644 --- a/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h +++ b/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h @@ -93,7 +93,7 @@ class TransformationEstimationSymmetricPointToPlaneLLS */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, Matrix4& transformation_matrix) const override; @@ -107,9 +107,9 @@ class TransformationEstimationSymmetricPointToPlaneLLS */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, - const std::vector& indices_src, + const pcl::Indices& indices_src, const pcl::PointCloud& cloud_tgt, - const std::vector& indices_tgt, + const pcl::Indices& indices_tgt, Matrix4& transformation_matrix) const override; /** \brief Estimate a rigid rotation transformation between a source and a target diff --git a/registration/src/correspondence_rejection_one_to_one.cpp b/registration/src/correspondence_rejection_one_to_one.cpp index 55f2e7dd09a..f94136da36b 100644 --- a/registration/src/correspondence_rejection_one_to_one.cpp +++ b/registration/src/correspondence_rejection_one_to_one.cpp @@ -38,6 +38,7 @@ */ #include +#include // for UNAVAILABLE ////////////////////////////////////////////////////////////////////////////////////////////// void @@ -53,7 +54,7 @@ pcl::registration::CorrespondenceRejectorOneToOne::getRemainingCorrespondences( pcl::registration::sortCorrespondencesByMatchIndexAndDistance()); remaining_correspondences.resize(input.size()); - int index_last = -1; + pcl::index_t index_last = UNAVAILABLE; unsigned int number_valid_correspondences = 0; for (const auto& i : input) { if (i.index_match < 0) diff --git a/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp b/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp index e11535f207c..406b0da8cb9 100644 --- a/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp +++ b/segmentation/include/pcl/segmentation/impl/grabcut_segmentation.hpp @@ -339,7 +339,7 @@ GrabCut::computeNLinksNonOrganized () NLinks &n_link = n_links_[i_point]; if (n_link.nb_links > 0) { - int point_index = (*indices_) [i_point]; + const auto point_index = (*indices_) [i_point]; auto dists_it = n_link.dists.cbegin (); auto weights_it = n_link.weights.begin (); for (auto indices_it = n_link.indices.cbegin (); indices_it != n_link.indices.cend (); ++indices_it, ++dists_it, ++weights_it) From 476ebff103edb7d247e5b770535fc678dea7b1ed Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 18 Mar 2021 15:20:28 +0100 Subject: [PATCH 073/431] Enable all (default) modules on ubuntu indices CI --- .ci/azure-pipelines/build/ubuntu_indices.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.ci/azure-pipelines/build/ubuntu_indices.yaml b/.ci/azure-pipelines/build/ubuntu_indices.yaml index 07463d6dca0..fd2e836662a 100644 --- a/.ci/azure-pipelines/build/ubuntu_indices.yaml +++ b/.ci/azure-pipelines/build/ubuntu_indices.yaml @@ -10,12 +10,6 @@ steps: -DPCL_ONLY_CORE_POINT_TYPES=ON \ -DPCL_INDEX_SIGNED=$INDEX_SIGNED \ -DPCL_INDEX_SIZE=$INDEX_SIZE \ - -DBUILD_geometry=OFF \ - -DBUILD_io=OFF \ - -DBUILD_tools=OFF \ - -DBUILD_kdtree=OFF \ - -DBUILD_ml=OFF \ - -DBUILD_stereo=OFF \ -DBUILD_global_tests=ON # Temporary fix to ensure no tests are skipped cmake $(Build.SourcesDirectory) From eda5305d2c749f0d655745ac45dc9cc1eeb851a3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 26 Mar 2021 17:22:28 +0100 Subject: [PATCH 074/431] Improve documentation, fix warnings Fix doxygen warnings such as: - Illegal command @param as part of a \a command - The following parameter [...] is not documented Fix rst warnings such as: - duplicate label - duplicate citation - malformed table - could not lex literal_block as "cmake" --- common/include/pcl/common/common.h | 1 + common/include/pcl/point_cloud.h | 4 ++++ doc/advanced/content/c_cache.rst | 8 ++++---- doc/tutorials/content/function_filter.rst | 4 ++-- doc/tutorials/content/how_features_work.rst | 8 ++++---- .../content/random_sample_consensus.rst | 6 +++--- gpu/octree/include/pcl/gpu/octree/octree.hpp | 2 +- ...spondence_estimation_organized_projection.h | 14 ++++++++++---- registration/include/pcl/registration/gicp.h | 13 +++++++------ .../registration/transformation_estimation.h | 4 ++-- .../transformation_estimation_2D.h | 13 +++++++------ .../transformation_estimation_3point.h | 4 ++-- .../transformation_estimation_dq.h | 14 ++++++++------ ...transformation_estimation_dual_quaternion.h | 14 ++++++++------ .../transformation_estimation_lm.h | 14 ++++++++------ ...nsformation_estimation_point_to_plane_lls.h | 14 ++++++++------ ...on_estimation_point_to_plane_lls_weighted.h | 14 ++++++++------ ...mation_estimation_point_to_plane_weighted.h | 17 ++++++++++------- .../transformation_estimation_svd.h | 14 ++++++++------ ...n_estimation_symmetric_point_to_plane_lls.h | 14 ++++++++------ .../segmentation/extract_labeled_clusters.h | 18 +++++++++++------- 21 files changed, 124 insertions(+), 90 deletions(-) diff --git a/common/include/pcl/common/common.h b/common/include/pcl/common/common.h index 97a41df5a95..f21f096881d 100644 --- a/common/include/pcl/common/common.h +++ b/common/include/pcl/common/common.h @@ -60,6 +60,7 @@ namespace pcl /** \brief Compute the smallest angle between two 3D vectors in radians (default) or degree. * \param v1 the first 3D vector (represented as a \a Eigen::Vector4f) * \param v2 the second 3D vector (represented as a \a Eigen::Vector4f) + * \param in_degree determine if angle should be in radians or degrees * \return the angle between v1 and v2 in radians or degrees * \note Handles rounding error for parallel and anti-parallel vectors * \ingroup common diff --git a/common/include/pcl/point_cloud.h b/common/include/pcl/point_cloud.h index 11d856f0eec..4a6cad3315a 100644 --- a/common/include/pcl/point_cloud.h +++ b/common/include/pcl/point_cloud.h @@ -536,6 +536,7 @@ namespace pcl * \note This breaks the organized structure of the cloud by setting the height to * 1! * \param[in] count new size of the point cloud + * \param[in] value value each point of the cloud should have */ inline void assign(index_t count, const PointT& value) @@ -549,6 +550,7 @@ namespace pcl * \brief Replaces the points with `new_width * new_height` copies of `value` * \param[in] new_width new width of the point cloud * \param[in] new_height new height of the point cloud + * \param[in] value value each point of the cloud should have */ inline void assign(index_t new_width, index_t new_height, const PointT& value) @@ -580,6 +582,7 @@ namespace pcl * `*this` * \note This calculates the height based on size and width provided. This means * the assignment happens even if the size is not perfectly divisible by width + * \param[in] first, last the range from which the points are copied * \param[in] new_width new width of the point cloud */ template @@ -616,6 +619,7 @@ namespace pcl * \brief Replaces the points with the elements from the initializer list `ilist` * \note This calculates the height based on size and width provided. This means * the assignment happens even if the size is not perfectly divisible by width + * \param[in] ilist initializer list from which the points are copied * \param[in] new_width new width of the point cloud */ void diff --git a/doc/advanced/content/c_cache.rst b/doc/advanced/content/c_cache.rst index 21da47ba24d..8d2826cce37 100644 --- a/doc/advanced/content/c_cache.rst +++ b/doc/advanced/content/c_cache.rst @@ -35,14 +35,14 @@ Install ``colorgcc`` on an Ubuntu system with :: To enable colorgcc, perform the following steps: -.. code-block:: cmake +.. code-block:: shell cp /etc/colorgcc/colorgccrc $HOME/.colorgccrc * edit the $HOME/.colorgccrc file, search for the following lines: -.. code-block:: cmake +.. code-block:: text g++: /usr/bin/g++ gcc: /usr/bin/gcc @@ -54,7 +54,7 @@ To enable colorgcc, perform the following steps: and replace them with: -.. code-block:: cmake +.. code-block:: text g++: ccache /usr/bin/g++ gcc: ccache /usr/bin/gcc @@ -66,7 +66,7 @@ and replace them with: * create a $HOME/bin or $HOME/sbin directory, and create the following softlinks in it -.. code-block:: cmake +.. code-block:: shell ln -s /usr/bin/colorgcc c++ ln -s /usr/bin/colorgcc cc diff --git a/doc/tutorials/content/function_filter.rst b/doc/tutorials/content/function_filter.rst index f346934b477..59ed23355c2 100644 --- a/doc/tutorials/content/function_filter.rst +++ b/doc/tutorials/content/function_filter.rst @@ -1,4 +1,4 @@ -.. _conditional_removal: +.. _function_filter: Removing outliers using a custom non-destructive condition ---------------------------------------------------------- @@ -7,7 +7,7 @@ This document demonstrates how to use the FunctionFilter class to remove points and faster appraoch compared to ConditionalRemoval filter or a `custom Condition class `_. .. note:: -Advanced users can use the FunctorFilter class that can provide a small but measurable speedup when used with a `lambda `_. + Advanced users can use the FunctorFilter class that can provide a small but measurable speedup when used with a `lambda `_. The code -------- diff --git a/doc/tutorials/content/how_features_work.rst b/doc/tutorials/content/how_features_work.rst index 0989543ef35..8eef3a32d66 100644 --- a/doc/tutorials/content/how_features_work.rst +++ b/doc/tutorials/content/how_features_work.rst @@ -54,13 +54,13 @@ the table below for a reference on each of the terms used. +=============+================================================+ | Foo | a class named `Foo` | +-------------+------------------------------------------------+ -| FooPtr | a shared pointer to a class `Foo`, | +| FooPtr | a shared pointer to a class `Foo`, | | | | -| | e.g., `shared_ptr` | +| | e.g., `shared_ptr` | +-------------+------------------------------------------------+ -| FooConstPtr | a const shared pointer to a class `Foo`, | +| FooConstPtr | a const shared pointer to a class `Foo`, | | | | -| | e.g., `const shared_ptr` | +| | e.g., `const shared_ptr` | +-------------+------------------------------------------------+ How to pass the input diff --git a/doc/tutorials/content/random_sample_consensus.rst b/doc/tutorials/content/random_sample_consensus.rst index d627f8b2cd6..ed5dad498ae 100644 --- a/doc/tutorials/content/random_sample_consensus.rst +++ b/doc/tutorials/content/random_sample_consensus.rst @@ -10,7 +10,7 @@ Theoretical Primer The abbreviation of "RANdom SAmple Consensus" is RANSAC, and it is an iterative method that is used to estimate parameters of a mathematical model from a set of data containing outliers. This algorithm was published by Fischler and Bolles in 1981. The RANSAC algorithm assumes that all of the data we are looking at is comprised of both inliers and outliers. Inliers can be explained by a model with a particular set of parameter values, while outliers do not fit that model in any circumstance. Another necessary assumption is that a procedure which can optimally estimate the parameters of the chosen model from the data is available. -From [Wikipedia]_: +From [WikipediaRANSAC]_: *The input to the RANSAC algorithm is a set of observed data values, a parameterized model which can explain or be fitted to the observations, and some confidence parameters.* @@ -38,7 +38,7 @@ From [Wikipedia]_: :align: right :height: 200px -The pictures to the left and right (From [Wikipedia]_) show a simple application of the RANSAC algorithm on a 2-dimensional set of data. The image on our left is a visual representation of a data set containing both inliers and outliers. The image on our right shows all of the outliers in red, and shows inliers in blue. The blue line is the result of the work done by RANSAC. In this case the model that we are trying to fit to the data is a line, and it looks like it's a fairly good fit to our data. +The pictures to the left and right (From [WikipediaRANSAC]_) show a simple application of the RANSAC algorithm on a 2-dimensional set of data. The image on our left is a visual representation of a data set containing both inliers and outliers. The image on our right shows all of the outliers in red, and shows inliers in blue. The blue line is the result of the work done by RANSAC. In this case the model that we are trying to fit to the data is a line, and it looks like it's a fairly good fit to our data. The code -------- @@ -123,4 +123,4 @@ It will show you the result of applying RandomSampleConsensus to this data set w :align: center :height: 400px -.. [Wikipedia] http://en.wikipedia.org/wiki/RANSAC +.. [WikipediaRANSAC] http://en.wikipedia.org/wiki/RANSAC diff --git a/gpu/octree/include/pcl/gpu/octree/octree.hpp b/gpu/octree/include/pcl/gpu/octree/octree.hpp index 64cfb378839..a5e2c734f3a 100644 --- a/gpu/octree/include/pcl/gpu/octree/octree.hpp +++ b/gpu/octree/include/pcl/gpu/octree/octree.hpp @@ -150,7 +150,7 @@ namespace pcl /** \brief Batch approximate nearest search on GPU * \param[in] queries array of centers * \param[out] result array of results ( one index for each query ) - * \param[out] sqr_distances corresponding square distances to results from query point + * \param[out] sqr_distance corresponding square distances to results from query point */ void approxNearestSearch(const Queries& queries, NeighborIndices& result, ResultSqrDists& sqr_distance) const; diff --git a/registration/include/pcl/registration/correspondence_estimation_organized_projection.h b/registration/include/pcl/registration/correspondence_estimation_organized_projection.h index 4f351fe1e49..97bf14ab188 100644 --- a/registration/include/pcl/registration/correspondence_estimation_organized_projection.h +++ b/registration/include/pcl/registration/correspondence_estimation_organized_projection.h @@ -187,15 +187,21 @@ class CorrespondenceEstimationOrganizedProjection } /** \brief Computes the correspondences, applying a maximum Euclidean distance - * threshold. \param correspondences \param[in] max_distance Euclidean distance - * threshold above which correspondences will be rejected + * threshold. + * \param[out] correspondences the found correspondences (index of query point, index + * of target point, distance) + * \param[in] max_distance Euclidean distance threshold above which correspondences + * will be rejected */ void determineCorrespondences(Correspondences& correspondences, double max_distance); /** \brief Computes the correspondences, applying a maximum Euclidean distance - * threshold. \param correspondences \param[in] max_distance Euclidean distance - * threshold above which correspondences will be rejected + * threshold. + * \param[out] correspondences the found correspondences (index of query and target + * point, distance) + * \param[in] max_distance Euclidean distance threshold above which correspondences + * will be rejected */ void determineReciprocalCorrespondences(Correspondences& correspondences, diff --git a/registration/include/pcl/registration/gicp.h b/registration/include/pcl/registration/gicp.h index d39c8d16892..c26688197c1 100644 --- a/registration/include/pcl/registration/gicp.h +++ b/registration/include/pcl/registration/gicp.h @@ -186,10 +186,11 @@ class GeneralizedIterativeClosestPoint /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using an iterative non-linear Levenberg-Marquardt approach. \param[in] * cloud_src the source point cloud dataset \param[in] indices_src the vector of - * indices describing the points of interest in \a cloud_src \param[in] cloud_tgt the - * target point cloud dataset \param[in] indices_tgt the vector of indices describing - * the correspondences of the interest points from \a indices_src \param[out] - * transformation_matrix the resultant transformation matrix + * indices describing the points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing + * the correspondences of the interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ void estimateRigidTransformationBFGS(const PointCloudSource& cloud_src, @@ -275,7 +276,7 @@ class GeneralizedIterativeClosestPoint } /** \brief Set the minimal translation gradient threshold for early optimization stop - * \param[in] translation gradient threshold in meters + * \param[in] tolerance translation gradient threshold in meters */ void setTranslationGradientTolerance(double tolerance) @@ -293,7 +294,7 @@ class GeneralizedIterativeClosestPoint } /** \brief Set the minimal rotation gradient threshold for early optimization stop - * \param[in] rotation gradient threshold in radians + * \param[in] tolerance rotation gradient threshold in radians */ void setRotationGradientTolerance(double tolerance) diff --git a/registration/include/pcl/registration/transformation_estimation.h b/registration/include/pcl/registration/transformation_estimation.h index c07ae01af85..d77c8931b34 100644 --- a/registration/include/pcl/registration/transformation_estimation.h +++ b/registration/include/pcl/registration/transformation_estimation.h @@ -93,8 +93,8 @@ class TransformationEstimation { * indices_src the vector of indices describing the points of interest in \a cloud_src * \param[in] cloud_tgt the target point cloud dataset * \param[in] indices_tgt the vector of indices describing the correspondences of the - * interest points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ virtual void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_2D.h b/registration/include/pcl/registration/transformation_estimation_2D.h index 6729f60be5c..6772f87298d 100644 --- a/registration/include/pcl/registration/transformation_estimation_2D.h +++ b/registration/include/pcl/registration/transformation_estimation_2D.h @@ -80,9 +80,9 @@ class TransformationEstimation2D /** \brief Estimate a rigid transformation between a source and a target point cloud * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] indices_src - * the vector of indices describing the points of interest in \a cloud_src \param[in] - * cloud_tgt the target point cloud dataset \param[out] transformation_matrix the - * resultant transformation matrix + * the vector of indices describing the points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -92,9 +92,10 @@ class TransformationEstimation2D /** \brief Estimate a rigid transformation between a source and a target point cloud * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] indices_src - * the vector of indices describing the points of interest in \a cloud_src \param[in] - * cloud_tgt the target point cloud dataset \param[in] indices_tgt the vector of - * indices describing the correspondences of the interest points from \a indices_src + * the vector of indices describing the points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src * \param[out] transformation_matrix the resultant transformation matrix */ virtual void diff --git a/registration/include/pcl/registration/transformation_estimation_3point.h b/registration/include/pcl/registration/transformation_estimation_3point.h index 8ee7ab0aae9..2441fd93a8d 100644 --- a/registration/include/pcl/registration/transformation_estimation_3point.h +++ b/registration/include/pcl/registration/transformation_estimation_3point.h @@ -100,8 +100,8 @@ class TransformationEstimation3Point * indices_src the vector of indices describing the points of interest in \a cloud_src * \param[in] cloud_tgt the target point cloud dataset * \param[in] indices_tgt the vector of indices describing the correspondences of the - * interest points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_dq.h b/registration/include/pcl/registration/transformation_estimation_dq.h index 4c7512c0b62..955fcfa24a8 100644 --- a/registration/include/pcl/registration/transformation_estimation_dq.h +++ b/registration/include/pcl/registration/transformation_estimation_dq.h @@ -83,8 +83,9 @@ class TransformationEstimationDQ /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using dual quaternion optimization \param[in] cloud_src the source * point cloud dataset \param[in] indices_src the vector of indices describing the - * points of interest in \a cloud_src \param[in] cloud_tgt the target point cloud - * dataset \param[out] transformation_matrix the resultant transformation matrix + * points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -95,10 +96,11 @@ class TransformationEstimationDQ /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using dual quaternion optimization \param[in] cloud_src the source * point cloud dataset \param[in] indices_src the vector of indices describing the - * points of interest in \a cloud_src \param[in] cloud_tgt the target point cloud - * dataset \param[in] indices_tgt the vector of indices describing the correspondences - * of the interest points from \a indices_src \param[out] transformation_matrix the - * resultant transformation matrix + * points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h b/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h index e52937af88d..2b154120228 100644 --- a/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h +++ b/registration/include/pcl/registration/transformation_estimation_dual_quaternion.h @@ -80,8 +80,9 @@ class TransformationEstimationDualQuaternion /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using dual quaternion optimization \param[in] cloud_src the source * point cloud dataset \param[in] indices_src the vector of indices describing the - * points of interest in \a cloud_src \param[in] cloud_tgt the target point cloud - * dataset \param[out] transformation_matrix the resultant transformation matrix + * points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -92,10 +93,11 @@ class TransformationEstimationDualQuaternion /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using dual quaternion optimization \param[in] cloud_src the source * point cloud dataset \param[in] indices_src the vector of indices describing the - * points of interest in \a cloud_src \param[in] cloud_tgt the target point cloud - * dataset \param[in] indices_tgt the vector of indices describing the correspondences - * of the interest points from \a indices_src \param[out] transformation_matrix the - * resultant transformation matrix + * points of interest in \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_lm.h b/registration/include/pcl/registration/transformation_estimation_lm.h index 2680f6460bd..b2a0e185273 100644 --- a/registration/include/pcl/registration/transformation_estimation_lm.h +++ b/registration/include/pcl/registration/transformation_estimation_lm.h @@ -119,8 +119,9 @@ class TransformationEstimationLM /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using LM. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out] - * transformation_matrix the resultant transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -131,10 +132,11 @@ class TransformationEstimationLM /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using LM. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in] - * indices_tgt the vector of indices describing the correspondences of the interest - * points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h b/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h index c41ec430000..a1f6bdbd14f 100644 --- a/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h +++ b/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls.h @@ -87,8 +87,9 @@ class TransformationEstimationPointToPlaneLLS /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out] - * transformation_matrix the resultant transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -99,10 +100,11 @@ class TransformationEstimationPointToPlaneLLS /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in] - * indices_tgt the vector of indices describing the correspondences of the interest - * points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls_weighted.h b/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls_weighted.h index f04415b2caa..645b0d45cde 100644 --- a/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls_weighted.h +++ b/registration/include/pcl/registration/transformation_estimation_point_to_plane_lls_weighted.h @@ -90,8 +90,9 @@ class TransformationEstimationPointToPlaneLLSWeighted /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out] - * transformation_matrix the resultant transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -102,10 +103,11 @@ class TransformationEstimationPointToPlaneLLSWeighted /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in] - * indices_tgt the vector of indices describing the correspondences of the interest - * points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_point_to_plane_weighted.h b/registration/include/pcl/registration/transformation_estimation_point_to_plane_weighted.h index 03a360736f7..4ebf6a9b33c 100644 --- a/registration/include/pcl/registration/transformation_estimation_point_to_plane_weighted.h +++ b/registration/include/pcl/registration/transformation_estimation_point_to_plane_weighted.h @@ -131,9 +131,10 @@ class TransformationEstimationPointToPlaneWeighted /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using LM. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out] - * transformation_matrix the resultant transformation matrix \note Uses the weights - * given by setWeights. + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix + * \note Uses the weights given by setWeights. */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -144,10 +145,12 @@ class TransformationEstimationPointToPlaneWeighted /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using LM. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in] - * indices_tgt the vector of indices describing the correspondences of the interest - * points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix \note Uses the weights given by setWeights. + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix + * \note Uses the weights given by setWeights. */ void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_svd.h b/registration/include/pcl/registration/transformation_estimation_svd.h index e6d003abef7..414c7bb2218 100644 --- a/registration/include/pcl/registration/transformation_estimation_svd.h +++ b/registration/include/pcl/registration/transformation_estimation_svd.h @@ -83,8 +83,9 @@ class TransformationEstimationSVD /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out] - * transformation_matrix the resultant transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -95,10 +96,11 @@ class TransformationEstimationSVD /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in] - * indices_tgt the vector of indices describing the correspondences of the interest - * points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h b/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h index 9bf47a8c894..076281e2e77 100644 --- a/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h +++ b/registration/include/pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h @@ -88,8 +88,9 @@ class TransformationEstimationSymmetricPointToPlaneLLS /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out] - * transformation_matrix the resultant transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, @@ -100,10 +101,11 @@ class TransformationEstimationSymmetricPointToPlaneLLS /** \brief Estimate a rigid rotation transformation between a source and a target * point cloud using SVD. \param[in] cloud_src the source point cloud dataset * \param[in] indices_src the vector of indices describing the points of interest in - * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in] - * indices_tgt the vector of indices describing the correspondences of the interest - * points from \a indices_src \param[out] transformation_matrix the resultant - * transformation matrix + * \a cloud_src + * \param[in] cloud_tgt the target point cloud dataset + * \param[in] indices_tgt the vector of indices describing the correspondences of the + * interest points from \a indices_src + * \param[out] transformation_matrix the resultant transformation matrix */ inline void estimateRigidTransformation(const pcl::PointCloud& cloud_src, diff --git a/segmentation/include/pcl/segmentation/extract_labeled_clusters.h b/segmentation/include/pcl/segmentation/extract_labeled_clusters.h index cd9594b6cf4..d65beacad7d 100644 --- a/segmentation/include/pcl/segmentation/extract_labeled_clusters.h +++ b/segmentation/include/pcl/segmentation/extract_labeled_clusters.h @@ -68,14 +68,18 @@ void extractLabeledEuclideanClusters( unsigned int max_label); /** \brief Decompose a region of space into clusters based on the Euclidean distance - * between points \param[in] cloud the point cloud message \param[in] tree the spatial - * locator (e.g., kd-tree) used for nearest neighbors searching \note the tree has to be - * created as a spatial locator on \a cloud \param[in] tolerance the spatial cluster - * tolerance as a measure in L2 Euclidean space \param[out] labeled_clusters the - * resultant clusters containing point indices (as a vector of PointIndices) \param[in] - * min_pts_per_cluster minimum number of points that a cluster may contain (default: 1) + * between points + * \param[in] cloud the point cloud message + * \param[in] tree the spatial locator (e.g., kd-tree) used for nearest neighbors + * searching \note the tree has to be created as a spatial locator on \a cloud + * \param[in] tolerance the spatial cluster tolerance as a measure in L2 Euclidean space + * \param[out] labeled_clusters the resultant clusters containing point indices + * (as a vector of PointIndices) + * \param[in] min_pts_per_cluster minimum number of points that a cluster may contain + * (default: 1) * \param[in] max_pts_per_cluster maximum number of points that a cluster may contain - * (default: max int) \ingroup segmentation + * (default: max int) + * \ingroup segmentation */ template void From 9db86d4e2d832e9f6aee6fdf74c41422c6d8f7dd Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 28 Mar 2021 12:05:56 +0200 Subject: [PATCH 075/431] Better random point count generation --- test/io/test_octree_compression.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/io/test_octree_compression.cpp b/test/io/test_octree_compression.cpp index ca65c61dd22..e71305300f0 100644 --- a/test/io/test_octree_compression.cpp +++ b/test/io/test_octree_compression.cpp @@ -65,10 +65,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) // iterate over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - int point_count; - do { // empty point cloud hangs decoder - point_count = MAX_POINTS * rand() / RAND_MAX; - } while (point_count < 1); + // empty point cloud hangs decoder + const int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; // create shared pointcloud instances pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); // assign input point clouds to octree @@ -121,10 +119,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZ) // loop over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - int point_count; - do { // empty point cloud hangs decoder - point_count = MAX_POINTS * rand() / RAND_MAX; - } while (point_count < 1); + // empty point cloud hangs decoder + const int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; // create shared pointcloud instances pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); // assign input point clouds to octree @@ -168,10 +164,8 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBASameCloud) pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); pcl::io::OctreePointCloudCompression pointcloud_decoder; - int point_count; - do { // empty point cloud hangs decoder - point_count = MAX_POINTS * rand() / RAND_MAX; - } while (point_count < 1); + // empty point cloud hangs decoder + const int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; // create shared pointcloud instances pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); // assign input point clouds to octree From 2069e88a6891e8173f7299cf58eee946edc013ac Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Sun, 28 Mar 2021 21:04:56 +0200 Subject: [PATCH 076/431] Only set QT_NO_DEBUG flag when in Release build --- apps/cloud_composer/ComposerTool.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cloud_composer/ComposerTool.cmake b/apps/cloud_composer/ComposerTool.cmake index 6ba49c8d7db..cfef108043d 100644 --- a/apps/cloud_composer/ComposerTool.cmake +++ b/apps/cloud_composer/ComposerTool.cmake @@ -16,7 +16,7 @@ function(define_composer_tool TOOL_NAME TOOL_SOURCES TOOL_HEADERS DEPS) endif() add_definitions(${QT_DEFINITIONS}) add_definitions(-DQT_PLUGIN) - add_definitions(-DQT_NO_DEBUG) + target_compile_definitions(${TOOL_TARGET} PUBLIC $<$:-DQT_NO_DEBUG>) add_definitions(-DQT_SHARED) target_link_libraries(${TOOL_TARGET} pcl_cc_tool_interface pcl_common pcl_io ${DEPS} Qt5::Widgets) From 0f8bee9e7c19b42f344e37cc42d2969f1c94bcf2 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Sun, 28 Mar 2021 21:44:02 +0200 Subject: [PATCH 077/431] [CMake] Enable to select flann build type as either dontcare, static or shared. (#4651) * Enable to select flann build type as either dontcare, static or shared. --- CMakeLists.txt | 6 +-- cmake/Modules/FindFLANN.cmake | 96 +++++++++++++++++++++++++++++------ cmake/pcl_options.cmake | 6 ++- 3 files changed, 87 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f45db158816..9997b151655 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,10 +299,10 @@ find_package(Eigen 3.1 REQUIRED) include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS}) # FLANN (required) -if(NOT PCL_SHARED_LIBS OR ((WIN32 AND NOT MINGW) AND NOT PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32)) - set(FLANN_USE_STATIC ON) -endif() find_package(FLANN 1.7.0 REQUIRED) +if(NOT (${FLANN_LIBRARY_TYPE} MATCHES ${PCL_FLANN_REQUIRED_TYPE}) AND NOT (${PCL_FLANN_REQUIRED_TYPE} MATCHES "DONTCARE")) + message(FATAL_ERROR "Flann was selected with ${PCL_FLANN_REQUIRED_TYPE} but found as ${FLANN_LIBRARY_TYPE}") +endif() # libusb option(WITH_LIBUSB "Build USB RGBD-Camera drivers" TRUE) diff --git a/cmake/Modules/FindFLANN.cmake b/cmake/Modules/FindFLANN.cmake index fd15d1bb75f..a87f9c61779 100644 --- a/cmake/Modules/FindFLANN.cmake +++ b/cmake/Modules/FindFLANN.cmake @@ -42,16 +42,38 @@ endif() # First try to locate FLANN using modern config find_package(flann NO_MODULE ${FLANN_FIND_VERSION} QUIET) + if(flann_FOUND) unset(flann_FOUND) set(FLANN_FOUND ON) + # Create interface library that effectively becomes an alias for the appropriate (static/dynamic) imported FLANN target add_library(FLANN::FLANN INTERFACE IMPORTED) - if(FLANN_USE_STATIC) + + if(TARGET flann::flann_cpp_s AND TARGET flann::flann_cpp) + if(PCL_FLANN_REQUIRED_TYPE MATCHES "DONTCARE") + if(PCL_SHARED_LIBS) + set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES flann::flann_cpp) + set(FLANN_LIBRARY_TYPE SHARED) + else() + set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES flann::flann_cpp_s) + set(FLANN_LIBRARY_TYPE STATIC) + endif() + elseif(PCL_FLANN_REQUIRED_TYPE MATCHES "SHARED") + set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES flann::flann_cpp) + set(FLANN_LIBRARY_TYPE SHARED) + else() + set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES flann::flann_cpp_s) + set(FLANN_LIBRARY_TYPE STATIC) + endif() + elseif(TARGET flann::flann_cpp_s) set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES flann::flann_cpp_s) + set(FLANN_LIBRARY_TYPE STATIC) else() set_property(TARGET FLANN::FLANN APPEND PROPERTY INTERFACE_LINK_LIBRARIES flann::flann_cpp) + set(FLANN_LIBRARY_TYPE SHARED) endif() + # Determine FLANN installation root based on the path to the processed Config file get_filename_component(_config_dir "${flann_CONFIG}" DIRECTORY) get_filename_component(FLANN_ROOT "${_config_dir}/../../.." ABSOLUTE) @@ -82,19 +104,23 @@ find_path(FLANN_INCLUDE_DIR include ) -if(FLANN_USE_STATIC) - set(FLANN_RELEASE_NAME flann_cpp_s) - set(FLANN_DEBUG_NAME flann_cpp_s-gd) - set(FLANN_LIBRARY_TYPE STATIC) -else() - set(FLANN_RELEASE_NAME flann_cpp) - set(FLANN_DEBUG_NAME flann_cpp-gd) - set(FLANN_LIBRARY_TYPE SHARED) -endif() +find_library(FLANN_LIBRARY_SHARED + NAMES + flann_cpp + HINTS + ${PC_FLANN_LIBRARY_DIRS} + ${FLANN_ROOT} + $ENV{FLANN_ROOT} + PATHS + $ENV{PROGRAMFILES}/Flann + $ENV{PROGRAMW6432}/Flann + PATH_SUFFIXES + lib +) -find_library(FLANN_LIBRARY +find_library(FLANN_LIBRARY_DEBUG_SHARED NAMES - ${FLANN_RELEASE_NAME} + flann_cpp-gd flann_cppd HINTS ${PC_FLANN_LIBRARY_DIRS} ${FLANN_ROOT} @@ -106,9 +132,9 @@ find_library(FLANN_LIBRARY lib ) -find_library(FLANN_LIBRARY_DEBUG +find_library(FLANN_LIBRARY_STATIC NAMES - ${FLANN_DEBUG_NAME} + flann_cpp_s HINTS ${PC_FLANN_LIBRARY_DIRS} ${FLANN_ROOT} @@ -120,6 +146,44 @@ find_library(FLANN_LIBRARY_DEBUG lib ) +find_library(FLANN_LIBRARY_DEBUG_STATIC + NAMES + flann_cpp_s-gd flann_cpp_sd + HINTS + ${PC_FLANN_LIBRARY_DIRS} + ${FLANN_ROOT} + $ENV{FLANN_ROOT} + PATHS + $ENV{PROGRAMFILES}/Flann + $ENV{PROGRAMW6432}/Flann + PATH_SUFFIXES + lib +) + +if(FLANN_LIBRARY_SHARED AND FLANN_LIBRARY_STATIC) + if(PCL_FLANN_REQUIRED_TYPE MATCHES "DONTCARE") + if(PCL_SHARED_LIBS) + set(FLANN_LIBRARY_TYPE SHARED) + set(FLANN_LIBRARY ${FLANN_LIBRARY_SHARED}) + else() + set(FLANN_LIBRARY_TYPE STATIC) + set(FLANN_LIBRARY ${FLANN_LIBRARY_STATIC}) + endif() + elseif(PCL_FLANN_REQUIRED_TYPE MATCHES "SHARED") + set(FLANN_LIBRARY_TYPE SHARED) + set(FLANN_LIBRARY ${FLANN_LIBRARY_SHARED}) + else() + set(FLANN_LIBRARY_TYPE STATIC) + set(FLANN_LIBRARY ${FLANN_LIBRARY_STATIC}) + endif() +elseif(FLANN_LIBRARY_STATIC) + set(FLANN_LIBRARY_TYPE STATIC) + set(FLANN_LIBRARY ${FLANN_LIBRARY_STATIC}) +elseif(FLANN_LIBRARY_SHARED) + set(FLANN_LIBRARY_TYPE SHARED) + set(FLANN_LIBRARY ${FLANN_LIBRARY_SHARED}) +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args( FLANN DEFAULT_MSG @@ -132,7 +196,7 @@ if(FLANN_FOUND) set_target_properties(FLANN::FLANN PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${PC_FLANN_CFLAGS_OTHER}") set_property(TARGET FLANN::FLANN APPEND PROPERTY IMPORTED_CONFIGURATIONS "RELEASE") set_target_properties(FLANN::FLANN PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX") - if(WIN32 AND NOT FLANN_USE_STATIC) + if(WIN32 AND (NOT FLANN_LIBRARY_TYPE MATCHES "STATIC")) set_target_properties(FLANN::FLANN PROPERTIES IMPORTED_IMPLIB_RELEASE "${FLANN_LIBRARY}") else() set_target_properties(FLANN::FLANN PROPERTIES IMPORTED_LOCATION_RELEASE "${FLANN_LIBRARY}") @@ -140,7 +204,7 @@ if(FLANN_FOUND) if(FLANN_LIBRARY_DEBUG) set_property(TARGET FLANN::FLANN APPEND PROPERTY IMPORTED_CONFIGURATIONS "DEBUG") set_target_properties(FLANN::FLANN PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX") - if(WIN32 AND NOT FLANN_USE_STATIC) + if(WIN32 AND (NOT FLANN_LIBRARY_TYPE MATCHES "STATIC")) set_target_properties(FLANN::FLANN PROPERTIES IMPORTED_IMPLIB_DEBUG "${FLANN_LIBRARY_DEBUG}") else() set_target_properties(FLANN::FLANN PROPERTIES IMPORTED_LOCATION_DEBUG "${FLANN_LIBRARY_DEBUG}") diff --git a/cmake/pcl_options.cmake b/cmake/pcl_options.cmake index 52b590f974f..b8e023486f2 100644 --- a/cmake/pcl_options.cmake +++ b/cmake/pcl_options.cmake @@ -22,8 +22,10 @@ mark_as_advanced(PCL_SHARED_LIBS) option(PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32 "Build against a dynamically linked Boost on Win32 platforms." OFF) mark_as_advanced(PCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32) -# Build with dynamic linking for FLANN (advanced users) -option(PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32 "Build against a dynamically linked FLANN on Win32 platforms." OFF) +# Build with shared/static linking for FLANN (advanced users) +set(PCL_FLANN_REQUIRED_TYPE "DONTCARE" CACHE STRING "Select build type to use (STATIC/SHARED).") +set_property(CACHE PCL_FLANN_REQUIRED_TYPE PROPERTY STRINGS DONTCARE SHARED STATIC) + mark_as_advanced(PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32) # Build with dynamic linking for QHull (advanced users) From 7ca2d32e1d6630e821b939a323030fda13a146dd Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Fri, 2 Apr 2021 14:11:16 +0200 Subject: [PATCH 078/431] [CI] Add windows docker file (#4428) * Add windows docker build --- .ci/azure-pipelines/env.yml | 71 ++++++++++++++++++++--- .dev/docker/windows/Dockerfile | 47 +++++++++++++++ .dev/docker/windows/x64-windows-rel.cmake | 4 ++ .dev/docker/windows/x86-windows-rel.cmake | 4 ++ 4 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 .dev/docker/windows/Dockerfile create mode 100644 .dev/docker/windows/x64-windows-rel.cmake create mode 100644 .dev/docker/windows/x86-windows-rel.cmake diff --git a/.ci/azure-pipelines/env.yml b/.ci/azure-pipelines/env.yml index 1fe345fa180..00ca0a80288 100644 --- a/.ci/azure-pipelines/env.yml +++ b/.ci/azure-pipelines/env.yml @@ -9,12 +9,14 @@ trigger: paths: include: - .dev/docker/env/Dockerfile + - .dev/docker/windows - .ci/azure-pipelines/env.yml pr: paths: include: - .dev/docker/env/Dockerfile + - .dev/docker/windows - .ci/azure-pipelines/env.yml schedules: @@ -32,7 +34,7 @@ variables: dockerHubID: "pointcloudlibrary" jobs: -- job: BuildAndPush +- job: BuildAndPushUbuntu timeoutInMinutes: 360 displayName: "Env" pool: @@ -44,27 +46,27 @@ jobs: UBUNTU_DISTRO: 18.04 USE_CUDA: true VTK_VERSION: 6 - tag: 18.04 + TAG: 18.04 Ubuntu 20.04: CUDA_VERSION: 11.2.1 UBUNTU_DISTRO: 20.04 VTK_VERSION: 7 USE_CUDA: true - tag: 20.04 + TAG: 20.04 Ubuntu 20.10: CUDA_VERSION: 11.2.1 UBUNTU_DISTRO: 20.10 VTK_VERSION: 7 # nvidia-cuda docker image has not been released for 20.10 yet USE_CUDA: "" - tag: 20.10 + TAG: 20.10 Ubuntu 21.04: CUDA_VERSION: 11.2.1 UBUNTU_DISTRO: 21.04 VTK_VERSION: 9 # nvidia-cuda docker image has not been released for 21.04 yet USE_CUDA: "" - tag: 21.04 + TAG: 21.04 steps: - task: Docker@2 displayName: "Build docker image" @@ -76,12 +78,12 @@ jobs: --build-arg UBUNTU_DISTRO=$(UBUNTU_DISTRO) --build-arg USE_CUDA=$(USE_CUDA) --build-arg VTK_VERSION=$(VTK_VERSION) - -t $(dockerHubID)/env:$(tag) + -t $(dockerHubID)/env:$(TAG) dockerfile: '$(Build.SourcesDirectory)/.dev/docker/env/Dockerfile' - tags: "$(tag)" + tags: "$(TAG)" - script: | set -x - docker run --rm -v "$(Build.SourcesDirectory)":/pcl $(dockerHubID)/env:$(tag) bash -c ' \ + docker run --rm -v "$(Build.SourcesDirectory)":/pcl $(dockerHubID)/env:$(TAG) bash -c ' \ mkdir /pcl/build && cd /pcl/build && \ cmake /pcl \ -DCMAKE_BUILD_TYPE="Release" \ @@ -96,6 +98,57 @@ jobs: command: push containerRegistry: $(dockerHub) repository: $(dockerHubID)/env - tags: "$(tag)" + tags: "$(TAG)" + condition: and(eq(variables['Build.Repository.Name'], 'PointCloudLibrary/pcl'), + eq(variables['Build.SourceBranch'], 'refs/heads/master')) +- job: BuildAndPushWindows + timeoutInMinutes: 360 + displayName: "Env" + pool: + vmImage: 'windows-2019' + strategy: + matrix: + Winx86: + PLATFORM: x86 + TAG: winx86 + GENERATOR: "'Visual Studio 16 2019' -A Win32" + VCPKGCOMMIT: 2bc10eae2fb0b8c7c098325c4e9d82aa5d0329d9 + Winx64: + PLATFORM: x64 + TAG: winx64 + GENERATOR: "'Visual Studio 16 2019' -A x64" + VCPKGCOMMIT: master + steps: + - task: Docker@2 + displayName: "Build docker image" + inputs: + command: build + arguments: | + --no-cache + --build-arg PLATFORM=$(PLATFORM) + --build-arg VCPKGCOMMIT=$(VCPKGCOMMIT) + -t $(dockerHubID)/env:$(TAG) + dockerfile: '$(Build.SourcesDirectory)/.dev/docker/windows/Dockerfile' + tags: "$(TAG)" + + - script: > + docker run --rm -v "$(Build.SourcesDirectory)":c:\pcl $(dockerHubID)/env:$(TAG) + powershell -command "mkdir c:\pcl\build; cd c:\pcl\build; + cmake c:\pcl -G$(GENERATOR) + -DVCPKG_TARGET_TRIPLET=$(PLATFORM)-windows-rel + -DCMAKE_BUILD_TYPE='Release' + -DCMAKE_TOOLCHAIN_FILE=c:\vcpkg\scripts\buildsystems\vcpkg.cmake + -DPCL_ONLY_CORE_POINT_TYPES=ON + -DBUILD_io:BOOL=OFF + -DBUILD_kdtree:BOOL=OFF; + cmake --build . " + displayName: 'Verify Dockerimage' + - task: Docker@2 + displayName: "Push docker image" + inputs: + command: push + containerRegistry: $(dockerHub) + repository: $(dockerHubID)/env + tags: "$(TAG)" condition: and(eq(variables['Build.Repository.Name'], 'PointCloudLibrary/pcl'), eq(variables['Build.SourceBranch'], 'refs/heads/master')) diff --git a/.dev/docker/windows/Dockerfile b/.dev/docker/windows/Dockerfile new file mode 100644 index 00000000000..81047508383 --- /dev/null +++ b/.dev/docker/windows/Dockerfile @@ -0,0 +1,47 @@ +# escape=` + +FROM mcr.microsoft.com/windows/servercore:ltsc2019 + +# Use "--build-arg platform=x64" for 64 bit or x86 for 32 bit. +ARG PLATFORM + +# Use to set specific commit to checkout +ARG VCPKGCOMMIT + +# Download channel for fixed install. +ARG CHANNEL_BASE_URL=https://aka.ms/vs/16/release + +ADD $CHANNEL_BASE_URL/channel C:\TEMP\VisualStudio.chman + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# Download and install Build Tools for Visual Studio 2019 for native desktop +RUN wget $Env:CHANNEL_BASE_URL/vs_buildtools.exe -OutFile 'C:\TEMP\vs_buildtools.exe'; ` + Start-Process -FilePath C:\TEMP\vs_buildtools.exe -ArgumentList ` + "--quiet", ` + "--norestart", ` + "--nocache", ` + "--installPath", ` + "C:\BuildTools", ` + "--wait", ` + "--channelUri", ` + "C:\TEMP\VisualStudio.chman", ` + "--installChannelUri", ` + "C:\TEMP\VisualStudio.chman", ` + "--add", ` + "Microsoft.VisualStudio.Workload.VCTools", ` + "--includeRecommended" ` + -Wait -PassThru; ` + del c:\temp\vs_buildtools.exe; + +RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); ` + choco install cmake git --installargs 'ADD_CMAKE_TO_PATH=System' -y --no-progress + +RUN git clone https://github.com/microsoft/vcpkg.git; cd vcpkg; git checkout $Env:VCPKGCOMMIT; + +# To explicit set VCPKG to only build Release version of the libraries. +COPY $PLATFORM'-windows-rel.cmake' 'c:\vcpkg\triplets\'$PLATFORM'-windows-rel.cmake' + +RUN cd .\vcpkg; ` + .\bootstrap-vcpkg.bat; ` + .\vcpkg install boost flann eigen3 qhull vtk[qt,opengl] gtest --triplet $Env:PLATFORM-windows-rel --clean-after-build; diff --git a/.dev/docker/windows/x64-windows-rel.cmake b/.dev/docker/windows/x64-windows-rel.cmake new file mode 100644 index 00000000000..f6c40253a08 --- /dev/null +++ b/.dev/docker/windows/x64-windows-rel.cmake @@ -0,0 +1,4 @@ +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE dynamic) +set(VCPKG_BUILD_TYPE release) diff --git a/.dev/docker/windows/x86-windows-rel.cmake b/.dev/docker/windows/x86-windows-rel.cmake new file mode 100644 index 00000000000..0a277bdb77b --- /dev/null +++ b/.dev/docker/windows/x86-windows-rel.cmake @@ -0,0 +1,4 @@ +set(VCPKG_TARGET_ARCHITECTURE x86) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE dynamic) +set(VCPKG_BUILD_TYPE release) From e377982458784babbe032c185b178f7fb61b5cb3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 2 Apr 2021 18:30:52 +0200 Subject: [PATCH 079/431] Remove all deprecated for version 1.12 --- common/include/pcl/common/io.h | 19 +-- common/src/io.cpp | 109 -------------- io/include/pcl/io/grabber.h | 12 -- kdtree/CMakeLists.txt | 1 - kdtree/include/pcl/kdtree/flann.h | 53 ------- test/common/test_io.cpp | 199 -------------------------- tracking/include/pcl/tracking/boost.h | 46 ------ 7 files changed, 2 insertions(+), 437 deletions(-) delete mode 100644 kdtree/include/pcl/kdtree/flann.h delete mode 100644 tracking/include/pcl/tracking/boost.h diff --git a/common/include/pcl/common/io.h b/common/include/pcl/common/io.h index ccb6825de37..4e765e4ea20 100644 --- a/common/include/pcl/common/io.h +++ b/common/include/pcl/common/io.h @@ -254,10 +254,8 @@ namespace pcl /** \brief Concatenate two pcl::PCLPointCloud2 * - * \warning This function subtly differs from the deprecated concatenatePointCloud() - * The difference is that this function will concatenate IFF the non-skip fields - * are in the correct order and same in number. The deprecated function skipped - * fields even if both clouds didn't agree on the number of output fields + * \warning This function will concatenate IFF the non-skip fields are in the correct + * order and same in number. * \param[in] cloud1 the first input point cloud dataset * \param[in] cloud2 the second input point cloud dataset * \param[out] cloud_out the resultant output point cloud dataset @@ -287,19 +285,6 @@ namespace pcl return pcl::PolygonMesh::concatenate(mesh1, mesh2, mesh_out); } - /** \brief Concatenate two pcl::PCLPointCloud2 - * \param[in] cloud1 the first input point cloud dataset - * \param[in] cloud2 the second input point cloud dataset - * \param[out] cloud_out the resultant output point cloud dataset - * \return true if successful, false otherwise (e.g., name/number of fields differs) - * \ingroup common - */ - PCL_DEPRECATED(1, 12, "use pcl::concatenate() instead, but beware of subtle difference in behavior (see documentation)") - PCL_EXPORTS bool - concatenatePointCloud (const pcl::PCLPointCloud2 &cloud1, - const pcl::PCLPointCloud2 &cloud2, - pcl::PCLPointCloud2 &cloud_out); - /** \brief Extract the indices of a given point cloud as a new point cloud * \param[in] cloud_in the input point cloud dataset * \param[in] indices the vector of indices representing the points to be copied from \a cloud_in diff --git a/common/src/io.cpp b/common/src/io.cpp index 838ab1c37a5..76841aecbb7 100644 --- a/common/src/io.cpp +++ b/common/src/io.cpp @@ -213,115 +213,6 @@ pcl::concatenateFields (const pcl::PCLPointCloud2 &cloud1, return (true); } -////////////////////////////////////////////////////////////////////////// -bool -pcl::concatenatePointCloud (const pcl::PCLPointCloud2 &cloud1, - const pcl::PCLPointCloud2 &cloud2, - pcl::PCLPointCloud2 &cloud_out) -{ - //if one input cloud has no points, but the other input does, just return the cloud with points - if (cloud1.width*cloud1.height == 0 && cloud2.width*cloud2.height > 0) - { - cloud_out = cloud2; - return (true); - } - if (cloud1.width*cloud1.height > 0 && cloud2.width*cloud2.height == 0) - { - cloud_out = cloud1; - return (true); - } - - bool strip = false; - for (const auto &field : cloud1.fields) - if (field.name == "_") - strip = true; - - for (const auto &field : cloud2.fields) - if (field.name == "_") - strip = true; - - if (!strip && cloud1.fields.size () != cloud2.fields.size ()) - { - PCL_ERROR ("[pcl::concatenatePointCloud] Number of fields in cloud1 (%u) != Number of fields in cloud2 (%u)\n", cloud1.fields.size (), cloud2.fields.size ()); - return (false); - } - - // Copy cloud1 into cloud_out - cloud_out = cloud1; - std::size_t nrpts = cloud_out.data.size (); - // Height = 1 => no more organized - cloud_out.width = cloud1.width * cloud1.height + cloud2.width * cloud2.height; - cloud_out.height = 1; - if (!cloud1.is_dense || !cloud2.is_dense) - cloud_out.is_dense = false; - else - cloud_out.is_dense = true; - - // We need to strip the extra padding fields - if (strip) - { - // Get the field sizes for the second cloud - std::vector fields2; - std::vector fields2_sizes; - for (const auto &field : cloud2.fields) - { - if (field.name == "_") - continue; - - fields2_sizes.push_back (field.count * - pcl::getFieldSize (field.datatype)); - fields2.push_back (field); - } - - cloud_out.data.resize (nrpts + (cloud2.width * cloud2.height) * cloud_out.point_step); - - // Copy the second cloud - for (uindex_t cp = 0; cp < cloud2.width * cloud2.height; ++cp) - { - int i = 0; - for (std::size_t j = 0; j < fields2.size (); ++j) - { - if (cloud1.fields[i].name == "_") - { - ++i; - continue; - } - - // We're fine with the special RGB vs RGBA use case - if ((cloud1.fields[i].name == "rgb" && fields2[j].name == "rgba") || - (cloud1.fields[i].name == "rgba" && fields2[j].name == "rgb") || - (cloud1.fields[i].name == fields2[j].name)) - { - memcpy (reinterpret_cast (&cloud_out.data[nrpts + cp * cloud1.point_step + cloud1.fields[i].offset]), - reinterpret_cast (&cloud2.data[cp * cloud2.point_step + cloud2.fields[j].offset]), - fields2_sizes[j]); - ++i; // increment the field size i - } - } - } - } - else - { - for (std::size_t i = 0; i < cloud1.fields.size (); ++i) - { - // We're fine with the special RGB vs RGBA use case - if ((cloud1.fields[i].name == "rgb" && cloud2.fields[i].name == "rgba") || - (cloud1.fields[i].name == "rgba" && cloud2.fields[i].name == "rgb")) - continue; - // Otherwise we need to make sure the names are the same - if (cloud1.fields[i].name != cloud2.fields[i].name) - { - PCL_ERROR ("[pcl::concatenatePointCloud] Name of field %d in cloud1, %s, does not match name in cloud2, %s\n", i, cloud1.fields[i].name.c_str (), cloud2.fields[i].name.c_str ()); - return (false); - } - } - - cloud_out.data.resize (nrpts + cloud2.data.size ()); - memcpy (&cloud_out.data[nrpts], &cloud2.data[0], cloud2.data.size ()); - } - return (true); -} - ////////////////////////////////////////////////////////////////////////// bool pcl::getPointCloudAsEigen (const pcl::PCLPointCloud2 &in, Eigen::MatrixXf &out) diff --git a/io/include/pcl/io/grabber.h b/io/include/pcl/io/grabber.h index 378b81a8e2f..385ae501ebc 100644 --- a/io/include/pcl/io/grabber.h +++ b/io/include/pcl/io/grabber.h @@ -98,18 +98,6 @@ namespace pcl template boost::signals2::connection registerCallback (const std::function& callback); - /** \brief registers a callback function/method to a signal with the corresponding signature - * \param[in] callback: the callback function/method - * \return Connection object, that can be used to disconnect the callback method from the signal again. - */ - template class FunctionT> - PCL_DEPRECATED (1, 12, "please assign the callback to a std::function.") - boost::signals2::connection - registerCallback (const FunctionT& callback) - { - return registerCallback (std::function (callback)); - } - /** \brief indicates whether a signal with given parameter-type exists or not * \return true if signal exists, false otherwise */ diff --git a/kdtree/CMakeLists.txt b/kdtree/CMakeLists.txt index 826e902663d..a5a0fb9b8ec 100644 --- a/kdtree/CMakeLists.txt +++ b/kdtree/CMakeLists.txt @@ -19,7 +19,6 @@ set(srcs set(incs "include/pcl/${SUBSYS_NAME}/kdtree.h" "include/pcl/${SUBSYS_NAME}/io.h" - "include/pcl/${SUBSYS_NAME}/flann.h" "include/pcl/${SUBSYS_NAME}/kdtree_flann.h" ) diff --git a/kdtree/include/pcl/kdtree/flann.h b/kdtree/include/pcl/kdtree/flann.h deleted file mode 100644 index a49048d05ea..00000000000 --- a/kdtree/include/pcl/kdtree/flann.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2012, Willow Garage, Inc. - * Copyright (c) 2012-, Open Perception, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of the copyright holder(s) nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#pragma once - -#include - -PCL_DEPRECATED_HEADER(1, 12, "") - -#if defined _MSC_VER -# pragma warning(disable: 4267 4244) -#endif - -#include - -#if defined _MSC_VER -# pragma warning(default: 4267) -#endif diff --git a/test/common/test_io.cpp b/test/common/test_io.cpp index 6199fccc8a6..efdc8245b7b 100644 --- a/test/common/test_io.cpp +++ b/test/common/test_io.cpp @@ -128,205 +128,6 @@ TEST (PCL, copyPointCloud) } } -/////////////////////////////////////////////////////////////////////////////////////////// -// Ignore deprecation warnings on MSVC and GNU C Compiler -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4996) -#elif defined __GNUC__ -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#pragma GCC diagnostic push -#endif -TEST (PCL, concatenatePointCloud) -{ - CloudXYZRGBA cloud_xyz_rgba; - cloud_xyz_rgba.push_back (pt_xyz_rgba); - cloud_xyz_rgba.push_back (pt_xyz_rgba); - cloud_xyz_rgba.push_back (pt_xyz_rgba); - cloud_xyz_rgba.push_back (pt_xyz_rgba); - cloud_xyz_rgba.push_back (pt_xyz_rgba); - - CloudXYZRGBA cloud_xyz_rgba2; - cloud_xyz_rgba2.push_back (pt_xyz_rgba2); - cloud_xyz_rgba2.push_back (pt_xyz_rgba2); - - pcl::PCLPointCloud2 cloud1, cloud2, cloud_out, cloud_out2, cloud_out3, cloud_out4; - pcl::toPCLPointCloud2 (cloud_xyz_rgba, cloud1); - pcl::toPCLPointCloud2 (cloud_xyz_rgba2, cloud2); - - // Regular - pcl::concatenatePointCloud (cloud1, cloud2, cloud_out); - - CloudXYZRGBA cloud_all; - pcl::fromPCLPointCloud2 (cloud_out, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgba2.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgba2[i]); - EXPECT_RGB_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgba2[i]); - EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, cloud_xyz_rgba2[i].rgba); - } - - // RGB != RGBA - CloudXYZRGB cloud_xyz_rgb; - cloud_xyz_rgb.push_back (pt_xyz_rgb); - cloud_xyz_rgb.push_back (pt_xyz_rgb); - - pcl::toPCLPointCloud2 (cloud_xyz_rgb, cloud2); - pcl::concatenatePointCloud (cloud1, cloud2, cloud_out2); - - pcl::fromPCLPointCloud2 (cloud_out2, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgb[i]); - EXPECT_RGB_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgb[i]); - EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, cloud_xyz_rgb[i].rgba); - } - - // _ vs regular - int rgb_idx = pcl::getFieldIndex (cloud1, "rgba"); - cloud1.fields[rgb_idx].name = "_"; - pcl::concatenatePointCloud (cloud1, cloud2, cloud_out3); - - pcl::fromPCLPointCloud2 (cloud_out3, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgba[i]); - // Data doesn't get modified - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i) - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgb[i]); - - cloud1.fields[rgb_idx].name = "rgba"; - // regular vs _ - rgb_idx = pcl::getFieldIndex (cloud2, "rgb"); - cloud2.fields[rgb_idx].name = "_"; - pcl::concatenatePointCloud (cloud1, cloud2, cloud_out4); - - pcl::fromPCLPointCloud2 (cloud_out4, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgba[i]); - // Data doesn't get modified - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgb[i]); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, 0); - EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, 0); - } - - // _ vs _ - rgb_idx = pcl::getFieldIndex (cloud1, "rgba"); - cloud1.fields[rgb_idx].name = "_"; - pcl::toPCLPointCloud2 (cloud_xyz_rgb, cloud2); - rgb_idx = pcl::getFieldIndex (cloud2, "rgb"); - cloud2.fields[rgb_idx].name = "_"; - - pcl::concatenatePointCloud (cloud1, cloud2, cloud_out3); - - pcl::fromPCLPointCloud2 (cloud_out3, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgba[i]); - // Data doesn't get modified - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgba[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgba[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgba.size () + i], cloud_xyz_rgb[i]); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].r, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].g, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgba.size () + i].b, 0); - EXPECT_EQ (cloud_all[cloud_xyz_rgba.size () + i].rgba, 0); - } - - cloud1.fields[rgb_idx].name = "rgba"; - // _ vs regular - rgb_idx = pcl::getFieldIndex (cloud1, "rgba"); - - cloud1.fields[rgb_idx].name = "_"; - pcl::toPCLPointCloud2 (cloud_xyz_rgb, cloud2); - pcl::concatenatePointCloud (cloud2, cloud1, cloud_out3); - - pcl::fromPCLPointCloud2 (cloud_out3, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgb[i]); - // Data doesn't get modified - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgb[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgb[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgb.size () + i], cloud_xyz_rgba[i]); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].r, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].g, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].b, 0); - EXPECT_EQ (cloud_all[cloud_xyz_rgb.size () + i].rgba, 0); - } - - cloud1.fields[rgb_idx].name = "rgba"; - // regular vs _ - rgb_idx = pcl::getFieldIndex (cloud2, "rgb"); - cloud2.fields[rgb_idx].name = "_"; - pcl::concatenatePointCloud (cloud2, cloud1, cloud_out4); - - pcl::fromPCLPointCloud2 (cloud_out4, cloud_all); - - EXPECT_EQ (cloud_all.size (), cloud_xyz_rgba.size () + cloud_xyz_rgba2.size ()); - for (int i = 0; i < int (cloud_xyz_rgb.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[i], cloud_xyz_rgb[i]); - // Data doesn't get modified - EXPECT_RGB_EQ (cloud_all[i], cloud_xyz_rgb[i]); - EXPECT_EQ (cloud_all[i].rgba, cloud_xyz_rgb[i].rgba); - } - for (int i = 0; i < int (cloud_xyz_rgba.size ()); ++i) - { - EXPECT_XYZ_EQ (cloud_all[cloud_xyz_rgb.size () + i], cloud_xyz_rgba[i]); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].r, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].g, 0); - EXPECT_FLOAT_EQ (cloud_all[cloud_xyz_rgb.size () + i].b, 0); - EXPECT_EQ (cloud_all[cloud_xyz_rgb.size () + i].rgba, 0); - } -} -#ifdef _MSC_VER -#pragma warning(pop) -#elif defined __GNUC__ -#pragma GCC diagnostic pop -#endif - /////////////////////////////////////////////////////////////////////////////////////////// TEST (PCL, concatenatePointCloud2) { diff --git a/tracking/include/pcl/tracking/boost.h b/tracking/include/pcl/tracking/boost.h deleted file mode 100644 index 64a8d172e17..00000000000 --- a/tracking/include/pcl/tracking/boost.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2012-, Open Perception, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of the copyright holder(s) nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * $Id: lmeds.h 1370 2011-06-19 01:06:01Z jspricke $ - * - */ - -#pragma once - -#include - -PCL_DEPRECATED_HEADER(1, 12, "") - -#include From 785c046a3f966d64eed2b65811cb062c788e375b Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 2 Apr 2021 18:34:28 +0200 Subject: [PATCH 080/431] Properly deprecate uniform_sampling header in keypoints __DEPRECATED might not be defined, so a user might not receive the warning. Start deprecation cycle again. --- keypoints/include/pcl/keypoints/uniform_sampling.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/keypoints/include/pcl/keypoints/uniform_sampling.h b/keypoints/include/pcl/keypoints/uniform_sampling.h index 4b9da1352c0..66596274997 100644 --- a/keypoints/include/pcl/keypoints/uniform_sampling.h +++ b/keypoints/include/pcl/keypoints/uniform_sampling.h @@ -39,8 +39,6 @@ #pragma once -#ifdef __DEPRECATED -PCL_DEPRECATED_HEADER(1, 12, "UniformSampling is not a Keypoint anymore, use instead.") -#endif +PCL_DEPRECATED_HEADER(1, 15, "UniformSampling is not a Keypoint anymore, use instead.") #include From 8b9dafdea1818fdf04fd9be93d04e39ac2e21d4d Mon Sep 17 00:00:00 2001 From: Yan Hang Date: Mon, 5 Apr 2021 17:14:57 +0800 Subject: [PATCH 081/431] [CI] Exclude doc files from CI to save CI time Fixed #3999. Updates to doc, README, etc. don't run formatting + main CI. --- .ci/azure-pipelines/azure-pipelines.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml index 511e093a8ee..53c61eec242 100644 --- a/.ci/azure-pipelines/azure-pipelines.yaml +++ b/.ci/azure-pipelines/azure-pipelines.yaml @@ -1,3 +1,19 @@ +trigger: + paths: + exclude: + - doc + - README.md + - CHANGES.md + - CONTRIBUTING.md + +pr: + paths: + exclude: + - doc + - README.md + - CHANGES.md + - CONTRIBUTING.md + resources: containers: - container: fmt From 5c8370a18be39cc62719af0bfcaf55f7f534bd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nehil=20Dan=C4=B1=C5=9F?= Date: Mon, 5 Apr 2021 16:36:18 +0200 Subject: [PATCH 082/431] [tracking] made ParticleFilterTracker API user friendly (#4685) * made tracking API user friendly * Used if statement for type check in setUseNormal * Added use_normal is false cases to the condition --- tracking/include/pcl/tracking/particle_filter.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tracking/include/pcl/tracking/particle_filter.h b/tracking/include/pcl/tracking/particle_filter.h index ce3ebf24d31..f4cf99e6113 100644 --- a/tracking/include/pcl/tracking/particle_filter.h +++ b/tracking/include/pcl/tracking/particle_filter.h @@ -293,7 +293,14 @@ class ParticleFilterTracker : public Tracker { inline void setUseNormal(bool use_normal) { - use_normal_ = use_normal; + if (traits::has_normal_v || !use_normal) { + use_normal_ = use_normal; + return; + } + PCL_WARN("[pcl::%s::setUseNormal] " + "use_normal_ == true is not supported in this Point Type.\n", + getClassName().c_str()); + use_normal_ = false; } /** \brief Get the value of use_normal_. */ @@ -461,7 +468,7 @@ class ParticleFilterTracker : public Tracker { void computeTransformedPointCloudWithNormal(const StateT&, pcl::Indices&, PointCloudIn&) { - PCL_WARN("[pcl::%s::computeTransformedPointCloudWithoutNormal] " + PCL_WARN("[pcl::%s::computeTransformedPointCloudWithNormal] " "use_normal_ == true is not supported in this Point Type.\n", getClassName().c_str()); } From 792f3e5e14928f2f5e10acbdaaaffa0ef5d19136 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Mon, 5 Apr 2021 22:06:24 +0200 Subject: [PATCH 083/431] [GPU] MSVC / CUDA fix (#4675) * Fix MSVC 16.9 change --- gpu/octree/src/utils/morton.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gpu/octree/src/utils/morton.hpp b/gpu/octree/src/utils/morton.hpp index de08c47808e..943e3deb105 100644 --- a/gpu/octree/src/utils/morton.hpp +++ b/gpu/octree/src/utils/morton.hpp @@ -122,10 +122,12 @@ namespace pcl } __device__ __host__ __forceinline__ Morton::code_t operator()(const float3& p) const - { - const int cellx = min((int)std::floor(depth_mult * min(1.f, max(0.f, (p.x - minp_.x)/dims_.x))), depth_mult - 1); - const int celly = min((int)std::floor(depth_mult * min(1.f, max(0.f, (p.y - minp_.y)/dims_.y))), depth_mult - 1); - const int cellz = min((int)std::floor(depth_mult * min(1.f, max(0.f, (p.z - minp_.z)/dims_.z))), depth_mult - 1); + { + //Using floorf due to changes to MSVC 16.9. See details here: https://devtalk.blender.org/t/cuda-compile-error-windows-10/17886/4 + //floorf is without std:: see why here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700 + const int cellx = min((int)floorf(depth_mult * min(1.f, max(0.f, (p.x - minp_.x)/dims_.x))), depth_mult - 1); + const int celly = min((int)floorf(depth_mult * min(1.f, max(0.f, (p.y - minp_.y)/dims_.y))), depth_mult - 1); + const int cellz = min((int)floorf(depth_mult * min(1.f, max(0.f, (p.z - minp_.z)/dims_.z))), depth_mult - 1); return Morton::createCode(cellx, celly, cellz); } @@ -151,4 +153,4 @@ namespace pcl } } -#endif /* PCL_GPU_OCTREE_MORTON_HPP */ \ No newline at end of file +#endif /* PCL_GPU_OCTREE_MORTON_HPP */ From 0df79823d8abcfc76552ff14455cf274a835bff9 Mon Sep 17 00:00:00 2001 From: ueqri Date: Wed, 7 Apr 2021 01:10:12 +0800 Subject: [PATCH 084/431] separated documentation & tutorials into a new pipeline --- .ci/azure-pipelines/azure-pipelines.yaml | 15 --------- .ci/azure-pipelines/docs-pipeline.yaml | 41 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 .ci/azure-pipelines/docs-pipeline.yaml diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml index 53c61eec242..69881c08317 100644 --- a/.ci/azure-pipelines/azure-pipelines.yaml +++ b/.ci/azure-pipelines/azure-pipelines.yaml @@ -24,8 +24,6 @@ resources: image: pointcloudlibrary/env:20.04 - container: env2010 image: pointcloudlibrary/env:20.10 - - container: doc - image: pointcloudlibrary/doc stages: - stage: formatting @@ -163,16 +161,3 @@ stages: VCPKG_ROOT: 'C:\vcpkg' steps: - template: build/windows.yaml - - - stage: documentation - displayName: Documentation - dependsOn: [] - jobs: - - template: documentation.yaml - - - stage: tutorials - displayName: Tutorials - dependsOn: build_gcc - jobs: - - template: tutorials.yaml - diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml new file mode 100644 index 00000000000..696bf537a5a --- /dev/null +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -0,0 +1,41 @@ +trigger: + paths: + include: + - doc + - README.md + - CHANGES.md + - CONTRIBUTING.md + +pr: + paths: + include: + - doc + - README.md + - CHANGES.md + - CONTRIBUTING.md + +resources: + pipelines: + - pipeline: Build + source: Build-CI + trigger: + stages: + - build_gcc + containers: + - container: doc # for documentation.yaml + image: pointcloudlibrary/doc + - container: env1804 # for tutorials.yaml + image: pointcloudlibrary/env:18.04 + +stages: + - stage: documentation + displayName: Documentation + jobs: + - template: documentation.yaml + + - stage: tutorials + displayName: Tutorials + # triggered only by build_gcc stage + condition: eq(variables['Build.Reason'], 'ResourceTrigger') + jobs: + - template: tutorials.yaml From 779fe025e4ce59a3d7bfeeb488a4de5dc7676651 Mon Sep 17 00:00:00 2001 From: Yan Hang Date: Wed, 7 Apr 2021 01:16:54 +0800 Subject: [PATCH 085/431] fixed a typo in docs-pipeline.yaml fixed the name of the main build pipeline. --- .ci/azure-pipelines/docs-pipeline.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml index 696bf537a5a..26cbc717838 100644 --- a/.ci/azure-pipelines/docs-pipeline.yaml +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -16,8 +16,8 @@ pr: resources: pipelines: - - pipeline: Build - source: Build-CI + - pipeline: Build-CI + source: Build trigger: stages: - build_gcc From f1b0d1a962d7fcec0dd100a0ea7960f0ba58c2f0 Mon Sep 17 00:00:00 2001 From: Guilhem Villemin Date: Tue, 6 Apr 2021 20:59:26 +0200 Subject: [PATCH 086/431] Add access to boxSearch (#4282) * Add access to boxSearch * Update octree.h * change boxSearch signature * fix indentation, use uindex_t as return type --- search/include/pcl/search/octree.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/search/include/pcl/search/octree.h b/search/include/pcl/search/octree.h index 0df81f3d311..d98e605e715 100644 --- a/search/include/pcl/search/octree.h +++ b/search/include/pcl/search/octree.h @@ -275,7 +275,17 @@ namespace pcl { return (tree_->approxNearestSearch (query_index, result_index, sqr_distance)); } - + /** \brief Search for points within rectangular search area + * \param[in] min_pt lower corner of search area + * \param[in] max_pt upper corner of search area + * \param[out] k_indices the resultant point indices + * \return number of points found within search area + */ + inline uindex_t + boxSearch(const Eigen::Vector3f &min_pt, const Eigen::Vector3f &max_pt, Indices &k_indices) const + { + return (tree_->boxSearch(min_pt, max_pt, k_indices)); + } }; } } From e9e3c022816d52b259d1e4cc5d631e9dc91035d3 Mon Sep 17 00:00:00 2001 From: ueqri Date: Wed, 7 Apr 2021 16:59:41 +0800 Subject: [PATCH 087/431] added formatting to docs pipeline & fixed tutorials stage --- .ci/azure-pipelines/docs-pipeline.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml index 26cbc717838..c31ed8f26e8 100644 --- a/.ci/azure-pipelines/docs-pipeline.yaml +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -22,12 +22,23 @@ resources: stages: - build_gcc containers: + - container: fmt # for formatting.yaml + image: pointcloudlibrary/fmt - container: doc # for documentation.yaml image: pointcloudlibrary/doc - container: env1804 # for tutorials.yaml image: pointcloudlibrary/env:18.04 stages: + - stage: formatting + displayName: Formatting + # if docs pipeline triggered by build_gcc stage, + # the formatting stage has already run, thus it + # won't run for a second time here. + condition: not(eq(variables['Build.Reason'], 'ResourceTrigger')) + jobs: + - template: formatting.yaml + - stage: documentation displayName: Documentation jobs: @@ -35,7 +46,5 @@ stages: - stage: tutorials displayName: Tutorials - # triggered only by build_gcc stage - condition: eq(variables['Build.Reason'], 'ResourceTrigger') jobs: - template: tutorials.yaml From d56cc62e7624dd701fe58a427490afad8f4d3eaa Mon Sep 17 00:00:00 2001 From: jmaiolini <45634864+jmaiolini@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:56:12 +0200 Subject: [PATCH 088/431] [geometry] Update mesh_indices.h to not need a generator file (#4648) --- geometry/include/pcl/geometry/mesh_indices.h | 451 ++---------------- geometry/include/pcl/geometry/mesh_indices.py | 266 ----------- 2 files changed, 42 insertions(+), 675 deletions(-) delete mode 100644 geometry/include/pcl/geometry/mesh_indices.py diff --git a/geometry/include/pcl/geometry/mesh_indices.h b/geometry/include/pcl/geometry/mesh_indices.h index 115e2228c23..79cbddc8c9d 100644 --- a/geometry/include/pcl/geometry/mesh_indices.h +++ b/geometry/include/pcl/geometry/mesh_indices.h @@ -38,9 +38,6 @@ * */ -// NOTE: This file has been created with -// 'pcl_src/geometry/include/pcl/geometry/mesh_indices.py' - #pragma once #include @@ -48,38 +45,42 @@ #include //////////////////////////////////////////////////////////////////////////////// -// VertexIndex +// MeshIndex //////////////////////////////////////////////////////////////////////////////// namespace pcl { -namespace geometry { -/** \brief Index used to access elements in the half-edge mesh. It is basically just a - * wrapper around an integer with a few added methods. - * \author Martin Saelzle - * \ingroup geometry - */ -class VertexIndex +namespace detail { + +template +class MeshIndex; + +template +std::istream& +operator>>(std::istream& is, MeshIndex&); + +template +class MeshIndex : boost::totally_ordered< - pcl::geometry::VertexIndex // < > <= >= == != - , - boost::unit_steppable, // < > <= >= == != + boost::unit_steppable, // ++ -- (pre and post) + boost::additive // += + + // -= - >>> { + public: using Base = boost::totally_ordered< - pcl::geometry::VertexIndex, - boost::unit_steppable>>; - using Self = pcl::geometry::VertexIndex; + MeshIndex, + boost::unit_steppable, + boost::additive>>>; + using Self = MeshIndex; /** \brief Constructor. Initializes with an invalid index. */ - VertexIndex() : index_(-1) {} + MeshIndex() : index_(-1) {} /** \brief Constructor. * \param[in] index The integer index. */ - explicit VertexIndex(const int index) : index_(index) {} + explicit MeshIndex(const int index) : index_(index) {} /** \brief Returns true if the index is valid. */ inline bool @@ -159,31 +160,28 @@ class VertexIndex /** \brief Stored index. */ int index_; - friend std::istream& - operator>>(std::istream& is, pcl::geometry::VertexIndex& index); + friend std::istream& operator>><>(std::istream& is, MeshIndex& index); }; /** \brief ostream operator. */ +template inline std::ostream& -operator<<(std::ostream& os, const pcl::geometry::VertexIndex& index) +operator<<(std::ostream& os, const MeshIndex& index) { return (os << index.get()); } /** \brief istream operator. */ +template inline std::istream& -operator>>(std::istream& is, pcl::geometry::VertexIndex& index) +operator>>(std::istream& is, MeshIndex& index) { return (is >> index.index_); } -} // End namespace geometry +} // End namespace detail } // End namespace pcl -//////////////////////////////////////////////////////////////////////////////// -// HalfEdgeIndex -//////////////////////////////////////////////////////////////////////////////// - namespace pcl { namespace geometry { /** \brief Index used to access elements in the half-edge mesh. It is basically just a @@ -191,390 +189,25 @@ namespace geometry { * \author Martin Saelzle * \ingroup geometry */ -class HalfEdgeIndex -: boost::totally_ordered< - pcl::geometry::HalfEdgeIndex // < > <= >= == != - , - boost::unit_steppable>> { -public: - using Base = boost::totally_ordered< - pcl::geometry::HalfEdgeIndex, - boost::unit_steppable>>; - using Self = pcl::geometry::HalfEdgeIndex; - - /** \brief Constructor. Initializes with an invalid index. */ - HalfEdgeIndex() : index_(-1) {} - - /** \brief Constructor. - * \param[in] index The integer index. - */ - explicit HalfEdgeIndex(const int index) : index_(index) {} - - /** \brief Returns true if the index is valid. */ - inline bool - isValid() const - { - return (index_ >= 0); - } - - /** \brief Invalidate the index. */ - inline void - invalidate() - { - index_ = -1; - } - - /** \brief Get the index. */ - inline int - get() const - { - return (index_); - } - - /** \brief Set the index. */ - inline void - set(const int index) - { - index_ = index; - } - - /** \brief Comparison operators (with boost::operators): < > <= >= */ - inline bool - operator<(const Self& other) const - { - return (this->get() < other.get()); - } - - /** \brief Comparison operators (with boost::operators): == != */ - inline bool - operator==(const Self& other) const - { - return (this->get() == other.get()); - } - - /** \brief Increment operators (with boost::operators): ++ (pre and post) */ - inline Self& - operator++() - { - ++index_; - return (*this); - } - - /** \brief Decrement operators (with boost::operators): \-\- (pre and post) */ - inline Self& - operator--() - { - --index_; - return (*this); - } - - /** \brief Addition operators (with boost::operators): + += */ - inline Self& - operator+=(const Self& other) - { - index_ += other.get(); - return (*this); - } - - /** \brief Subtraction operators (with boost::operators): - -= */ - inline Self& - operator-=(const Self& other) - { - index_ -= other.get(); - return (*this); - } - -private: - /** \brief Stored index. */ - int index_; - - friend std::istream& - operator>>(std::istream& is, pcl::geometry::HalfEdgeIndex& index); -}; - -/** \brief ostream operator. */ -inline std::ostream& -operator<<(std::ostream& os, const pcl::geometry::HalfEdgeIndex& index) -{ - return (os << index.get()); -} - -/** \brief istream operator. */ -inline std::istream& -operator>>(std::istream& is, pcl::geometry::HalfEdgeIndex& index) -{ - return (is >> index.index_); -} - -} // End namespace geometry -} // End namespace pcl - -//////////////////////////////////////////////////////////////////////////////// -// EdgeIndex -//////////////////////////////////////////////////////////////////////////////// - -namespace pcl { -namespace geometry { +using VertexIndex = pcl::detail::MeshIndex; /** \brief Index used to access elements in the half-edge mesh. It is basically just a * wrapper around an integer with a few added methods. * \author Martin Saelzle * \ingroup geometry */ -class EdgeIndex -: boost::totally_ordered< - pcl::geometry::EdgeIndex // < > <= >= == != - , - boost::unit_steppable>> { -public: - using Base = boost::totally_ordered< - pcl::geometry::EdgeIndex, - boost::unit_steppable>>; - using Self = pcl::geometry::EdgeIndex; - - /** \brief Constructor. Initializes with an invalid index. */ - EdgeIndex() : index_(-1) {} - - /** \brief Constructor. - * \param[in] index The integer index. - */ - explicit EdgeIndex(const int index) : index_(index) {} - - /** \brief Returns true if the index is valid. */ - inline bool - isValid() const - { - return (index_ >= 0); - } - - /** \brief Invalidate the index. */ - inline void - invalidate() - { - index_ = -1; - } - - /** \brief Get the index. */ - inline int - get() const - { - return (index_); - } - - /** \brief Set the index. */ - inline void - set(const int index) - { - index_ = index; - } - - /** \brief Comparison operators (with boost::operators): < > <= >= */ - inline bool - operator<(const Self& other) const - { - return (this->get() < other.get()); - } - - /** \brief Comparison operators (with boost::operators): == != */ - inline bool - operator==(const Self& other) const - { - return (this->get() == other.get()); - } - - /** \brief Increment operators (with boost::operators): ++ (pre and post) */ - inline Self& - operator++() - { - ++index_; - return (*this); - } - - /** \brief Decrement operators (with boost::operators): \-\- (pre and post) */ - inline Self& - operator--() - { - --index_; - return (*this); - } - - /** \brief Addition operators (with boost::operators): + += */ - inline Self& - operator+=(const Self& other) - { - index_ += other.get(); - return (*this); - } - - /** \brief Subtraction operators (with boost::operators): - -= */ - inline Self& - operator-=(const Self& other) - { - index_ -= other.get(); - return (*this); - } - -private: - /** \brief Stored index. */ - int index_; - - friend std::istream& - operator>>(std::istream& is, pcl::geometry::EdgeIndex& index); -}; - -/** \brief ostream operator. */ -inline std::ostream& -operator<<(std::ostream& os, const pcl::geometry::EdgeIndex& index) -{ - return (os << index.get()); -} - -/** \brief istream operator. */ -inline std::istream& -operator>>(std::istream& is, pcl::geometry::EdgeIndex& index) -{ - return (is >> index.index_); -} - -} // End namespace geometry -} // End namespace pcl - -//////////////////////////////////////////////////////////////////////////////// -// FaceIndex -//////////////////////////////////////////////////////////////////////////////// - -namespace pcl { -namespace geometry { +using HalfEdgeIndex = pcl::detail::MeshIndex; /** \brief Index used to access elements in the half-edge mesh. It is basically just a * wrapper around an integer with a few added methods. * \author Martin Saelzle * \ingroup geometry */ -class FaceIndex -: boost::totally_ordered< - pcl::geometry::FaceIndex // < > <= >= == != - , - boost::unit_steppable>> { -public: - using Base = boost::totally_ordered< - pcl::geometry::FaceIndex, - boost::unit_steppable>>; - using Self = pcl::geometry::FaceIndex; - - /** \brief Constructor. Initializes with an invalid index. */ - FaceIndex() : index_(-1) {} - - /** \brief Constructor. - * \param[in] index The integer index. - */ - explicit FaceIndex(const int index) : index_(index) {} - - /** \brief Returns true if the index is valid. */ - inline bool - isValid() const - { - return (index_ >= 0); - } - - /** \brief Invalidate the index. */ - inline void - invalidate() - { - index_ = -1; - } - - /** \brief Get the index. */ - inline int - get() const - { - return (index_); - } - - /** \brief Set the index. */ - inline void - set(const int index) - { - index_ = index; - } - - /** \brief Comparison operators (with boost::operators): < > <= >= */ - inline bool - operator<(const Self& other) const - { - return (this->get() < other.get()); - } - - /** \brief Comparison operators (with boost::operators): == != */ - inline bool - operator==(const Self& other) const - { - return (this->get() == other.get()); - } - - /** \brief Increment operators (with boost::operators): ++ (pre and post) */ - inline Self& - operator++() - { - ++index_; - return (*this); - } - - /** \brief Decrement operators (with boost::operators): \-\- (pre and post) */ - inline Self& - operator--() - { - --index_; - return (*this); - } - - /** \brief Addition operators (with boost::operators): + += */ - inline Self& - operator+=(const Self& other) - { - index_ += other.get(); - return (*this); - } - - /** \brief Subtraction operators (with boost::operators): - -= */ - inline Self& - operator-=(const Self& other) - { - index_ -= other.get(); - return (*this); - } - -private: - /** \brief Stored index. */ - int index_; - - friend std::istream& - operator>>(std::istream& is, pcl::geometry::FaceIndex& index); -}; - -/** \brief ostream operator. */ -inline std::ostream& -operator<<(std::ostream& os, const pcl::geometry::FaceIndex& index) -{ - return (os << index.get()); -} - -/** \brief istream operator. */ -inline std::istream& -operator>>(std::istream& is, pcl::geometry::FaceIndex& index) -{ - return (is >> index.index_); -} +using EdgeIndex = pcl::detail::MeshIndex; +/** \brief Index used to access elements in the half-edge mesh. It is basically just a + * wrapper around an integer with a few added methods. + * \author Martin Saelzle + * \ingroup geometry + */ +using FaceIndex = pcl::detail::MeshIndex; } // End namespace geometry } // End namespace pcl @@ -586,7 +219,7 @@ operator>>(std::istream& is, pcl::geometry::FaceIndex& index) namespace pcl { namespace geometry { /** \brief Convert the given half-edge index to an edge index. */ -inline pcl::geometry::EdgeIndex +inline EdgeIndex toEdgeIndex(const HalfEdgeIndex& index) { return (index.isValid() ? EdgeIndex(index.get() / 2) : EdgeIndex()); @@ -594,10 +227,10 @@ toEdgeIndex(const HalfEdgeIndex& index) /** \brief Convert the given edge index to a half-edge index. * \param index - * \param[in] get_first The first half-edge of the edge is returned if this variable is - * true; elsewise the second. + * \param[in] get_first The first half-edge of the edge is returned if this + * variable is true; elsewise the second. */ -inline pcl::geometry::HalfEdgeIndex +inline HalfEdgeIndex toHalfEdgeIndex(const EdgeIndex& index, const bool get_first = true) { return (index.isValid() diff --git a/geometry/include/pcl/geometry/mesh_indices.py b/geometry/include/pcl/geometry/mesh_indices.py deleted file mode 100644 index 9bd0f53f3fc..00000000000 --- a/geometry/include/pcl/geometry/mesh_indices.py +++ /dev/null @@ -1,266 +0,0 @@ -## -# Software License Agreement (BSD License) -# -# Point Cloud Library (PCL) - www.pointclouds.org -# Copyright (c) 2009-2012, Willow Garage, Inc. -# Copyright (c) 2012-, Open Perception, Inc. -# -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# # Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# # Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# # Neither the name of the copyright holder(s) nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -import os - -filename = os.path.join (os.path.dirname (__file__), 'mesh_indices.h') -class_names = ['VertexIndex', 'HalfEdgeIndex', 'EdgeIndex', 'FaceIndex'] - -################################################################################ - -f = open (filename, 'w') - -f.write ('/*\n') -f.write (' * Software License Agreement (BSD License)\n') -f.write (' *\n') -f.write (' * Point Cloud Library (PCL) - www.pointclouds.org\n') -f.write (' * Copyright (c) 2009-2012, Willow Garage, Inc.\n') -f.write (' * Copyright (c) 2012-, Open Perception, Inc.\n') -f.write (' *\n') -f.write (' * All rights reserved.\n') -f.write (' *\n') -f.write (' * Redistribution and use in source and binary forms, with or without\n') -f.write (' * modification, are permitted provided that the following conditions\n') -f.write (' * are met:\n') -f.write (' *\n') -f.write (' * * Redistributions of source code must retain the above copyright\n') -f.write (' * notice, this list of conditions and the following disclaimer.\n') -f.write (' * * Redistributions in binary form must reproduce the above\n') -f.write (' * copyright notice, this list of conditions and the following\n') -f.write (' * disclaimer in the documentation and/or other materials provided\n') -f.write (' * with the distribution.\n') -f.write (' * * Neither the name of the copyright holder(s) nor the names of its\n') -f.write (' * contributors may be used to endorse or promote products derived\n') -f.write (' * from this software without specific prior written permission.\n') -f.write (' *\n') -f.write (' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n') -f.write (' * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n') -f.write (' * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n') -f.write (' * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n') -f.write (' * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n') -f.write (' * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n') -f.write (' * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n') -f.write (' * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n') -f.write (' * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n') -f.write (' * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\n') -f.write (' * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n') -f.write (' * POSSIBILITY OF SUCH DAMAGE.\n') -f.write (' *\n') -f.write (' * $Id$\n') -f.write (' *\n') -f.write (' */\n\n') - -f.write ("// NOTE: This file has been created with 'pcl_src/geometry/include/pcl/geometry/mesh_indices.py'\n\n") - -f.write ('#ifndef PCL_GEOMETRY_MESH_INDICES_H\n') -f.write ('#define PCL_GEOMETRY_MESH_INDICES_H\n\n') - -f.write ('#include \n\n') - -f.write ('#include \n\n') - -for cn in class_names: - - f.write ('////////////////////////////////////////////////////////////////////////////////\n') - f.write ('// ' + cn + '\n') - f.write ('////////////////////////////////////////////////////////////////////////////////\n\n') - - f.write ('namespace pcl\n') - f.write ('{\n') - f.write (' namespace geometry\n') - f.write (' {\n') - f.write (' /** \\brief Index used to access elements in the half-edge mesh. It is basically just a\n') - f.write (' * wrapper around an integer with a few added methods.\n') - f.write (' * \\author Martin Saelzle\n') - f.write (' * \ingroup geometry\n') - f.write (' */\n') - f.write (' class ' + cn + '\n') - f.write (' : boost::totally_ordered <= >= == !=\n') - f.write (' , boost::unit_steppable > >\n') - f.write (' {\n') - f.write (' public:\n\n') - - f.write (' typedef boost::totally_ordered > > Base;\n') - f.write (' typedef pcl::geometry::' + cn + ' Self;\n\n') - - f.write (' /** \\brief Constructor. Initializes with an invalid index. */\n') - f.write (' ' + cn + ' ()\n') - f.write (' : index_ (-1)\n') - f.write (' {\n') - f.write (' }\n\n') - - f.write (' /** \\brief Constructor.\n') - f.write (' * \param[in] index The integer index.\n') - f.write (' */\n') - f.write (' explicit ' + cn + ' (const int index)\n') - f.write (' : index_ (index)\n') - f.write (' {\n') - f.write (' }\n\n') - - f.write (' /** \\brief Returns true if the index is valid. */\n') - f.write (' inline bool\n') - f.write (' isValid () const\n') - f.write (' {\n') - f.write (' return (index_ >= 0);\n') - f.write (' }\n\n') - - f.write (' /** \\brief Invalidate the index. */\n') - f.write (' inline void\n') - f.write (' invalidate ()\n') - f.write (' {\n') - f.write (' index_ = -1;\n') - f.write (' }\n\n') - - f.write (' /** \\brief Get the index. */\n') - f.write (' inline int\n') - f.write (' get () const\n') - f.write (' {\n') - f.write (' return (index_);\n') - f.write (' }\n\n') - - f.write (' /** \\brief Set the index. */\n') - f.write (' inline void\n') - f.write (' set (const int index)\n') - f.write (' {\n') - f.write (' index_ = index;\n') - f.write (' }\n\n') - - f.write (' /** \\brief Comparison operators (with boost::operators): < > <= >= */\n') - f.write (' inline bool\n') - f.write (' operator < (const Self& other) const\n') - f.write (' {\n') - f.write (' return (this->get () < other.get ());\n') - f.write (' }\n\n') - - f.write (' /** \\brief Comparison operators (with boost::operators): == != */\n') - f.write (' inline bool\n') - f.write (' operator == (const Self& other) const\n') - f.write (' {\n') - f.write (' return (this->get () == other.get ());\n') - f.write (' }\n\n') - - f.write (' /** \\brief Increment operators (with boost::operators): ++ (pre and post) */\n') - f.write (' inline Self&\n') - f.write (' operator ++ ()\n') - f.write (' {\n') - f.write (' ++index_;\n') - f.write (' return (*this);\n') - f.write (' }\n\n') - - f.write (' /** \\brief Decrement operators (with boost::operators): \-\- (pre and post) */\n') - f.write (' inline Self&\n') - f.write (' operator -- ()\n') - f.write (' {\n') - f.write (' --index_;\n') - f.write (' return (*this);\n') - f.write (' }\n\n') - - f.write (' /** \\brief Addition operators (with boost::operators): + += */\n') - f.write (' inline Self&\n') - f.write (' operator += (const Self& other)\n') - f.write (' {\n') - f.write (' index_ += other.get ();\n') - f.write (' return (*this);\n') - f.write (' }\n\n') - - f.write (' /** \\brief Subtraction operators (with boost::operators): - -= */\n') - f.write (' inline Self&\n') - f.write (' operator -= (const Self& other)\n') - f.write (' {\n') - f.write (' index_ -= other.get ();\n') - f.write (' return (*this);\n') - f.write (' }\n\n') - - f.write (' private:\n\n') - - f.write (' /** \\brief Stored index. */\n') - f.write (' int index_;\n\n') - - f.write (' friend std::istream&\n') - f.write (' operator >> (std::istream& is, pcl::geometry::' + cn + '& index);\n') - f.write (' };\n\n') - - f.write (' /** \\brief ostream operator. */\n') - f.write (' inline std::ostream&\n') - f.write (' operator << (std::ostream& os, const pcl::geometry::' + cn + '& index)\n') - f.write (' {\n') - f.write (' return (os << index.get ());\n') - f.write (' }\n\n') - - f.write (' /** \\brief istream operator. */\n') - f.write (' inline std::istream&\n') - f.write (' operator >> (std::istream& is, pcl::geometry::' + cn + '& index)\n') - f.write (' {\n') - f.write (' return (is >> index.index_);\n') - f.write (' }\n\n') - - f.write (' } // End namespace geometry\n') - f.write ('} // End namespace pcl\n\n') - -f.write ('////////////////////////////////////////////////////////////////////////////////\n') -f.write ('// Conversions\n') -f.write ('////////////////////////////////////////////////////////////////////////////////\n\n') - -f.write ('namespace pcl\n') -f.write ('{\n') -f.write (' namespace geometry\n') -f.write (' {\n') -f.write (' /** \\brief Convert the given half-edge index to an edge index. */\n') -f.write (' inline pcl::geometry::EdgeIndex\n') -f.write (' toEdgeIndex (const HalfEdgeIndex& index)\n') -f.write (' {\n') -f.write (' return (index.isValid () ? EdgeIndex (index.get () / 2) : EdgeIndex ());\n') -f.write (' }\n\n') - -f.write (' /** \\brief Convert the given edge index to a half-edge index.\n') -f.write (' * \\param[in] get_first The first half-edge of the edge is returned if this variable is true; elsewise the second.\n') -f.write (' */\n') -f.write (' inline pcl::geometry::HalfEdgeIndex\n') -f.write (' toHalfEdgeIndex (const EdgeIndex& index, const bool get_first=true)\n') -f.write (' {\n') -f.write (' return (index.isValid () ? HalfEdgeIndex (index.get () * 2 + static_cast (!get_first)) : HalfEdgeIndex ());\n') -f.write (' }\n') -f.write (' } // End namespace geometry\n') -f.write ('} // End namespace pcl\n\n') - -f.write ('#endif // PCL_GEOMETRY_MESH_INDICES_H\n') - -f.close() From e1664a4ba63107b2c5ca10bc4137c5a8f73ae0b5 Mon Sep 17 00:00:00 2001 From: Yosshi999 Date: Thu, 8 Apr 2021 22:42:08 +0900 Subject: [PATCH 089/431] add ellipsoid shape to pcl_visualizer (#4531) * add ellipsoid shape to pcl_visualizer * more accurate description * addEllipsoid with Isometry3f * use const * support only Isometry3d argument * add a component for ellipsoid * add a link library for ellipsoid --- cmake/pcl_find_vtk.cmake | 1 + visualization/CMakeLists.txt | 1 + .../include/pcl/visualization/common/shapes.h | 12 ++++++++ .../pcl/visualization/pcl_visualizer.h | 14 ++++++++++ visualization/src/common/shapes.cpp | 27 ++++++++++++++++++ visualization/src/pcl_visualizer.cpp | 28 +++++++++++++++++++ 6 files changed, 83 insertions(+) diff --git a/cmake/pcl_find_vtk.cmake b/cmake/pcl_find_vtk.cmake index 99f8d558606..300e27ff80b 100644 --- a/cmake/pcl_find_vtk.cmake +++ b/cmake/pcl_find_vtk.cmake @@ -37,6 +37,7 @@ endif() set(NON_PREFIX_PCL_VTK_COMPONENTS ChartsCore CommonColor + CommonComputationalGeometry CommonCore CommonDataModel CommonExecutionModel diff --git a/visualization/CMakeLists.txt b/visualization/CMakeLists.txt index e9ead2ac0e7..ed2c4ca1b99 100644 --- a/visualization/CMakeLists.txt +++ b/visualization/CMakeLists.txt @@ -168,6 +168,7 @@ else() target_link_libraries("${LIB_NAME}" VTK::ChartsCore VTK::CommonColor + VTK::CommonComputationalGeometry VTK::CommonDataModel VTK::FiltersExtraction VTK::FiltersGeometry diff --git a/visualization/include/pcl/visualization/common/shapes.h b/visualization/include/pcl/visualization/common/shapes.h index 3396753b6b8..d74389ddde7 100644 --- a/visualization/include/pcl/visualization/common/shapes.h +++ b/visualization/include/pcl/visualization/common/shapes.h @@ -280,6 +280,18 @@ namespace pcl createCube (double x_min, double x_max, double y_min, double y_max, double z_min, double z_max); + + /** \brief Create an ellipsoid shape from the given parameters. + * + * \param[in] transform a transformation to apply to the ellipsoid from 0,0,0 + * \param[in] radius_x the ellipsoid's radius along its local x-axis + * \param[in] radius_y the ellipsoid's radius along its local y-axis + * \param[in] radius_z the ellipsoid's radius along its local z-axis + * \ingroup visualization + */ + PCL_EXPORTS vtkSmartPointer + createEllipsoid (const Eigen::Isometry3d &transform, + double radius_x, double radius_y, double radius_z); /** \brief Allocate a new unstructured grid smartpointer. For internal use only. * \param[out] polydata the resultant unstructured grid. diff --git a/visualization/include/pcl/visualization/pcl_visualizer.h b/visualization/include/pcl/visualization/pcl_visualizer.h index 64e14ebf8ac..1c0c0154d88 100644 --- a/visualization/include/pcl/visualization/pcl_visualizer.h +++ b/visualization/include/pcl/visualization/pcl_visualizer.h @@ -1694,6 +1694,20 @@ namespace pcl addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max, double r = 1.0, double g = 1.0, double b = 1.0, const std::string &id = "cube", int viewport = 0); + /** \brief Add an ellipsoid from the given parameters + * \param[in] transform a transformation to apply to the ellipsoid from 0,0,0 + * \param[in] radius_x the ellipsoid's radius along its local x-axis + * \param[in] radius_y the ellipsoid's radius along its local y-axis + * \param[in] radius_z the ellipsoid's radius along its local z-axis + * \param[in] id the ellipsoid id/name (default: "ellipsoid") + * \param[in] viewport (optional) the id of the new viewport (default: 0) + */ + bool + addEllipsoid (const Eigen::Isometry3d &transform, + double radius_x, double radius_y, double radius_z, + const std::string &id = "ellipsoid", + int viewport = 0); + /** \brief Changes the visual representation for all actors to surface representation. */ void setRepresentationToSurfaceForAllActors (); diff --git a/visualization/src/common/shapes.cpp b/visualization/src/common/shapes.cpp index 445db9f555a..8893ea96d4e 100644 --- a/visualization/src/common/shapes.cpp +++ b/visualization/src/common/shapes.cpp @@ -47,6 +47,8 @@ #include #include #include +#include +#include //////////////////////////////////////////////////////////////////////////////////////////// vtkSmartPointer @@ -304,6 +306,31 @@ pcl::visualization::createLine (const Eigen::Vector4f &pt1, const Eigen::Vector4 return (line->GetOutput ()); } +////////////////////////////////////////////////////////////////////////////////////////////// +vtkSmartPointer +pcl::visualization::createEllipsoid (const Eigen::Isometry3d &transform, + double radius_x, double radius_y, double radius_z) +{ + const vtkSmartPointer t = vtkSmartPointer::New (); + const Eigen::Matrix4d trMatrix = transform.matrix ().transpose (); // Eigen is col-major while vtk is row-major, so transpose it. + t->SetMatrix (trMatrix.data ()); + + vtkSmartPointer ellipsoid = vtkSmartPointer::New (); + ellipsoid->SetXRadius (radius_x); + ellipsoid->SetYRadius (radius_y); + ellipsoid->SetZRadius (radius_z); + + vtkSmartPointer s_ellipsoid = vtkSmartPointer::New (); + s_ellipsoid->SetParametricFunction (ellipsoid); + + vtkSmartPointer tf = vtkSmartPointer::New (); + tf->SetTransform (t); + tf->SetInputConnection (s_ellipsoid->GetOutputPort ()); + tf->Update (); + + return (tf->GetOutput ()); +} + ////////////////////////////////////////////////////////////////////////////////////////////// void pcl::visualization::allocVtkUnstructuredGrid (vtkSmartPointer &polydata) diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visualizer.cpp index 79b3d12263a..0a110ee5763 100644 --- a/visualization/src/pcl_visualizer.cpp +++ b/visualization/src/pcl_visualizer.cpp @@ -2435,6 +2435,34 @@ pcl::visualization::PCLVisualizer::addCube (float x_min, float x_max, return (true); } +//////////////////////////////////////////////////////////////////////////////////////////// +bool +pcl::visualization::PCLVisualizer::addEllipsoid ( + const Eigen::Isometry3d &transform, + double radius_x, double radius_y, double radius_z, + const std::string &id, int viewport) +{ + // Check to see if this ID entry already exists (has it been already added to the visualizer?) + ShapeActorMap::iterator am_it = shape_actor_map_->find (id); + if (am_it != shape_actor_map_->end ()) + { + pcl::console::print_warn (stderr, "[addEllipsoid] A shape with id <%s> already exists! Please choose a different id and retry.\n", id.c_str ()); + return (false); + } + + vtkSmartPointer data = createEllipsoid (transform, radius_x, radius_y, radius_z); + + // Create an Actor + vtkSmartPointer actor; + createActorFromVTKDataSet (data, actor); + actor->GetProperty ()->SetRepresentationToSurface (); + addActorToRenderer (actor, viewport); + + // Save the pointer/ID pair to the global actor map + (*shape_actor_map_)[id] = actor; + return (true); +} + //////////////////////////////////////////////////////////////////////////////////////////// bool pcl::visualization::PCLVisualizer::addSphere (const pcl::ModelCoefficients &coefficients, From 2c8053fae97d950ff9fdec8729f1d2bb0e0dde25 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Wed, 10 Mar 2021 11:55:31 +0530 Subject: [PATCH 090/431] Move the init of static variables to library load time Added header for `array`, newly added in this PR Move the LUT for sRGB and XYZ to common, Also utilize them in gicp6d and SHOT --- common/include/pcl/common/colors.h | 86 ++++++++++++++++++++- features/include/pcl/features/impl/shot.hpp | 34 ++------ features/include/pcl/features/shot.h | 7 +- registration/src/gicp6d.cpp | 66 +++++----------- 4 files changed, 115 insertions(+), 78 deletions(-) diff --git a/common/include/pcl/common/colors.h b/common/include/pcl/common/colors.h index 5490c06bb52..34fb86d8170 100644 --- a/common/include/pcl/common/colors.h +++ b/common/include/pcl/common/colors.h @@ -40,6 +40,8 @@ #include #include +#include // for is_floating_point + namespace pcl { @@ -83,4 +85,86 @@ namespace pcl using GlasbeyLUT = ColorLUT; using ViridisLUT = ColorLUT; -} + /** + * @brief Returns a Look-Up Table useful in converting RGB to sRGB + * @tparam T floating point type with resultant value + * @tparam bits depth of RGB + * @return 1-D LUT for converting R, G or B into Rs, Gs or Bs + * @remarks sRGB was proposed by Stokes et al. as a uniform default color + * space for the internet + * M. Stokes, M. Anderson, S. Chandrasekar, and R. Motta: A standard default colorspace for the internet - sRGB (Nov 1996) + * IEC 61966-2.1 Default RGB Colour Space - sRGB (International Electrotechnical Commission, Geneva, Switzerland, 1999) + * www.srgb.com, www.color.org/srgb.html + */ + template + inline std::array + RGB2sRGB_LUT() noexcept + { + static_assert(std::is_floating_point::value, "LUT value must be a floating point"); + + constexpr std::size_t size = 1 << bits; + + static const std::array sRGB_LUT = [&]() { + std::array LUT; + for (std::size_t i = 0; i < size; ++i) { + T f = static_cast(i) / static_cast(size - 1); + if (f > 0.04045) { + // ((f + 0.055)/1.055)^2.4 + LUT[i] = static_cast( + std::pow((f + static_cast(0.055)) / static_cast(1.055), + static_cast(2.4))); + } + else { + // f / 12.92 + LUT[i] = f / static_cast(12.92); + } + } + return LUT; + }(); + return sRGB_LUT; + } + + /** + * @brief Returns a Look-Up Table useful in converting scaled CIE XYZ into CIE L*a*b* + * @details The function assumes that the XYZ values are + * * not normalized using reference illuminant + * * scaled such that reference illuminant has Xn = Yn = Zn = discretizations + * @tparam T floating point type with resultant value + * @tparam discretizations number of levels for the LUT + * @return 1-D LUT with results of f(X/Xn) + * @note This function doesn't convert from CIE XYZ to CIE L*a*b*. The actual conversion + * is as follows: + * L* = 116 * [f(Y/Yn) - 16/116] + * a* = 500 * [f(X/Xn) - f(Y/Yn)] + * b* = 200 * [f(Y/Yn) - f(Z/Zn)] + * Where, Xn, Yn and Zn are values of the reference illuminant (at prescribed angle) + * f is appropriate function such that L* = 100, a* = b* = 0 for white color + * Reference: Billmeyer and Saltzman’s Principles of Color Technology + */ + template + inline const std::array& + XYZ2LAB_LUT() noexcept + { + static_assert(std::is_floating_point::value, "LUT value must be a floating point"); + + constexpr std::size_t size = discretizations; + + static const std::array f_LUT = [&]() { + std::array LUT; + for (std::size_t i = 0; i < size; ++i) { + T f = static_cast(i) / static_cast(size); + if (f > static_cast(0.008856)) { + // f^(1/3) + LUT[i] = static_cast(std::pow(f, (static_cast(1) / static_cast(3)))); + } + else { + // 7.87 * f + 16/116 + LUT[i] = + static_cast(7.87) * f + (static_cast(16) / static_cast(116)); + } + } + return LUT; + }(); + return f_LUT; + } +} // namespace pcl diff --git a/features/include/pcl/features/impl/shot.hpp b/features/include/pcl/features/impl/shot.hpp index 297a55a40de..73a50e004cf 100644 --- a/features/include/pcl/features/impl/shot.hpp +++ b/features/include/pcl/features/impl/shot.hpp @@ -43,6 +43,8 @@ #include #include +#include // for RGB2sRGB_LUT, XYZ2LAB_LUT + // Useful constants. #define PST_PI 3.1415926535897932384626433832795 #define PST_RAD_45 0.78539816339744830961566084581988 @@ -84,12 +86,14 @@ areEquals (float val1, float val2, float zeroFloatEps = zeroFloatEps8) } ////////////////////////////////////////////////////////////////////////////////////////////// -template float -pcl::SHOTColorEstimation::sRGB_LUT[256] = {- 1}; +template +std::array + pcl::SHOTColorEstimation::sRGB_LUT = pcl::RGB2sRGB_LUT(); ////////////////////////////////////////////////////////////////////////////////////////////// -template float -pcl::SHOTColorEstimation::sXYZ_LUT[4000] = {- 1}; +template +std::array + pcl::SHOTColorEstimation::sXYZ_LUT = pcl::XYZ2LAB_LUT(); ////////////////////////////////////////////////////////////////////////////////////////////// template void @@ -97,28 +101,6 @@ pcl::SHOTColorEstimation::RGB2CIELAB (un unsigned char B, float &L, float &A, float &B2) { - // @TODO: C++17 supports constexpr lambda for compile time init - if (sRGB_LUT[0] < 0) - { - for (int i = 0; i < 256; i++) - { - float f = static_cast (i) / 255.0f; - if (f > 0.04045) - sRGB_LUT[i] = powf ((f + 0.055f) / 1.055f, 2.4f); - else - sRGB_LUT[i] = f / 12.92f; - } - - for (int i = 0; i < 4000; i++) - { - float f = static_cast (i) / 4000.0f; - if (f > 0.008856) - sXYZ_LUT[i] = static_cast (powf (f, 0.3333f)); - else - sXYZ_LUT[i] = static_cast((7.787 * f) + (16.0 / 116.0)); - } - } - float fr = sRGB_LUT[R]; float fg = sRGB_LUT[G]; float fb = sRGB_LUT[B]; diff --git a/features/include/pcl/features/shot.h b/features/include/pcl/features/shot.h index 24041664c3a..0e3581febb2 100644 --- a/features/include/pcl/features/shot.h +++ b/features/include/pcl/features/shot.h @@ -42,6 +42,8 @@ #include #include +#include // for sRGB_LUT, sXYZ_LUT + namespace pcl { /** \brief SHOTEstimation estimates the Signature of Histograms of OrienTations (SHOT) descriptor for @@ -98,7 +100,6 @@ namespace pcl { feature_name_ = "SHOTEstimation"; }; - public: @@ -400,8 +401,8 @@ namespace pcl static void RGB2CIELAB (unsigned char R, unsigned char G, unsigned char B, float &L, float &A, float &B2); - static float sRGB_LUT[256]; - static float sXYZ_LUT[4000]; + static std::array sRGB_LUT; + static std::array sXYZ_LUT; }; } diff --git a/registration/src/gicp6d.cpp b/registration/src/gicp6d.cpp index b3a4f5db033..1b5a30a0f7a 100644 --- a/registration/src/gicp6d.cpp +++ b/registration/src/gicp6d.cpp @@ -36,6 +36,7 @@ * */ +#include // for RGB2sRGB_LUT, XYZ2LAB_LUT #include #include // for pcl::make_shared @@ -47,59 +48,28 @@ RGB2Lab(const Eigen::Vector3i& colorRGB) // for sRGB -> CIEXYZ see http://www.easyrgb.com/index.php?X=MATH&H=02#text2 // for CIEXYZ -> CIELAB see http://www.easyrgb.com/index.php?X=MATH&H=07#text7 - double R, G, B, X, Y, Z; + const auto& sRGB_LUT = RGB2sRGB_LUT(); + const auto& XYZ_LUT = XYZ2LAB_LUT(); - // map sRGB values to [0, 1] - R = colorRGB[0] / 255.0; - G = colorRGB[1] / 255.0; - B = colorRGB[2] / 255.0; + const double R = sRGB_LUT[colorRGB[0]]; + const double G = sRGB_LUT[colorRGB[1]]; + const double B = sRGB_LUT[colorRGB[2]]; - // linearize sRGB values - if (R > 0.04045) - R = pow((R + 0.055) / 1.055, 2.4); - else - R /= 12.92; + // linear sRGB -> CIEXYZ, D65 illuminant, observer at 2 degrees + double X = R * 0.4124 + G * 0.3576 + B * 0.1805; + double Y = R * 0.2126 + G * 0.7152 + B * 0.0722; + double Z = R * 0.0193 + G * 0.1192 + B * 0.9505; - if (G > 0.04045) - G = pow((G + 0.055) / 1.055, 2.4); - else - G /= 12.92; - - if (B > 0.04045) - B = pow((B + 0.055) / 1.055, 2.4); - else - B /= 12.92; - - // postponed: - // R *= 100.0; - // G *= 100.0; - // B *= 100.0; - - // linear sRGB -> CIEXYZ - X = R * 0.4124 + G * 0.3576 + B * 0.1805; - Y = R * 0.2126 + G * 0.7152 + B * 0.0722; - Z = R * 0.0193 + G * 0.1192 + B * 0.9505; - - // *= 100.0 including: - X /= 0.95047; // 95.047; - // Y /= 1;//100.000; - Z /= 1.08883; // 108.883; + // normalize X, Y, Z with tristimulus values for Xn, Yn, Zn + // and scale for using the LUT with 4000 steps + X = (X / 0.95047) * 4000; + Y = (Y / 1) * 4000; + Z = (Z / 1.08883) * 4000; // CIEXYZ -> CIELAB - if (X > 0.008856) - X = pow(X, 1.0 / 3.0); - else - X = 7.787 * X + 16.0 / 116.0; - - if (Y > 0.008856) - Y = pow(Y, 1.0 / 3.0); - else - Y = 7.787 * Y + 16.0 / 116.0; - - if (Z > 0.008856) - Z = pow(Z, 1.0 / 3.0); - else - Z = 7.787 * Z + 16.0 / 116.0; + X = XYZ_LUT[static_cast(X)]; + Y = XYZ_LUT[static_cast(Y)]; + Z = XYZ_LUT[static_cast(Z)]; Eigen::Vector3f colorLab; colorLab[0] = static_cast(116.0 * Y - 16.0); From 22831c9a05ddda83cb8d18c1f7033423058b0676 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Sun, 14 Mar 2021 08:02:03 +0530 Subject: [PATCH 091/431] Here's hoping one of this makes MSVC happier --- common/include/pcl/common/colors.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/common/include/pcl/common/colors.h b/common/include/pcl/common/colors.h index 34fb86d8170..50599a7a402 100644 --- a/common/include/pcl/common/colors.h +++ b/common/include/pcl/common/colors.h @@ -97,15 +97,16 @@ namespace pcl * www.srgb.com, www.color.org/srgb.html */ template - inline std::array + PCL_EXPORTS inline std::array RGB2sRGB_LUT() noexcept { static_assert(std::is_floating_point::value, "LUT value must be a floating point"); - constexpr std::size_t size = 1 << bits; + constexpr const std::size_t size = 1 << bits; - static const std::array sRGB_LUT = [&]() { - std::array LUT; + static const auto sRGB_LUT = [&]() { + // MSVC wouldn't take `size` here instead of the expression + std::array LUT; for (std::size_t i = 0; i < size; ++i) { T f = static_cast(i) / static_cast(size - 1); if (f > 0.04045) { @@ -142,17 +143,15 @@ namespace pcl * Reference: Billmeyer and Saltzman’s Principles of Color Technology */ template - inline const std::array& + PCL_EXPORTS inline const std::array& XYZ2LAB_LUT() noexcept { static_assert(std::is_floating_point::value, "LUT value must be a floating point"); - constexpr std::size_t size = discretizations; - - static const std::array f_LUT = [&]() { - std::array LUT; - for (std::size_t i = 0; i < size; ++i) { - T f = static_cast(i) / static_cast(size); + static const auto f_LUT = [&]() { + std::array LUT; + for (std::size_t i = 0; i < discretizations; ++i) { + T f = static_cast(i) / static_cast(discretizations); if (f > static_cast(0.008856)) { // f^(1/3) LUT[i] = static_cast(std::pow(f, (static_cast(1) / static_cast(3)))); From 400a4ec6b60a8a917716a7e4ab7df55b6a987289 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 16 Mar 2021 08:13:54 +0530 Subject: [PATCH 092/431] Minor rewrite to use the new LUT for RGB Not used for XYZ due to windows getting low accuracy with LUT --- registration/src/gicp6d.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/registration/src/gicp6d.cpp b/registration/src/gicp6d.cpp index 1b5a30a0f7a..27afd8ccab4 100644 --- a/registration/src/gicp6d.cpp +++ b/registration/src/gicp6d.cpp @@ -47,34 +47,39 @@ RGB2Lab(const Eigen::Vector3i& colorRGB) { // for sRGB -> CIEXYZ see http://www.easyrgb.com/index.php?X=MATH&H=02#text2 // for CIEXYZ -> CIELAB see http://www.easyrgb.com/index.php?X=MATH&H=07#text7 + // an overview at: https://www.comp.nus.edu.sg/~leowwk/papers/colordiff.pdf const auto& sRGB_LUT = RGB2sRGB_LUT(); - const auto& XYZ_LUT = XYZ2LAB_LUT(); const double R = sRGB_LUT[colorRGB[0]]; const double G = sRGB_LUT[colorRGB[1]]; const double B = sRGB_LUT[colorRGB[2]]; // linear sRGB -> CIEXYZ, D65 illuminant, observer at 2 degrees - double X = R * 0.4124 + G * 0.3576 + B * 0.1805; - double Y = R * 0.2126 + G * 0.7152 + B * 0.0722; - double Z = R * 0.0193 + G * 0.1192 + B * 0.9505; + const double X = R * 0.4124 + G * 0.3576 + B * 0.1805; + const double Y = R * 0.2126 + G * 0.7152 + B * 0.0722; + const double Z = R * 0.0193 + G * 0.1192 + B * 0.9505; // normalize X, Y, Z with tristimulus values for Xn, Yn, Zn - // and scale for using the LUT with 4000 steps - X = (X / 0.95047) * 4000; - Y = (Y / 1) * 4000; - Z = (Z / 1.08883) * 4000; + float f[3] = {static_cast(X), static_cast(Y), static_cast(Z)}; + f[0] /= 0.95047; + f[1] /= 1; + f[2] /= 1.08883; // CIEXYZ -> CIELAB - X = XYZ_LUT[static_cast(X)]; - Y = XYZ_LUT[static_cast(Y)]; - Z = XYZ_LUT[static_cast(Z)]; + for (int i = 0; i < 3; ++i) { + if (f[i] > 0.008856) { + f[i] = std::pow(f[i], 1.0 / 3.0); + } + else { + f[i] = 7.787 * f[i] + 16.0 / 116.0; + } + } Eigen::Vector3f colorLab; - colorLab[0] = static_cast(116.0 * Y - 16.0); - colorLab[1] = static_cast(500.0 * (X - Y)); - colorLab[2] = static_cast(200.0 * (Y - Z)); + colorLab[0] = 116.0f * f[1] - 16.0f; + colorLab[1] = 500.0f * (f[0] - f[1]); + colorLab[2] = 200.0f * (f[1] - f[2]); return colorLab; } From fcc948a10d1fe653fb93f4274c155fa38a4b14fe Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Fri, 9 Apr 2021 09:38:46 +0200 Subject: [PATCH 093/431] [CMake] Add AVX for windows (#4598) * Add AVX for windows * Update cmake/pcl_find_avx.cmake Co-authored-by: SunBlack --- CMakeLists.txt | 8 +++++++- cmake/pcl_find_avx.cmake | 41 ++++++++++++++++++++++++++++++++++++++++ cmake/pcl_options.cmake | 6 ++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 cmake/pcl_find_avx.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9997b151655..f4de5856f82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,12 @@ if(PCL_ENABLE_SSE AND "${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}" PCL_CHECK_FOR_SSE() endif() +# check for AVX flags for windows +if(PCL_ENABLE_AVX AND "${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}") + include("${PCL_SOURCE_DIR}/cmake/pcl_find_avx.cmake") + PCL_CHECK_FOR_AVX() +endif() + # ---[ Unix/Darwin/Windows specific flags if(CMAKE_COMPILER_IS_GNUCXX) if("${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}") @@ -127,7 +133,7 @@ if(CMAKE_COMPILER_IS_MSVC) add_compile_options(/bigobj) if("${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}") - string(APPEND CMAKE_CXX_FLAGS " /fp:precise /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 ${SSE_FLAGS_STR}") + string(APPEND CMAKE_CXX_FLAGS " /fp:precise /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 ${SSE_FLAGS_STR} ${AVX_FLAGS}") # Add extra code generation/link optimizations if(CMAKE_MSVC_CODE_LINK_OPTIMIZATION AND (NOT BUILD_CUDA) AND (NOT BUILD_GPU)) diff --git a/cmake/pcl_find_avx.cmake b/cmake/pcl_find_avx.cmake new file mode 100644 index 00000000000..d3187ea70e4 --- /dev/null +++ b/cmake/pcl_find_avx.cmake @@ -0,0 +1,41 @@ +############################################################################### +# Check for the presence of AVX and figure out the flags to use for it. +function(PCL_CHECK_FOR_AVX) + set(AVX_FLAGS) + + include(CheckCXXSourceRuns) + + check_cxx_source_runs(" + #include + int main() + { + __m256i a = {0}; + a = _mm256_abs_epi16(a); + return 0; + }" + HAVE_AVX2) + + if(NOT HAVE_AVX2) + check_cxx_source_runs(" + #include + int main() + { + __m256 a; + a = _mm256_set1_ps(0); + return 0; + }" + HAVE_AVX) + endif() + +# Setting the /arch defines __AVX(2)__, see here https://docs.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-160 +# AVX2 extends and includes AVX. +# Setting these defines allows the compiler to use AVX instructions as well as code guarded with the defines. +# TODO: Add AVX512 variant if needed. + if(MSVC) + if(HAVE_AVX2) + set(AVX_FLAGS "/arch:AVX2" PARENT_SCOPE) + elseif(HAVE_AVX) + set(AVX_FLAGS "/arch:AVX" PARENT_SCOPE) + endif() + endif() +endfunction() diff --git a/cmake/pcl_options.cmake b/cmake/pcl_options.cmake index b8e023486f2..c8d0a6506dc 100644 --- a/cmake/pcl_options.cmake +++ b/cmake/pcl_options.cmake @@ -44,6 +44,12 @@ mark_as_advanced(PCL_NO_PRECOMPILE) option(PCL_ENABLE_SSE "Enable or Disable SSE optimizations." ON) mark_as_advanced(PCL_ENABLE_SSE) +if(WIN32) + # Enable or Disable the check for AVX optimizations + option(PCL_ENABLE_AVX "Enable or Disable AVX optimizations." ON) + mark_as_advanced(PCL_ENABLE_AVX) +endif() + # Allow the user to enable compiler cache option(PCL_ENABLE_CCACHE "Enable using compiler cache for compilation" OFF) mark_as_advanced(PCL_ENABLE_CCACHE) From f8df44487c8c8105d0bd9e049e0b3df979f602c3 Mon Sep 17 00:00:00 2001 From: Yan Hang Date: Sat, 10 Apr 2021 22:52:51 +0800 Subject: [PATCH 094/431] removed md files from docs-pipeline.yaml Those md files are not part of the documentation, so no need for trigger. --- .ci/azure-pipelines/docs-pipeline.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml index c31ed8f26e8..4121c13f3d7 100644 --- a/.ci/azure-pipelines/docs-pipeline.yaml +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -2,9 +2,6 @@ trigger: paths: include: - doc - - README.md - - CHANGES.md - - CONTRIBUTING.md pr: paths: From 30294b9e810eb35a30830760a607f564fe4d8c42 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 9 Apr 2021 21:31:39 +0200 Subject: [PATCH 095/431] Enable more warnings on tutorial CI --- .ci/scripts/build_tutorials.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/scripts/build_tutorials.sh b/.ci/scripts/build_tutorials.sh index 169128ec943..c26d02d974e 100755 --- a/.ci/scripts/build_tutorials.sh +++ b/.ci/scripts/build_tutorials.sh @@ -73,7 +73,7 @@ for DIRECTORY in "$SOURCE_DIR"/*/ ; do TUTORIAL_BUILD_DIR="$BUILD_DIR/$NAME" mkdir -p "$TUTORIAL_BUILD_DIR" && cd "$TUTORIAL_BUILD_DIR" || exit echo "Configuring tutorial: $NAME" - if ! cmake "$TUTORIAL_SOURCE_DIR" -DPCL_DIR="$INSTALL_DIR" -DCMAKE_CXX_FLAGS="-Werror"; then + if ! cmake "$TUTORIAL_SOURCE_DIR" -DPCL_DIR="$INSTALL_DIR" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror"; then STATUS="cmake error" else echo "Building tutorial: $NAME" From e6dd586eeb8a0c177d4a6084db51ee837146754f Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 10:53:53 +0200 Subject: [PATCH 096/431] Remove unused argc, argv in tutorials --- doc/tutorials/content/sources/bare_earth/bare_earth.cpp | 2 +- .../content/sources/concatenate_fields/concatenate_fields.cpp | 2 +- .../content/sources/concatenate_points/concatenate_points.cpp | 2 +- .../content/sources/concave_hull_2d/concave_hull_2d.cpp | 2 +- .../conditional_euclidean_clustering.cpp | 2 +- .../sources/conditional_removal/conditional_removal.cpp | 2 +- .../content/sources/convex_hull_2d/convex_hull_2d.cpp | 2 +- .../sources/cylinder_segmentation/cylinder_segmentation.cpp | 2 +- .../content/sources/extract_indices/extract_indices.cpp | 2 +- .../content/sources/function_filter/sphere_removal.cpp | 2 +- .../content/sources/greedy_projection/greedy_projection.cpp | 2 +- .../iterative_closest_point/iterative_closest_point.cpp | 2 +- doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp | 2 +- .../sources/min_cut_segmentation/min_cut_segmentation.cpp | 4 ++-- .../normal_distributions_transform.cpp | 2 +- .../octree_change_detection/octree_change_detection.cpp | 2 +- doc/tutorials/content/sources/octree_search/octree_search.cpp | 2 +- doc/tutorials/content/sources/passthrough/passthrough.cpp | 2 +- doc/tutorials/content/sources/pcd_read/pcd_read.cpp | 2 +- doc/tutorials/content/sources/pcd_write/pcd_write.cpp | 2 +- .../content/sources/pcl_painter2D/pcl_painter2D_demo.cpp | 4 ++-- .../content/sources/pcl_plotter/pcl_plotter_demo.cpp | 2 +- .../sources/planar_segmentation/planar_segmentation.cpp | 2 +- .../point_cloud_compression/point_cloud_compression.cpp | 2 +- .../content/sources/project_inliers/project_inliers.cpp | 2 +- .../sources/radius_outlier_removal/radius_outlier_removal.cpp | 2 +- .../sources/range_image_creation/range_image_creation.cpp | 2 +- .../region_growing_rgb_segmentation.cpp | 2 +- .../region_growing_segmentation.cpp | 2 +- doc/tutorials/content/sources/resampling/resampling.cpp | 2 +- .../sources/statistical_removal/statistical_removal.cpp | 4 ++-- doc/tutorials/content/sources/voxel_grid/voxel_grid.cpp | 2 +- 32 files changed, 35 insertions(+), 35 deletions(-) diff --git a/doc/tutorials/content/sources/bare_earth/bare_earth.cpp b/doc/tutorials/content/sources/bare_earth/bare_earth.cpp index c09f49b08b1..c977407907e 100644 --- a/doc/tutorials/content/sources/bare_earth/bare_earth.cpp +++ b/doc/tutorials/content/sources/bare_earth/bare_earth.cpp @@ -5,7 +5,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/concatenate_fields/concatenate_fields.cpp b/doc/tutorials/content/sources/concatenate_fields/concatenate_fields.cpp index 8768aec32c1..74a3a4ab65f 100644 --- a/doc/tutorials/content/sources/concatenate_fields/concatenate_fields.cpp +++ b/doc/tutorials/content/sources/concatenate_fields/concatenate_fields.cpp @@ -3,7 +3,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud cloud_a; pcl::PointCloud cloud_b; diff --git a/doc/tutorials/content/sources/concatenate_points/concatenate_points.cpp b/doc/tutorials/content/sources/concatenate_points/concatenate_points.cpp index e3912109ed3..e0b7a1064b3 100644 --- a/doc/tutorials/content/sources/concatenate_points/concatenate_points.cpp +++ b/doc/tutorials/content/sources/concatenate_points/concatenate_points.cpp @@ -3,7 +3,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud cloud_a, cloud_b, cloud_c; diff --git a/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp b/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp index 828e904ffbf..9293d61a0a5 100644 --- a/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp +++ b/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp @@ -9,7 +9,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud), cloud_filtered (new pcl::PointCloud), diff --git a/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp b/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp index b2dcb748bf0..ee1a827e1c6 100644 --- a/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp +++ b/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp @@ -49,7 +49,7 @@ customRegionGrowing (const PointTypeFull& point_a, const PointTypeFull& point_b, } int -main (int argc, char** argv) +main () { // Data containers used pcl::PointCloud::Ptr cloud_in (new pcl::PointCloud), cloud_out (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/conditional_removal/conditional_removal.cpp b/doc/tutorials/content/sources/conditional_removal/conditional_removal.cpp index 7eb6dc35269..9b2a81c6776 100644 --- a/doc/tutorials/content/sources/conditional_removal/conditional_removal.cpp +++ b/doc/tutorials/content/sources/conditional_removal/conditional_removal.cpp @@ -3,7 +3,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp b/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp index ca9af729ee3..b2118533421 100644 --- a/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp +++ b/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp @@ -9,7 +9,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud), cloud_filtered (new pcl::PointCloud), cloud_projected (new pcl::PointCloud); pcl::PCDReader reader; diff --git a/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp b/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp index 703d8763693..1c2f7a4b2ff 100644 --- a/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp +++ b/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp @@ -11,7 +11,7 @@ typedef pcl::PointXYZ PointT; int -main (int argc, char** argv) +main () { // All the objects needed pcl::PCDReader reader; diff --git a/doc/tutorials/content/sources/extract_indices/extract_indices.cpp b/doc/tutorials/content/sources/extract_indices/extract_indices.cpp index 993f31b492c..ee4bc6be2db 100644 --- a/doc/tutorials/content/sources/extract_indices/extract_indices.cpp +++ b/doc/tutorials/content/sources/extract_indices/extract_indices.cpp @@ -9,7 +9,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PCLPointCloud2::Ptr cloud_blob (new pcl::PCLPointCloud2), cloud_filtered_blob (new pcl::PCLPointCloud2); pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud), cloud_p (new pcl::PointCloud), cloud_f (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/function_filter/sphere_removal.cpp b/doc/tutorials/content/sources/function_filter/sphere_removal.cpp index 858d28e44fe..1362c80d600 100644 --- a/doc/tutorials/content/sources/function_filter/sphere_removal.cpp +++ b/doc/tutorials/content/sources/function_filter/sphere_removal.cpp @@ -5,7 +5,7 @@ #include int -main(int argc, char** argv) +main() { using XYZCloud = pcl::PointCloud; const auto cloud = pcl::make_shared(); diff --git a/doc/tutorials/content/sources/greedy_projection/greedy_projection.cpp b/doc/tutorials/content/sources/greedy_projection/greedy_projection.cpp index 17df0e1400f..a0403c61ae8 100644 --- a/doc/tutorials/content/sources/greedy_projection/greedy_projection.cpp +++ b/doc/tutorials/content/sources/greedy_projection/greedy_projection.cpp @@ -5,7 +5,7 @@ #include int -main (int argc, char** argv) +main () { // Load input file into a PointCloud with an appropriate type pcl::PointCloud::Ptr cloud (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/iterative_closest_point/iterative_closest_point.cpp b/doc/tutorials/content/sources/iterative_closest_point/iterative_closest_point.cpp index 06cffa96eb1..d45ab78c837 100644 --- a/doc/tutorials/content/sources/iterative_closest_point/iterative_closest_point.cpp +++ b/doc/tutorials/content/sources/iterative_closest_point/iterative_closest_point.cpp @@ -4,7 +4,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud_in (new pcl::PointCloud(5,1)); pcl::PointCloud::Ptr cloud_out (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp b/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp index e704c9cc65c..d2b99cfa2ef 100644 --- a/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp +++ b/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp @@ -6,7 +6,7 @@ #include int -main (int argc, char** argv) +main () { srand (time (NULL)); diff --git a/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp b/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp index 31ce6979cfc..c3b23a3f378 100644 --- a/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp +++ b/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp @@ -6,7 +6,7 @@ #include #include -int main (int argc, char** argv) +int main () { pcl::PointCloud ::Ptr cloud (new pcl::PointCloud ); if ( pcl::io::loadPCDFile ("min_cut_segmentation_tutorial.pcd", *cloud) == -1 ) @@ -52,4 +52,4 @@ int main (int argc, char** argv) } return (0); -} \ No newline at end of file +} diff --git a/doc/tutorials/content/sources/normal_distributions_transform/normal_distributions_transform.cpp b/doc/tutorials/content/sources/normal_distributions_transform/normal_distributions_transform.cpp index 24938193ab8..b5a525d25da 100644 --- a/doc/tutorials/content/sources/normal_distributions_transform/normal_distributions_transform.cpp +++ b/doc/tutorials/content/sources/normal_distributions_transform/normal_distributions_transform.cpp @@ -12,7 +12,7 @@ using namespace std::chrono_literals; int -main (int argc, char** argv) +main () { // Loading first scan of room. pcl::PointCloud::Ptr target_cloud (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/octree_change_detection/octree_change_detection.cpp b/doc/tutorials/content/sources/octree_change_detection/octree_change_detection.cpp index 16aeef1c8cc..6f48ba3af96 100644 --- a/doc/tutorials/content/sources/octree_change_detection/octree_change_detection.cpp +++ b/doc/tutorials/content/sources/octree_change_detection/octree_change_detection.cpp @@ -6,7 +6,7 @@ #include int -main (int argc, char** argv) +main () { srand ((unsigned int) time (NULL)); diff --git a/doc/tutorials/content/sources/octree_search/octree_search.cpp b/doc/tutorials/content/sources/octree_search/octree_search.cpp index a37daad2fb0..6b49d22c5d5 100644 --- a/doc/tutorials/content/sources/octree_search/octree_search.cpp +++ b/doc/tutorials/content/sources/octree_search/octree_search.cpp @@ -6,7 +6,7 @@ #include int -main (int argc, char** argv) +main () { srand ((unsigned int) time (NULL)); diff --git a/doc/tutorials/content/sources/passthrough/passthrough.cpp b/doc/tutorials/content/sources/passthrough/passthrough.cpp index 98ec9b9c48d..b942ec6177c 100644 --- a/doc/tutorials/content/sources/passthrough/passthrough.cpp +++ b/doc/tutorials/content/sources/passthrough/passthrough.cpp @@ -3,7 +3,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/pcd_read/pcd_read.cpp b/doc/tutorials/content/sources/pcd_read/pcd_read.cpp index 0d92382925e..2b41d3d5019 100644 --- a/doc/tutorials/content/sources/pcd_read/pcd_read.cpp +++ b/doc/tutorials/content/sources/pcd_read/pcd_read.cpp @@ -3,7 +3,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/pcd_write/pcd_write.cpp b/doc/tutorials/content/sources/pcd_write/pcd_write.cpp index dd5638b559f..f42098871c6 100644 --- a/doc/tutorials/content/sources/pcd_write/pcd_write.cpp +++ b/doc/tutorials/content/sources/pcd_write/pcd_write.cpp @@ -3,7 +3,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud cloud; diff --git a/doc/tutorials/content/sources/pcl_painter2D/pcl_painter2D_demo.cpp b/doc/tutorials/content/sources/pcl_painter2D/pcl_painter2D_demo.cpp index 55082baa90d..9e578a4e323 100644 --- a/doc/tutorials/content/sources/pcl_painter2D/pcl_painter2D_demo.cpp +++ b/doc/tutorials/content/sources/pcl_painter2D/pcl_painter2D_demo.cpp @@ -6,7 +6,7 @@ #include //---------------------------------------------------------------------------- -int main (int argc, char * argv []) +int main () { pcl::visualization::PCLPainter2D *painter = new pcl::visualization::PCLPainter2D(); @@ -47,4 +47,4 @@ int main (int argc, char * argv []) return 0; -} \ No newline at end of file +} diff --git a/doc/tutorials/content/sources/pcl_plotter/pcl_plotter_demo.cpp b/doc/tutorials/content/sources/pcl_plotter/pcl_plotter_demo.cpp index aa832223b02..d1e173abba3 100644 --- a/doc/tutorials/content/sources/pcl_plotter/pcl_plotter_demo.cpp +++ b/doc/tutorials/content/sources/pcl_plotter/pcl_plotter_demo.cpp @@ -39,7 +39,7 @@ identity (double val) //............................................................................ int -main (int argc, char * argv []) +main () { //defining a plotter PCLPlotter *plotter = new PCLPlotter ("My Plotter"); diff --git a/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp b/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp index 07e6f8f0864..45cf0d5a698 100644 --- a/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp +++ b/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp @@ -7,7 +7,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud(new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/point_cloud_compression/point_cloud_compression.cpp b/doc/tutorials/content/sources/point_cloud_compression/point_cloud_compression.cpp index 0c1f9350475..7621752c5eb 100644 --- a/doc/tutorials/content/sources/point_cloud_compression/point_cloud_compression.cpp +++ b/doc/tutorials/content/sources/point_cloud_compression/point_cloud_compression.cpp @@ -90,7 +90,7 @@ class SimpleOpenNIViewer }; int -main (int argc, char **argv) +main () { SimpleOpenNIViewer v; v.run (); diff --git a/doc/tutorials/content/sources/project_inliers/project_inliers.cpp b/doc/tutorials/content/sources/project_inliers/project_inliers.cpp index b4d373d7965..325a271d759 100644 --- a/doc/tutorials/content/sources/project_inliers/project_inliers.cpp +++ b/doc/tutorials/content/sources/project_inliers/project_inliers.cpp @@ -5,7 +5,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::PointCloud::Ptr cloud_projected (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/radius_outlier_removal/radius_outlier_removal.cpp b/doc/tutorials/content/sources/radius_outlier_removal/radius_outlier_removal.cpp index 6093fcdda4a..64bdaea0622 100644 --- a/doc/tutorials/content/sources/radius_outlier_removal/radius_outlier_removal.cpp +++ b/doc/tutorials/content/sources/radius_outlier_removal/radius_outlier_removal.cpp @@ -3,7 +3,7 @@ #include int - main (int argc, char** argv) + main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud); diff --git a/doc/tutorials/content/sources/range_image_creation/range_image_creation.cpp b/doc/tutorials/content/sources/range_image_creation/range_image_creation.cpp index 8168cf1b9a2..a3d56ab13b1 100644 --- a/doc/tutorials/content/sources/range_image_creation/range_image_creation.cpp +++ b/doc/tutorials/content/sources/range_image_creation/range_image_creation.cpp @@ -1,6 +1,6 @@ #include -int main (int argc, char** argv) { +int main () { pcl::PointCloud pointCloud; // Generate the data diff --git a/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp b/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp index ba2db4119c8..1066d52a9e1 100644 --- a/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp +++ b/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp @@ -13,7 +13,7 @@ using namespace std::chrono_literals; int -main (int argc, char** argv) +main () { pcl::search::Search ::Ptr tree (new pcl::search::KdTree); diff --git a/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp b/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp index 5b472eae133..61646d98be6 100644 --- a/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp +++ b/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp @@ -10,7 +10,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); if ( pcl::io::loadPCDFile ("region_growing_tutorial.pcd", *cloud) == -1) diff --git a/doc/tutorials/content/sources/resampling/resampling.cpp b/doc/tutorials/content/sources/resampling/resampling.cpp index 0efbca9c30b..a47cb6d1ad7 100644 --- a/doc/tutorials/content/sources/resampling/resampling.cpp +++ b/doc/tutorials/content/sources/resampling/resampling.cpp @@ -4,7 +4,7 @@ #include int -main (int argc, char** argv) +main () { // Load input file into a PointCloud with an appropriate type pcl::PointCloud::Ptr cloud (new pcl::PointCloud ()); diff --git a/doc/tutorials/content/sources/statistical_removal/statistical_removal.cpp b/doc/tutorials/content/sources/statistical_removal/statistical_removal.cpp index 8ccba826f40..98e5aebef3c 100644 --- a/doc/tutorials/content/sources/statistical_removal/statistical_removal.cpp +++ b/doc/tutorials/content/sources/statistical_removal/statistical_removal.cpp @@ -4,7 +4,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PointCloud::Ptr cloud (new pcl::PointCloud); pcl::PointCloud::Ptr cloud_filtered (new pcl::PointCloud); @@ -35,4 +35,4 @@ main (int argc, char** argv) writer.write ("table_scene_lms400_outliers.pcd", *cloud_filtered, false); return (0); -} \ No newline at end of file +} diff --git a/doc/tutorials/content/sources/voxel_grid/voxel_grid.cpp b/doc/tutorials/content/sources/voxel_grid/voxel_grid.cpp index 95c52067408..a59feef7807 100644 --- a/doc/tutorials/content/sources/voxel_grid/voxel_grid.cpp +++ b/doc/tutorials/content/sources/voxel_grid/voxel_grid.cpp @@ -4,7 +4,7 @@ #include int -main (int argc, char** argv) +main () { pcl::PCLPointCloud2::Ptr cloud (new pcl::PCLPointCloud2 ()); pcl::PCLPointCloud2::Ptr cloud_filtered (new pcl::PCLPointCloud2 ()); From a6252e2db7f3faee94825aaf589c78a59a32b448 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 10:57:40 +0200 Subject: [PATCH 097/431] Remove wrong additional loop in tutorial --- .../content/sources/planar_segmentation/planar_segmentation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp b/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp index 45cf0d5a698..b78fcf97227 100644 --- a/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp +++ b/doc/tutorials/content/sources/planar_segmentation/planar_segmentation.cpp @@ -61,7 +61,6 @@ int << coefficients->values[3] << std::endl; std::cerr << "Model inliers: " << inliers->indices.size () << std::endl; - for (std::size_t i = 0; i < inliers->indices.size (); ++i) for (const auto& idx: inliers->indices) std::cerr << idx << " " << cloud->points[idx].x << " " << cloud->points[idx].y << " " From 815437a6fe68672064100f7b800c52912f04a98d Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 11:32:17 +0200 Subject: [PATCH 098/431] Solve sign-compare warnings in tutorials --- .../global_hypothesis_verification.cpp | 2 +- .../content/sources/iccv2011/src/correspondence_viewer.cpp | 2 +- doc/tutorials/content/sources/iccv2011/src/tutorial.cpp | 2 +- .../content/sources/iros2011/src/correspondence_viewer.cpp | 2 +- .../sources/model_outlier_removal/model_outlier_removal.cpp | 6 +++--- .../narf_descriptor_visualization.cpp | 2 +- .../random_sample_consensus/random_sample_consensus.cpp | 2 +- .../region_growing_segmentation.cpp | 2 +- doc/tutorials/content/sources/registration_api/example2.cpp | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/tutorials/content/sources/global_hypothesis_verification/global_hypothesis_verification.cpp b/doc/tutorials/content/sources/global_hypothesis_verification/global_hypothesis_verification.cpp index 26225bf77cd..293a9b108ea 100644 --- a/doc/tutorials/content/sources/global_hypothesis_verification/global_hypothesis_verification.cpp +++ b/doc/tutorials/content/sources/global_hypothesis_verification/global_hypothesis_verification.cpp @@ -451,7 +451,7 @@ main (int argc, GoHv.verify (); GoHv.getMask (hypotheses_mask); // i-element TRUE if hvModels[i] verifies hypotheses - for (int i = 0; i < hypotheses_mask.size (); i++) + for (std::size_t i = 0; i < hypotheses_mask.size (); i++) { if (hypotheses_mask[i]) { diff --git a/doc/tutorials/content/sources/iccv2011/src/correspondence_viewer.cpp b/doc/tutorials/content/sources/iccv2011/src/correspondence_viewer.cpp index 40297cccfa3..3ba7056d215 100644 --- a/doc/tutorials/content/sources/iccv2011/src/correspondence_viewer.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/correspondence_viewer.cpp @@ -71,7 +71,7 @@ void visualize_correspondences (const PointCloudPtr points1, const PointCloudPtr keypoints1, const PointCloudPtr points2, const PointCloudPtr keypoints2, const std::vector &correspondences, - const std::vector &correspondence_scores, int max_to_display) + const std::vector &correspondence_scores, std::size_t max_to_display) { // We want to visualize two clouds side-by-side, so do to this, we'll make copies of the clouds and transform them // by shifting one to the left and the other to the right. Then we'll draw lines between the corresponding points diff --git a/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp b/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp index a3570fa0198..616e8d440bb 100644 --- a/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp @@ -310,7 +310,7 @@ void ICCVTutorial::filterCorrespondences () std::cout << "correspondence rejection..." << std::flush; std::vector > correspondences; for (unsigned cIdx = 0; cIdx < source2target_.size (); ++cIdx) - if (target2source_[source2target_[cIdx]] == cIdx) + if (static_cast(target2source_[source2target_[cIdx]]) == cIdx) correspondences.push_back(std::make_pair(cIdx, source2target_[cIdx])); correspondences_->resize (correspondences.size()); diff --git a/doc/tutorials/content/sources/iros2011/src/correspondence_viewer.cpp b/doc/tutorials/content/sources/iros2011/src/correspondence_viewer.cpp index 40297cccfa3..3ba7056d215 100644 --- a/doc/tutorials/content/sources/iros2011/src/correspondence_viewer.cpp +++ b/doc/tutorials/content/sources/iros2011/src/correspondence_viewer.cpp @@ -71,7 +71,7 @@ void visualize_correspondences (const PointCloudPtr points1, const PointCloudPtr keypoints1, const PointCloudPtr points2, const PointCloudPtr keypoints2, const std::vector &correspondences, - const std::vector &correspondence_scores, int max_to_display) + const std::vector &correspondence_scores, std::size_t max_to_display) { // We want to visualize two clouds side-by-side, so do to this, we'll make copies of the clouds and transform them // by shifting one to the left and the other to the right. Then we'll draw lines between the corresponding points diff --git a/doc/tutorials/content/sources/model_outlier_removal/model_outlier_removal.cpp b/doc/tutorials/content/sources/model_outlier_removal/model_outlier_removal.cpp index b7de1fed328..80735fade99 100644 --- a/doc/tutorials/content/sources/model_outlier_removal/model_outlier_removal.cpp +++ b/doc/tutorials/content/sources/model_outlier_removal/model_outlier_removal.cpp @@ -9,8 +9,8 @@ main () pcl::PointCloud::Ptr cloud_sphere_filtered (new pcl::PointCloud); // 1. Generate cloud data - int noise_size = 5; - int sphere_data_size = 10; + std::size_t noise_size = 5; + std::size_t sphere_data_size = 10; cloud->width = noise_size + sphere_data_size; cloud->height = 1; cloud->points.resize (cloud->width * cloud->height); @@ -24,7 +24,7 @@ main () // 1.2 Add sphere: double rand_x1 = 1; double rand_x2 = 1; - for (std::size_t i = noise_size; i < noise_size + sphere_data_size; ++i) + for (std::size_t i = noise_size; i < (noise_size + sphere_data_size); ++i) { // See: http://mathworld.wolfram.com/SpherePointPicking.html while (pow (rand_x1, 2) + pow (rand_x2, 2) >= 1) diff --git a/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp b/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp index 25200c3daeb..87ca778d0bb 100644 --- a/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp +++ b/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp @@ -120,7 +120,7 @@ main (int argc, char** argv) std::cout << "Now extracting NARFs in every image point.\n"; std::vector > narfs; narfs.resize (range_image.size ()); - int last_percentage=-1; + unsigned int last_percentage=0; for (unsigned int y=0; yheight = 1; cloud->is_dense = false; cloud->points.resize (cloud->width * cloud->height); - for (pcl::index_t i = 0; i < cloud->size (); ++i) + for (pcl::index_t i = 0; i < static_cast(cloud->size ()); ++i) { if (pcl::console::find_argument (argc, argv, "-s") >= 0 || pcl::console::find_argument (argc, argv, "-sf") >= 0) { diff --git a/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp b/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp index 61646d98be6..2702b411036 100644 --- a/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp +++ b/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp @@ -52,7 +52,7 @@ main () std::cout << "First cluster has " << clusters[0].indices.size () << " points." << std::endl; std::cout << "These are the indices of the points of the initial" << std::endl << "cloud that belong to the first cluster:" << std::endl; - int counter = 0; + std::size_t counter = 0; while (counter < clusters[0].indices.size ()) { std::cout << clusters[0].indices[counter] << ", "; diff --git a/doc/tutorials/content/sources/registration_api/example2.cpp b/doc/tutorials/content/sources/registration_api/example2.cpp index fc70b24c632..18177a8e7e0 100644 --- a/doc/tutorials/content/sources/registration_api/example2.cpp +++ b/doc/tutorials/content/sources/registration_api/example2.cpp @@ -166,8 +166,8 @@ computeTransformation (const PointCloud::Ptr &src, // Reject correspondences based on their XYZ distance rejectBadCorrespondences (all_correspondences, keypoints_src, keypoints_tgt, *good_correspondences); - for (int i = 0; i < good_correspondences->size (); ++i) - std::cerr << good_correspondences->at (i) << std::endl; + for (const auto& corr : (*good_correspondences)) + std::cerr << corr << std::endl; // Obtain the best transformation between the two sets of keypoints given the remaining correspondences TransformationEstimationSVD trans_est; trans_est.estimateRigidTransformation (*keypoints_src, *keypoints_tgt, *good_correspondences, transform); From 301ce60cb2dbd9bff9dddef4cb0df7f0da0680a1 Mon Sep 17 00:00:00 2001 From: Yan Hang Date: Sun, 11 Apr 2021 03:42:30 +0800 Subject: [PATCH 099/431] fixed docs-pipeline.yaml removed md files from PR trigger, and added conditions for `documentation` and `tutorials` stages to make sure they run as expected. --- .ci/azure-pipelines/docs-pipeline.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml index 4121c13f3d7..42fd82a6b1d 100644 --- a/.ci/azure-pipelines/docs-pipeline.yaml +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -7,9 +7,6 @@ pr: paths: include: - doc - - README.md - - CHANGES.md - - CONTRIBUTING.md resources: pipelines: @@ -38,10 +35,12 @@ stages: - stage: documentation displayName: Documentation + condition: in(dependencies.formatting.result, 'Succeeded', 'SucceededWithIssues', 'Skipped') jobs: - template: documentation.yaml - stage: tutorials displayName: Tutorials + condition: in(dependencies.documentation.result, 'Succeeded', 'SucceededWithIssues') jobs: - template: tutorials.yaml From b3d77445a167a7f13fd754b9044e057fa3a919e4 Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Mon, 12 Apr 2021 22:09:45 +0300 Subject: [PATCH 100/431] =?UTF-8?q?replace=20uint32=5Ft=20to=20auto=20for?= =?UTF-8?q?=20Indices=20after=20@=C2=96mvieth=20proposition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filters/include/pcl/filters/impl/crop_hull.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filters/include/pcl/filters/impl/crop_hull.hpp b/filters/include/pcl/filters/impl/crop_hull.hpp index 7b913ba6bf0..166b598e664 100644 --- a/filters/include/pcl/filters/impl/crop_hull.hpp +++ b/filters/include/pcl/filters/impl/crop_hull.hpp @@ -106,7 +106,7 @@ pcl::CropHull::getHullCloudRange () ); for (pcl::Vertices const & poly : hull_polygons_) { - for (std::uint32_t const & idx : poly.vertices) + for (auto const & idx : poly.vertices) { Eigen::Vector3f pt = (*hull_cloud_)[idx].getVector3fMap (); cloud_min = cloud_min.cwiseMin(pt); From cbc195cb9a52aa9f042867f470998f131242a20c Mon Sep 17 00:00:00 2001 From: ueqri Date: Tue, 13 Apr 2021 21:24:46 +0800 Subject: [PATCH 101/431] simplified condition expression --- .ci/azure-pipelines/docs-pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml index 42fd82a6b1d..bde0ec8bfda 100644 --- a/.ci/azure-pipelines/docs-pipeline.yaml +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -29,7 +29,7 @@ stages: # if docs pipeline triggered by build_gcc stage, # the formatting stage has already run, thus it # won't run for a second time here. - condition: not(eq(variables['Build.Reason'], 'ResourceTrigger')) + condition: ne(variables['Build.Reason'], 'ResourceTrigger')) jobs: - template: formatting.yaml From a53ef5aa26797a0c6cd18beeab361bd9630db65a Mon Sep 17 00:00:00 2001 From: Daniil Nikulin Date: Tue, 13 Apr 2021 19:20:55 +0300 Subject: [PATCH 102/431] uint32_t -> pcl::index_t in test_crop_hull --- test/filters/test_crop_hull.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/filters/test_crop_hull.cpp b/test/filters/test_crop_hull.cpp index 0b534f1e59a..d46838a3baf 100644 --- a/test/filters/test_crop_hull.cpp +++ b/test/filters/test_crop_hull.cpp @@ -198,7 +198,7 @@ template struct RandomGenerator }; -static std::vector> cube_elements = { +static std::vector> cube_elements = { {0, 2, 1}, // l {1, 2, 3}, // l {3, 2, 6}, // f From 0afd2a9522f57904daa0cd34b54d9b6be2fd4f25 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Wed, 14 Apr 2021 08:18:41 +0530 Subject: [PATCH 103/431] Update LICENSE blurb in CONTRIBUTION.md (#4696) --- CONTRIBUTING.md | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71aa4672da6..c940ed3bcdf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -114,40 +114,12 @@ of each `.h` and `.cpp` file: ```cpp /* - * Software License Agreement (BSD License) + * SPDX-License-Identifier: BSD-3-Clause * * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2014-, Open Perception, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of the copyright holder(s) nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Copyright (c) 2014-, Open Perception Inc. * + * All rights reserved */ ``` From 6f2ab13b960206431ce7cc2009611814295890e3 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Wed, 14 Apr 2021 21:49:37 +0200 Subject: [PATCH 104/431] Octree compression test: add function for random cloud generation --- test/io/test_octree_compression.cpp | 87 +++++++++++------------------ 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/test/io/test_octree_compression.cpp b/test/io/test_octree_compression.cpp index e71305300f0..89618c86096 100644 --- a/test/io/test_octree_compression.cpp +++ b/test/io/test_octree_compression.cpp @@ -51,6 +51,36 @@ char* pcd_file; #define MAX_COLOR 255 #define NUMBER_OF_TEST_RUNS 3 +template inline PointT generateRandomPoint(const float MAX_XYZ); + +template<> inline pcl::PointXYZRGBA generateRandomPoint(const float MAX_XYZ) { + return pcl::PointXYZRGBA(static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_COLOR * rand() / RAND_MAX), + static_cast (MAX_COLOR * rand() / RAND_MAX), + static_cast (MAX_COLOR * rand() / RAND_MAX), + static_cast (MAX_COLOR * rand() / RAND_MAX)); +} + +template<> inline pcl::PointXYZ generateRandomPoint(const float MAX_XYZ) { + return pcl::PointXYZ(static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_XYZ * rand() / RAND_MAX), + static_cast (MAX_XYZ * rand() / RAND_MAX)); +} + +template inline +typename pcl::PointCloud::Ptr generateRandomCloud(const float MAX_XYZ) { + // empty point cloud hangs decoder + const unsigned int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; + // create shared pointcloud instances + typename pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); + for (unsigned int point = 0; point < point_count; point++) { + cloud->push_back(generateRandomPoint(MAX_XYZ)); + } + return cloud; +} + TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) { srand(static_cast (time(NULL))); @@ -65,26 +95,7 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) // iterate over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - // empty point cloud hangs decoder - const int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; - // create shared pointcloud instances - pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); - // assign input point clouds to octree - // create random point cloud - for (int point = 0; point < point_count; point++) - { - // generate a random point - pcl::PointXYZRGBA new_point; - new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), - new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); - // OctreePointCloudPointVector can store all points.. - cloud->push_back(new_point); - } + auto cloud = generateRandomCloud(MAX_XYZ); EXPECT_EQ(cloud->height, 1); // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; @@ -119,20 +130,7 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZ) // loop over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - // empty point cloud hangs decoder - const int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; - // create shared pointcloud instances - pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); - // assign input point clouds to octree - // create random point cloud - for (int point = 0; point < point_count; point++) - { - // generate a random point - pcl::PointXYZ new_point(static_cast (MAX_XYZ * rand() / RAND_MAX), - static_cast (MAX_XYZ * rand() / RAND_MAX), - static_cast (MAX_XYZ * rand() / RAND_MAX)); - cloud->push_back(new_point); - } + auto cloud = generateRandomCloud(MAX_XYZ); EXPECT_EQ(cloud->height, 1); // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; std::stringstream compressed_data; @@ -164,26 +162,7 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBASameCloud) pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); pcl::io::OctreePointCloudCompression pointcloud_decoder; - // empty point cloud hangs decoder - const int point_count = 1 + (MAX_POINTS - 1) * rand() / RAND_MAX; - // create shared pointcloud instances - pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); - // assign input point clouds to octree - // create random point cloud - for (int point = 0; point < point_count; point++) - { - // generate a random point - pcl::PointXYZRGBA new_point; - new_point.x = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.y = static_cast (MAX_XYZ * rand() / RAND_MAX), - new_point.z = static_cast (MAX_XYZ * rand() / RAND_MAX); - new_point.r = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.g = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.b = static_cast (MAX_COLOR * rand() / RAND_MAX); - new_point.a = static_cast (MAX_COLOR * rand() / RAND_MAX); - // OctreePointCloudPointVector can store all points.. - cloud->push_back(new_point); - } + auto cloud = generateRandomCloud(MAX_XYZ); EXPECT_EQ(cloud->height, 1); // iterate over runs From e7939aec32b27b0613d20c47ebb8e364d5fde796 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Thu, 15 Apr 2021 16:05:12 +0200 Subject: [PATCH 105/431] [CMake] Add SSE definitions for SSE 4.1 and 4.2 (#4596) * Restructure and add additional SSE definitions Co-authored-by: SunBlack --- CMakeLists.txt | 4 +- cmake/pcl_find_sse.cmake | 399 ++++++++++++++++++++++----------------- 2 files changed, 225 insertions(+), 178 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4de5856f82..beb00c8e4b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) else() string(APPEND CMAKE_CXX_FLAGS " -Wabi") endif() - string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare -Wno-invalid-offsetof -Wno-conversion ${SSE_FLAGS_STR}") + string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare -Wno-invalid-offsetof -Wno-conversion ${SSE_FLAGS}") if(PCL_WARNINGS_ARE_ERRORS) string(APPEND CMAKE_CXX_FLAGS " -Werror") endif() @@ -133,7 +133,7 @@ if(CMAKE_COMPILER_IS_MSVC) add_compile_options(/bigobj) if("${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}") - string(APPEND CMAKE_CXX_FLAGS " /fp:precise /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 ${SSE_FLAGS_STR} ${AVX_FLAGS}") + string(APPEND CMAKE_CXX_FLAGS " /fp:precise /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 ${SSE_FLAGS} ${AVX_FLAGS}") # Add extra code generation/link optimizations if(CMAKE_MSVC_CODE_LINK_OPTIMIZATION AND (NOT BUILD_CUDA) AND (NOT BUILD_GPU)) diff --git a/cmake/pcl_find_sse.cmake b/cmake/pcl_find_sse.cmake index b64f6bce0d6..541ec580b55 100644 --- a/cmake/pcl_find_sse.cmake +++ b/cmake/pcl_find_sse.cmake @@ -1,210 +1,257 @@ ############################################################################### # Check for the presence of SSE and figure out the flags to use for it. -macro(PCL_CHECK_FOR_SSE) - set(SSE_FLAGS) - set(SSE_DEFINITIONS) - - if(NOT CMAKE_CROSSCOMPILING) - # Test GCC/G++ and CLANG - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag("-march=native" HAVE_MARCH) - if(HAVE_MARCH) - list(APPEND SSE_FLAGS "-march=native") - else() - list(APPEND SSE_FLAGS "-mtune=native") - endif() - message(STATUS "Using CPU native flags for SSE optimization: ${SSE_FLAGS}") - endif() - endif() - - # Unfortunately we need to check for SSE to enable "-mfpmath=sse" alongside - # "-march=native". The reason for this is that by default, 32bit architectures - # tend to use the x87 FPU (which has 80 bit internal precision), thus leading - # to different results than 64bit architectures which are using SSE2 (64 bit internal - # precision). One solution would be to use "-ffloat-store" on 32bit (see - # http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html), but that slows code down, - # so the preferred solution is to try "-mpfmath=sse" first. - include(CheckCXXSourceRuns) - set(CMAKE_REQUIRED_FLAGS) +function(PCL_CHECK_FOR_SSE) + set(SSE_FLAGS) + set(SSE_DEFINITIONS) - check_cxx_source_runs(" - // Intel compiler defines an incompatible _mm_malloc signature - #if defined(__INTEL_COMPILER) - #include - #else - #include - #endif - int main() - { - void* mem = _mm_malloc (100, 16); - return 0; - }" - HAVE_MM_MALLOC) + if(NOT CMAKE_CROSSCOMPILING) + # Test GCC/G++ and CLANG + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("-march=native" HAVE_MARCH) + if(HAVE_MARCH) + list(APPEND SSE_FLAGS "-march=native") + else() + list(APPEND SSE_FLAGS "-mtune=native") + endif() + message(STATUS "Using CPU native flags for SSE optimization: ${SSE_FLAGS}") + endif() + endif() - check_cxx_source_runs(" - #include - int main() - { - void* mem; - return posix_memalign (&mem, 16, 100); - }" - HAVE_POSIX_MEMALIGN) + # Unfortunately we need to check for SSE to enable "-mfpmath=sse" alongside + # "-march=native". The reason for this is that by default, 32bit architectures + # tend to use the x87 FPU (which has 80 bit internal precision), thus leading + # to different results than 64bit architectures which are using SSE2 (64 bit internal + # precision). One solution would be to use "-ffloat-store" on 32bit (see + # http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html), but that slows code down, + # so the preferred solution is to try "-mpfmath=sse" first. + include(CheckCXXSourceRuns) + set(CMAKE_REQUIRED_FLAGS) + set(SSE_LEVEL 0) + + check_cxx_source_runs(" + // Intel compiler defines an incompatible _mm_malloc signature + #if defined(__INTEL_COMPILER) + #include + #else + #include + #endif + int main() + { + void* mem = _mm_malloc (100, 16); + return 0; + }" + HAVE_MM_MALLOC) + + check_cxx_source_runs(" + #include + int main() + { + void* mem; + return posix_memalign (&mem, 16, 100); + }" + HAVE_POSIX_MEMALIGN) + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + set(CMAKE_REQUIRED_FLAGS "-msse4.2") + endif() + + check_cxx_source_runs(" + #include + #include + int main () + { + long long a[2] = { 1, 2 }; + long long b[2] = { -1, 3 }; + long long c[2]; + __m128i va = _mm_loadu_si128 ((__m128i*)a); + __m128i vb = _mm_loadu_si128 ((__m128i*)b); + __m128i vc = _mm_cmpgt_epi64 (va, vb); + + _mm_storeu_si128 ((__m128i*)c, vc); + if (c[0] == -1LL && c[1] == 0LL) + return (0); + else + return (1); + }" + HAVE_SSE4_2_EXTENSIONS) + + if(HAVE_SSE4_2_EXTENSIONS) + set(SSE_LEVEL 4.2) + endif() + + if(SSE_LEVEL LESS 4.2) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_REQUIRED_FLAGS "-msse4.2") + set(CMAKE_REQUIRED_FLAGS "-msse4.1") endif() check_cxx_source_runs(" - #include - #include - int main () - { - long long a[2] = { 1, 2 }; - long long b[2] = { -1, 3 }; - long long c[2]; - __m128i va = _mm_loadu_si128 ((__m128i*)a); - __m128i vb = _mm_loadu_si128 ((__m128i*)b); - __m128i vc = _mm_cmpgt_epi64 (va, vb); - - _mm_storeu_si128 ((__m128i*)c, vc); - if (c[0] == -1LL && c[1] == 0LL) - return (0); - else - return (1); - }" - HAVE_SSE4_2_EXTENSIONS) + #include + int main () + { + __m128 a, b; + float vals[4] = {1, 2, 3, 4}; + const int mask = 123; + a = _mm_loadu_ps (vals); + b = a; + b = _mm_dp_ps (a, a, mask); + _mm_storeu_ps (vals,b); + return (0); + }" + HAVE_SSE4_1_EXTENSIONS) + + if(HAVE_SSE4_1_EXTENSIONS) + set(SSE_LEVEL 4.1) + endif() + endif() + if(SSE_LEVEL LESS 4.1) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_REQUIRED_FLAGS "-msse4.1") + set(CMAKE_REQUIRED_FLAGS "-mssse3") endif() - + check_cxx_source_runs(" - #include - int main () - { - __m128 a, b; - float vals[4] = {1, 2, 3, 4}; - const int mask = 123; - a = _mm_loadu_ps (vals); - b = a; - b = _mm_dp_ps (a, a, mask); - _mm_storeu_ps (vals,b); - return (0); - }" - HAVE_SSE4_1_EXTENSIONS) + #include + int main () + { + __m128i a, b; + int vals[4] = {-1, -2, -3, -4}; + a = _mm_loadu_si128 ((const __m128i*)vals); + b = _mm_abs_epi32 (a); + _mm_storeu_si128 ((__m128i*)vals, b); + return (0); + }" + HAVE_SSSE3_EXTENSIONS) + if(HAVE_SSSE3_EXTENSIONS) + set(SSE_LEVEL 3.1) + endif() + endif() + + if(SSE_LEVEL LESS 3.1) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_REQUIRED_FLAGS "-mssse3") + set(CMAKE_REQUIRED_FLAGS "-msse3") endif() check_cxx_source_runs(" - #include - int main () - { - __m128i a, b; - int vals[4] = {-1, -2, -3, -4}; - a = _mm_loadu_si128 ((const __m128i*)vals); - b = _mm_abs_epi32 (a); - _mm_storeu_si128 ((__m128i*)vals, b); + #include + int main () + { + __m128d a, b; + double vals[2] = {0}; + a = _mm_loadu_pd (vals); + b = _mm_hadd_pd (a,a); + _mm_storeu_pd (vals, b); return (0); - }" - HAVE_SSSE3_EXTENSIONS) + }" + HAVE_SSE3_EXTENSIONS) - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_REQUIRED_FLAGS "-msse3") + if(HAVE_SSE3_EXTENSIONS) + set( SSE_LEVEL 3.0) endif() + endif() - check_cxx_source_runs(" - #include - int main () - { - __m128d a, b; - double vals[2] = {0}; - a = _mm_loadu_pd (vals); - b = _mm_hadd_pd (a,a); - _mm_storeu_pd (vals, b); - return (0); - }" - HAVE_SSE3_EXTENSIONS) - + if(SSE_LEVEL LESS 3.0) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_REQUIRED_FLAGS "-msse2") + set(CMAKE_REQUIRED_FLAGS "-msse2") elseif(MSVC AND NOT CMAKE_CL_64) - set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") + set(CMAKE_REQUIRED_FLAGS "/arch:SSE2") endif() check_cxx_source_runs(" - #include - int main () - { - __m128d a, b; - double vals[2] = {0}; - a = _mm_loadu_pd (vals); - b = _mm_add_pd (a,a); - _mm_storeu_pd (vals,b); - return (0); - }" - HAVE_SSE2_EXTENSIONS) + #include + int main () + { + __m128d a, b; + double vals[2] = {0}; + a = _mm_loadu_pd (vals); + b = _mm_add_pd (a,a); + _mm_storeu_pd (vals,b); + return (0); + }" + HAVE_SSE2_EXTENSIONS) + + if(HAVE_SSE2_EXTENSIONS) + set(SSE_LEVEL 2.0) + endif() + endif() + if(SSE_LEVEL LESS 2.0) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - set(CMAKE_REQUIRED_FLAGS "-msse") + set(CMAKE_REQUIRED_FLAGS "-msse") elseif(MSVC AND NOT CMAKE_CL_64) - set(CMAKE_REQUIRED_FLAGS "/arch:SSE") + set(CMAKE_REQUIRED_FLAGS "/arch:SSE") endif() check_cxx_source_runs(" - #include - int main () - { - __m128 a, b; - float vals[4] = {0}; - a = _mm_loadu_ps (vals); - b = a; - b = _mm_add_ps (a,b); - _mm_storeu_ps (vals,b); - return (0); - }" - HAVE_SSE_EXTENSIONS) - - set(CMAKE_REQUIRED_FLAGS) + #include + int main () + { + __m128 a, b; + float vals[4] = {0}; + a = _mm_loadu_ps (vals); + b = a; + b = _mm_add_ps (a,b); + _mm_storeu_ps (vals,b); + return (0); + }" + HAVE_SSE_EXTENSIONS) - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) - if(HAVE_SSE4_2_EXTENSIONS) - list(APPEND SSE_FLAGS "-msse4.2" "-mfpmath=sse") - elseif(HAVE_SSE4_1_EXTENSIONS) - list(APPEND SSE_FLAGS "-msse4.1" "-mfpmath=sse") - elseif(HAVE_SSSE3_EXTENSIONS) - list(APPEND SSE_FLAGS "-mssse3" "-mfpmath=sse") - elseif(HAVE_SSE3_EXTENSIONS) - list(APPEND SSE_FLAGS "-msse3" "-mfpmath=sse") - elseif(HAVE_SSE2_EXTENSIONS) - list(APPEND SSE_FLAGS "-msse2" "-mfpmath=sse") - elseif(HAVE_SSE_EXTENSIONS) - list(APPEND SSE_FLAGS "-msse" "-mfpmath=sse") - else() - # Setting -ffloat-store to alleviate 32bit vs 64bit discrepancies on non-SSE - # platforms. - list(APPEND SSE_FLAGS "-ffloat-store") - endif() - elseif(MSVC AND NOT CMAKE_CL_64) - if(HAVE_SSE2_EXTENSIONS) - list(APPEND SSE_FLAGS "/arch:SSE2") - elseif(HAVE_SSE_EXTENSIONS) - list(APPEND SSE_FLAGS "/arch:SSE") - endif() - endif() - - if(MSVC) - if(HAVE_SSSE3_EXTENSIONS) - string(APPEND SSE_DEFINITIONS " -D__SSSE3__") - endif() - if(HAVE_SSE2_EXTENSIONS) - string(APPEND SSE_DEFINITIONS " -D__SSE2__") - endif() - if(HAVE_SSE_EXTENSIONS) - string(APPEND SSE_DEFINITIONS " -D__SSE__") - endif() - endif() - string(REPLACE ";" " " SSE_FLAGS_STR "${SSE_FLAGS}") -endmacro() + if(HAVE_SSE_EXTENSIONS) + set(SSE_LEVEL 1.0) + endif() + endif() + + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG) + if(SSE_LEVEL GREATER_EQUAL 1.0) + if(SSE_LEVEL GREATER_EQUAL 4.2) + set(SSE_FLAGS "-msse4.2") + elseif(SSE_LEVEL GREATER_EQUAL 4.1) + set(SSE_FLAGS "-msse4.1") + elseif(SSE_LEVEL GREATER_EQUAL 3.1) + set(SSE_FLAGS "-msse3") + elseif(SSE_LEVEL GREATER_EQUAL 3.0) + set(SSE_FLAGS "-msse3") + elseif(SSE_LEVEL GREATER_EQUAL 2.0) + set(SSE_FLAGS "-msse2") + else() + set(SSE_FLAGS "-msse") + endif() + string(APPEND SSE_FLAGS " -mfpmath=sse") + else() + # Setting -ffloat-store to alleviate 32bit vs 64bit discrepancies on non-SSE + # platforms. + list(APPEND SSE_FLAGS "-ffloat-store") + endif() + elseif(MSVC AND NOT CMAKE_SIZEOF_VOID_P) + if(SSE_LEVEL GREATER_EQUAL 2.0) + set( SSE_FLAGS "/arch:SSE2") + elseif(SSE_LEVEL GREATER_EQUAL 1.0) + set( SSE_FLAGS "/arch:SSE") + endif() + elseif(MSVC) + if(SSE_LEVEL GREATER_EQUAL 4.2) + string(APPEND SSE_DEFINITIONS " -D__SSE4_2__") + endif() + if(SSE_LEVEL GREATER_EQUAL 4.1) + string(APPEND SSE_DEFINITIONS " -D__SSE4_1__") + endif() + if(SSE_LEVEL GREATER_EQUAL 3.1) + string(APPEND SSE_DEFINITIONS " -D__SSSE3__") + endif() + if(SSE_LEVEL GREATER_EQUAL 3.0) + string(APPEND SSE_DEFINITIONS " -D__SSE3__") + endif() + if(SSE_LEVEL GREATER_EQUAL 2.0) + string(APPEND SSE_DEFINITIONS " -D__SSE2__") + endif() + if(SSE_LEVEL GREATER_EQUAL 1.0) + string(APPEND SSE_DEFINITIONS " -D__SSE__") + endif() + endif() + + set(SSE_FLAGS ${SSE_FLAGS} PARENT_SCOPE) + set(SSE_DEFINITIONS ${SSE_DEFINITIONS} PARENT_SCOPE) + + unset(CMAKE_REQUIRED_FLAGS) +endfunction() From b20ead022ae2013dedf06c55988062000520892a Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Thu, 15 Apr 2021 21:25:36 +0200 Subject: [PATCH 106/431] Unify test for XYZ and XYZRGBA by using typed test --- test/io/test_octree_compression.cpp | 50 +++++++---------------------- 1 file changed, 11 insertions(+), 39 deletions(-) diff --git a/test/io/test_octree_compression.cpp b/test/io/test_octree_compression.cpp index 89618c86096..d268e45dd2c 100644 --- a/test/io/test_octree_compression.cpp +++ b/test/io/test_octree_compression.cpp @@ -81,7 +81,13 @@ typename pcl::PointCloud::Ptr generateRandomCloud(const float MAX_XYZ) { return cloud; } -TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) +template +class OctreeDeCompressionTest : public testing::Test {}; + +using TestTypes = ::testing::Types; +TYPED_TEST_SUITE(OctreeDeCompressionTest, TestTypes); + +TYPED_TEST (OctreeDeCompressionTest, RandomClouds) { srand(static_cast (time(NULL))); for (const double MAX_XYZ : {1.0, 1024.0}) { // Small clouds, large clouds @@ -89,13 +95,13 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) { // instantiate point cloud compression encoder/decoder - pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); - pcl::io::OctreePointCloudCompression pointcloud_decoder; - pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); + pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); + pcl::io::OctreePointCloudCompression pointcloud_decoder; + typename pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); // iterate over runs for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) { - auto cloud = generateRandomCloud(MAX_XYZ); + auto cloud = generateRandomCloud(MAX_XYZ); EXPECT_EQ(cloud->height, 1); // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; @@ -115,40 +121,6 @@ TEST (PCL, OctreeDeCompressionRandomPointXYZRGBA) } // small clouds, large clouds } // TEST -TEST (PCL, OctreeDeCompressionRandomPointXYZ) -{ - srand(static_cast (time(NULL))); - for (const double MAX_XYZ : {1.0, 1024.0}) { // Small clouds, large clouds - // iterate over all pre-defined compression profiles - for (int compression_profile = pcl::io::LOW_RES_ONLINE_COMPRESSION_WITHOUT_COLOR; - compression_profile != pcl::io::COMPRESSION_PROFILE_COUNT; ++compression_profile) - { - // instantiate point cloud compression encoder/decoder - pcl::io::OctreePointCloudCompression pointcloud_encoder((pcl::io::compression_Profiles_e) compression_profile, false); - pcl::io::OctreePointCloudCompression pointcloud_decoder; - pcl::PointCloud::Ptr cloud_out(new pcl::PointCloud()); - // loop over runs - for (int test_idx = 0; test_idx < NUMBER_OF_TEST_RUNS; test_idx++, total_runs++) - { - auto cloud = generateRandomCloud(MAX_XYZ); - EXPECT_EQ(cloud->height, 1); - // std::cout << "Run: " << total_runs << " compression profile:" << compression_profile << " point_count: " << point_count; - std::stringstream compressed_data; - pointcloud_encoder.encodePointCloud(cloud, compressed_data); - pointcloud_decoder.decodePointCloud(compressed_data, cloud_out); - if (pcl::io::compressionProfiles_[compression_profile].doVoxelGridDownSampling) { - EXPECT_GT(cloud_out->width, 0); - EXPECT_LE(cloud_out->width, cloud->width) << "cloud width after encoding and decoding greater than before. Profile: " << compression_profile; - } - else { - EXPECT_EQ(cloud_out->width, cloud->width) << "cloud width after encoding and decoding not the same. Profile: " << compression_profile; - } - EXPECT_EQ(cloud_out->height, 1) << "cloud height after encoding and decoding should be 1 (as before). Profile: " << compression_profile; - } // runs - } // compression profiles - } // small clouds, large clouds -} // TEST - TEST (PCL, OctreeDeCompressionRandomPointXYZRGBASameCloud) { // Generate a random cloud. Put it into the encoder several times and make From 69ec601e013069ecc27bbadcb02773c06315523d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sat, 17 Apr 2021 01:45:12 +0100 Subject: [PATCH 107/431] Consistently use lowercase for headers and libs for Windows When building on Windows, a case-insensitive file-system is usually employed, but when cross-compiling on a Linux host for a Windows target case-senstive file-systems are more common. MinGW is the most common cross-compiler and consistently uses lowercase names for all libraries and header files. --- io/include/pcl/io/low_level_io.h | 2 +- surface/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/io/include/pcl/io/low_level_io.h b/io/include/pcl/io/low_level_io.h index 39ad6d246c3..1950aa42cbd 100644 --- a/io/include/pcl/io/low_level_io.h +++ b/io/include/pcl/io/low_level_io.h @@ -51,7 +51,7 @@ # endif # include # include -# include +# include using ssize_t = SSIZE_T; #else # include diff --git a/surface/CMakeLists.txt b/surface/CMakeLists.txt index 9ccf3b3c0fb..eae2d3ae011 100644 --- a/surface/CMakeLists.txt +++ b/surface/CMakeLists.txt @@ -193,5 +193,5 @@ if(VTK_FOUND AND NOT ANDROID) endif() if(WIN32) - target_link_libraries("${LIB_NAME}" Rpcrt4.lib) + target_link_libraries("${LIB_NAME}" rpcrt4.lib) endif() From a8e2170a6f12dd31f668c98a2e2a5b0dd921e73e Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Sat, 17 Apr 2021 17:15:42 +0200 Subject: [PATCH 108/431] Fix compile issue of visualization::details::fillCells under MSVC due to missing symbol export --- visualization/include/pcl/visualization/pcl_visualizer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visualization/include/pcl/visualization/pcl_visualizer.h b/visualization/include/pcl/visualization/pcl_visualizer.h index 1c0c0154d88..c847ac9ac4a 100644 --- a/visualization/include/pcl/visualization/pcl_visualizer.h +++ b/visualization/include/pcl/visualization/pcl_visualizer.h @@ -80,7 +80,7 @@ namespace pcl { namespace details { - vtkIdType fillCells(std::vector& lookup, const std::vector& vertices, vtkSmartPointer cell_array, int max_size_of_polygon); + PCL_EXPORTS vtkIdType fillCells(std::vector& lookup, const std::vector& vertices, vtkSmartPointer cell_array, int max_size_of_polygon); } /** \brief PCL Visualizer main class. From 2279d91a42b00623d73d4dc0ff6b20e721d99bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sat, 17 Apr 2021 19:04:37 +0100 Subject: [PATCH 109/431] Link pcl_io against `ws2_32` when building with MinGW --- io/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt index d26e6042179..ab918424e07 100644 --- a/io/CMakeLists.txt +++ b/io/CMakeLists.txt @@ -204,6 +204,10 @@ set(PLY_INCLUDES ) PCL_ADD_LIBRARY(pcl_io_ply COMPONENT ${SUBSYS_NAME} SOURCES ${PLY_SOURCES} ${PLY_INCLUDES}) +if(MINGW) + # libws2_32 isn't added by default for MinGW + target_link_libraries(pcl_io_ply ws2_32) +endif() PCL_ADD_INCLUDES("${SUBSYS_NAME}" "${SUBSYS_NAME}/ply" ${PLY_INCLUDES}) target_include_directories(pcl_io_ply PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") From 69f6c51c8947dfd4b611b04fd65ee7419b93fd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Sat, 17 Apr 2021 19:21:42 +0100 Subject: [PATCH 110/431] Alias `ssize_t` to `SSIZE_T` only for MSVC MinGW defines `ssize_t` as `int` for a 32-bit target (https://github.com/mirror/mingw-w64/blob/c6e13e0c105eab7797c2373819b49fff6b05566c/mingw-w64-headers/crt/time.h#L76-L80), which conflicts with the definition of `SSIZE_T`, which is `LONG_PTR`, i.e. `long` for a 32-bit target (https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types). --- io/include/pcl/io/low_level_io.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/io/include/pcl/io/low_level_io.h b/io/include/pcl/io/low_level_io.h index 1950aa42cbd..e59d1a632ed 100644 --- a/io/include/pcl/io/low_level_io.h +++ b/io/include/pcl/io/low_level_io.h @@ -51,8 +51,12 @@ # endif # include # include -# include +# ifdef _MSC_VER +// ssize_t is already defined in MinGW and its definition conflicts with that of +// SSIZE_T on a 32-bit target, so do this only for MSVC. +# include using ssize_t = SSIZE_T; +# endif /* _MSC_VER */ #else # include # include From 64a31d3a6596bc386981786f72576c5ad7625f15 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Thu, 15 Apr 2021 16:06:04 +0200 Subject: [PATCH 111/431] More std::floor to floorf fixes. --- gpu/features/src/fpfh.cu | 8 +++++--- gpu/features/src/pfh.cu | 14 ++++++++------ gpu/features/src/spinimages.cu | 6 ++++-- gpu/features/src/vfh.cu | 12 +++++++----- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/gpu/features/src/fpfh.cu b/gpu/features/src/fpfh.cu index f51055029c2..d2ae7fda43d 100644 --- a/gpu/features/src/fpfh.cu +++ b/gpu/features/src/fpfh.cu @@ -140,15 +140,17 @@ namespace pcl if (computePairFeatures (current_point[warp_idx], current_nomal[warp_idx], p, n, f1, f2, f3, f4)) { // Normalize the f1, f2, f3 features and push them in the histogram - h_index = std::floor (bins1 * ((f1 + M_PI) * (1.0f / (2.0f * M_PI)))); + //Using floorf due to changes to MSVC 16.9. See details here: https://devtalk.blender.org/t/cuda-compile-error-windows-10/17886/4 + //floorf is without std:: see why here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700 + h_index = floorf (bins1 * ((f1 + M_PI) * (1.0f / (2.0f * M_PI)))); h_index = min(bins1 - 1, max(0, h_index)); atomicAdd(shist_b1 + h_index, hist_incr); - h_index = std::floor (bins2 * ((f2 + 1.0f) * 0.5f)); + h_index = floorf (bins2 * ((f2 + 1.0f) * 0.5f)); h_index = min(bins2 - 1, max (0, h_index)); atomicAdd(shist_b2 + h_index, hist_incr); - h_index = std::floor (bins3 * ((f3 + 1.0f) * 0.5f)); + h_index = floorf (bins3 * ((f3 + 1.0f) * 0.5f)); h_index = min(bins3 - 1, max (0, h_index)); atomicAdd(shist_b3 + h_index, hist_incr); diff --git a/gpu/features/src/pfh.cu b/gpu/features/src/pfh.cu index 2b4bbc83cdc..b5a508b3bcb 100644 --- a/gpu/features/src/pfh.cu +++ b/gpu/features/src/pfh.cu @@ -197,13 +197,15 @@ namespace pcl //if (computePairFeatures (pi, ni, pj, nj, f1, f2, f3, f4)) { // Normalize the f1, f2, f3 features and push them in the histogram - int find0 = std::floor( NR_SPLIT * ((f1 + PI) * (1.f / (2.f * PI))) ); + //Using floorf due to changes to MSVC 16.9. See details here: https://devtalk.blender.org/t/cuda-compile-error-windows-10/17886/4 + //floorf is without std:: see why here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700 + int find0 = floorf( NR_SPLIT * ((f1 + PI) * (1.f / (2.f * PI))) ); find0 = min(NR_SPLIT - 1, max(0, find0)); - int find1 = std::floor( NR_SPLIT * ( (f2 + 1.f) * 0.5f ) ); + int find1 = floorf( NR_SPLIT * ( (f2 + 1.f) * 0.5f ) ); find1 = min(NR_SPLIT - 1, max(0, find1)); - int find2 = std::floor( NR_SPLIT * ( (f3 + 1.f) * 0.5f ) ); + int find2 = floorf( NR_SPLIT * ( (f3 + 1.f) * 0.5f ) ); find2 = min(NR_SPLIT - 1, max(0, find2)); int h_index = find0 + NR_SPLIT * find1 + NR_SPLIT_2 * find2; @@ -218,13 +220,13 @@ namespace pcl computeRGBPairFeatures_RGBOnly(ci, cj, f5, f6, f7); // color ratios are in [-1, 1] - int find4 = std::floor (NR_SPLIT * ((f5 + 1.f) * 0.5f)); + int find4 = floorf(NR_SPLIT * ((f5 + 1.f) * 0.5f)); find4 = min(NR_SPLIT - 1, max(0, find4)); - int find5 = std::floor (NR_SPLIT * ((f6 + 1.f) * 0.5f)); + int find5 = floorf(NR_SPLIT * ((f6 + 1.f) * 0.5f)); find5 = min(NR_SPLIT - 1, max(0, find5)); - int find6 = std::floor (NR_SPLIT * ((f7 + 1.f) * 0.5f)); + int find6 = floorf(NR_SPLIT * ((f7 + 1.f) * 0.5f)); find6 = min(NR_SPLIT - 1, max(0, find6)); // and the colors diff --git a/gpu/features/src/spinimages.cu b/gpu/features/src/spinimages.cu index 4b9f587d951..c763ae3b27a 100644 --- a/gpu/features/src/spinimages.cu +++ b/gpu/features/src/spinimages.cu @@ -197,8 +197,10 @@ namespace pcl // bilinear interpolation float beta_bin_size = radial ? (PI*0.5f/image_width) : bin_size; - int beta_bin = std::floor(beta / beta_bin_size) + image_width; - int alpha_bin = std::floor(alpha / bin_size); + //Using floorf due to changes to MSVC 16.9. See details here: https://devtalk.blender.org/t/cuda-compile-error-windows-10/17886/4 + //floorf is without std:: see why here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700 + int beta_bin = floorf(beta / beta_bin_size) + image_width; + int alpha_bin = floorf(alpha / bin_size); //alpha_bin = min(simage_cols, max(0, alpha_bin)); //beta_bin = min(simage_rows, max(0, beta_bin)); diff --git a/gpu/features/src/vfh.cu b/gpu/features/src/vfh.cu index c221ccf088a..2a577157266 100644 --- a/gpu/features/src/vfh.cu +++ b/gpu/features/src/vfh.cu @@ -136,20 +136,22 @@ namespace pcl if (computePairFeatures(centroid_p, centroid_n, p, n, f1, f2, f3, f4)) { // Normalize the f1, f2, f3, f4 features and push them in the histogram - h_index = std::floor (bins1 * ((f1 + M_PI) * (1.f / (2.f * M_PI)))); + //Using floorf due to changes to MSVC 16.9. See details here: https://devtalk.blender.org/t/cuda-compile-error-windows-10/17886/4 + //floorf is without std:: see why here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79700 + h_index = floorf (bins1 * ((f1 + M_PI) * (1.f / (2.f * M_PI)))); h_index = min(bins1 - 1, max(0, h_index)); atomicAdd(shist_b1 + h_index, hist_incr); - h_index = std::floor (bins2 * ((f2 + 1.f) * 0.5f)); + h_index = floorf (bins2 * ((f2 + 1.f) * 0.5f)); h_index = min(bins2 - 1, max (0, h_index)); atomicAdd(shist_b2 + h_index, hist_incr); - h_index = std::floor (bins3 * ((f3 + 1.f) * 0.5f)); + h_index = floorf (bins3 * ((f3 + 1.f) * 0.5f)); h_index = min(bins3 - 1, max (0, h_index)); atomicAdd(shist_b3 + h_index, hist_incr); if (normalize_distances) - h_index = std::floor (bins4 * (f4 * distance_normalization_factor_inv)); + h_index = floorf (bins4 * (f4 * distance_normalization_factor_inv)); else h_index = __float2int_rn (f4 * 100); @@ -159,7 +161,7 @@ namespace pcl // viewpoint component float alfa = ((dot(n, d_vp_p) + 1.f) * 0.5f); - h_index = std::floor (bins_vp * alfa); + h_index = floorf (bins_vp * alfa); h_index = min(bins_vp - 1, max (0, h_index)); atomicAdd(shist_vp + h_index, hist_incr_vp); From 93653fa50556e6bb64ae78dd5fe65ea2a77c72ef Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 20 Apr 2021 07:41:00 +0530 Subject: [PATCH 112/431] Hotfix for the new doc CI --- .ci/azure-pipelines/docs-pipeline.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/azure-pipelines/docs-pipeline.yaml b/.ci/azure-pipelines/docs-pipeline.yaml index bde0ec8bfda..e9c787cb0af 100644 --- a/.ci/azure-pipelines/docs-pipeline.yaml +++ b/.ci/azure-pipelines/docs-pipeline.yaml @@ -29,7 +29,7 @@ stages: # if docs pipeline triggered by build_gcc stage, # the formatting stage has already run, thus it # won't run for a second time here. - condition: ne(variables['Build.Reason'], 'ResourceTrigger')) + condition: ne(variables['Build.Reason'], 'ResourceTrigger') jobs: - template: formatting.yaml From 446f2d5c1fd34672a22330df0e0bbec24a5bba63 Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Tue, 20 Apr 2021 08:27:33 +0530 Subject: [PATCH 113/431] Add separate badge for docs pipeline --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index eb0109ab4c6..36a1b0d1d85 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,15 @@ Continuous integration [ci-windows-x64]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20MSVC&jobName=Windows%20VS2017%20Build&configuration=Windows%20VS2017%20Build%20x64&label=Windows%20VS2017%20x64 [ci-macos-10.14]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20Clang&jobName=macOS&configuration=macOS%20Mojave%2010.14&label=macOS%20Mojave%2010.14 [ci-macos-10.15]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/9?branchName=master&stageName=Build%20Clang&jobName=macOS&configuration=macOS%20Catalina%2010.15&label=macOS%20Catalina%2010.15 +[ci-docs]: https://dev.azure.com/PointCloudLibrary/pcl/_apis/build/status/Documentation?branchName=master +[ci-latest-docs]: https://dev.azure.com/PointCloudLibrary/pcl/_build/latest?definitionId=14&branchName=master Build Platform | Status ------------------------ | ------------------------------------------------------------------------------------------------- | Ubuntu | [![Status][ci-ubuntu-18.04]][ci-latest-build]
[![Status][ci-ubuntu-20.04]][ci-latest-build]
[![Status][ci-ubuntu-20.10]][ci-latest-build] | Windows | [![Status][ci-windows-x86]][ci-latest-build]
[![Status][ci-windows-x64]][ci-latest-build] | macOS | [![Status][ci-macos-10.14]][ci-latest-build]
[![Status][ci-macos-10.15]][ci-latest-build] | +Documentation | [![Status][ci-docs]][ci-latest-docs] | Community --------- From f79847e4eba3357c91786fb039246ef325e8a0c0 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 14:24:49 +0200 Subject: [PATCH 114/431] Fix unused-value warnings in tutorials - the options are mandatory, so return with error message if not found - it is not necessary to keep the line count in these cpp files, so formatting can be done freely --- .../iccv2011/src/build_all_object_models.cpp | 24 +++++++++++++++---- .../iccv2011/src/build_object_model.cpp | 24 +++++++++++++++---- .../iccv2011/src/test_object_recognition.cpp | 24 +++++++++++++++---- .../iros2011/src/build_all_object_models.cpp | 24 +++++++++++++++---- .../iros2011/src/build_object_model.cpp | 24 +++++++++++++++---- .../iros2011/src/test_object_recognition.cpp | 24 +++++++++++++++---- 6 files changed, 120 insertions(+), 24 deletions(-) diff --git a/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp b/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp index e660b2cb10a..53ce73c889d 100644 --- a/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp @@ -90,7 +90,11 @@ main (int argc, char ** argv) //Parse filter parameters std::string filter_parameters_file; - pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --filter\n"); + return (1); + } params_stream.open (filter_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -109,7 +113,11 @@ main (int argc, char ** argv) // Parse segmentation parameters std::string segmentation_parameters_file; - pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --segment\n"); + return (1); + } params_stream.open (segmentation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -129,7 +137,11 @@ main (int argc, char ** argv) // Parse feature estimation parameters std::string feature_estimation_parameters_file; - pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --feature\n"); + return (1); + } params_stream.open (feature_estimation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -150,7 +162,11 @@ main (int argc, char ** argv) // Parse the registration parameters std::string registration_parameters_file; - pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --registration\n"); + return (1); + } params_stream.open (registration_parameters_file.c_str ()); if (params_stream.is_open()) { diff --git a/doc/tutorials/content/sources/iccv2011/src/build_object_model.cpp b/doc/tutorials/content/sources/iccv2011/src/build_object_model.cpp index ea946530980..deaf2760d65 100644 --- a/doc/tutorials/content/sources/iccv2011/src/build_object_model.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/build_object_model.cpp @@ -66,7 +66,11 @@ main (int argc, char ** argv) //Parse filter parameters std::string filter_parameters_file; - pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --filter\n"); + return (1); + } params_stream.open (filter_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -85,7 +89,11 @@ main (int argc, char ** argv) // Parse segmentation parameters std::string segmentation_parameters_file; - pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --segment\n"); + return (1); + } params_stream.open (segmentation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -105,7 +113,11 @@ main (int argc, char ** argv) // Parse feature estimation parameters std::string feature_estimation_parameters_file; - pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --feature\n"); + return (1); + } params_stream.open (feature_estimation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -126,7 +138,11 @@ main (int argc, char ** argv) // Parse the registration parameters std::string registration_parameters_file; - pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --registration\n"); + return (1); + } params_stream.open (registration_parameters_file.c_str ()); if (params_stream.is_open()) { diff --git a/doc/tutorials/content/sources/iccv2011/src/test_object_recognition.cpp b/doc/tutorials/content/sources/iccv2011/src/test_object_recognition.cpp index d9ebb473dd5..bd363d2b5e0 100644 --- a/doc/tutorials/content/sources/iccv2011/src/test_object_recognition.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/test_object_recognition.cpp @@ -86,7 +86,11 @@ main (int argc, char ** argv) //Parse filter parameters std::string filter_parameters_file; - pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --filter\n"); + return (1); + } input_stream.open (filter_parameters_file.c_str ()); if (input_stream.is_open()) { @@ -105,7 +109,11 @@ main (int argc, char ** argv) // Parse segmentation parameters std::string segmentation_parameters_file; - pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --segment\n"); + return (1); + } input_stream.open (segmentation_parameters_file.c_str ()); if (input_stream.is_open()) { @@ -125,7 +133,11 @@ main (int argc, char ** argv) // Parse feature estimation parameters std::string feature_estimation_parameters_file; - pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --feature\n"); + return (1); + } input_stream.open (feature_estimation_parameters_file.c_str ()); if (input_stream.is_open()) { @@ -146,7 +158,11 @@ main (int argc, char ** argv) // Parse the registration parameters std::string registration_parameters_file; - pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --registration\n"); + return (1); + } input_stream.open (registration_parameters_file.c_str ()); if (input_stream.is_open()) { diff --git a/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp b/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp index cb77cdf8f48..094c9e220da 100644 --- a/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp +++ b/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp @@ -90,7 +90,11 @@ main (int argc, char ** argv) //Parse filter parameters std::string filter_parameters_file; - pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --filter\n"); + return (1); + } params_stream.open (filter_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -109,7 +113,11 @@ main (int argc, char ** argv) // Parse segmentation parameters std::string segmentation_parameters_file; - pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --segment\n"); + return (1); + } params_stream.open (segmentation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -129,7 +137,11 @@ main (int argc, char ** argv) // Parse feature estimation parameters std::string feature_estimation_parameters_file; - pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --feature\n"); + return (1); + } params_stream.open (feature_estimation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -150,7 +162,11 @@ main (int argc, char ** argv) // Parse the registration parameters std::string registration_parameters_file; - pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --registration\n"); + return (1); + } params_stream.open (registration_parameters_file.c_str ()); if (params_stream.is_open()) { diff --git a/doc/tutorials/content/sources/iros2011/src/build_object_model.cpp b/doc/tutorials/content/sources/iros2011/src/build_object_model.cpp index ea946530980..deaf2760d65 100644 --- a/doc/tutorials/content/sources/iros2011/src/build_object_model.cpp +++ b/doc/tutorials/content/sources/iros2011/src/build_object_model.cpp @@ -66,7 +66,11 @@ main (int argc, char ** argv) //Parse filter parameters std::string filter_parameters_file; - pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --filter\n"); + return (1); + } params_stream.open (filter_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -85,7 +89,11 @@ main (int argc, char ** argv) // Parse segmentation parameters std::string segmentation_parameters_file; - pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --segment\n"); + return (1); + } params_stream.open (segmentation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -105,7 +113,11 @@ main (int argc, char ** argv) // Parse feature estimation parameters std::string feature_estimation_parameters_file; - pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --feature\n"); + return (1); + } params_stream.open (feature_estimation_parameters_file.c_str ()); if (params_stream.is_open()) { @@ -126,7 +138,11 @@ main (int argc, char ** argv) // Parse the registration parameters std::string registration_parameters_file; - pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --registration\n"); + return (1); + } params_stream.open (registration_parameters_file.c_str ()); if (params_stream.is_open()) { diff --git a/doc/tutorials/content/sources/iros2011/src/test_object_recognition.cpp b/doc/tutorials/content/sources/iros2011/src/test_object_recognition.cpp index 251463d58cb..79f24a2cd8b 100644 --- a/doc/tutorials/content/sources/iros2011/src/test_object_recognition.cpp +++ b/doc/tutorials/content/sources/iros2011/src/test_object_recognition.cpp @@ -86,7 +86,11 @@ main (int argc, char ** argv) //Parse filter parameters std::string filter_parameters_file; - pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--filter", filter_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --filter\n"); + return (1); + } input_stream.open (filter_parameters_file.c_str ()); if (input_stream.is_open()) { @@ -105,7 +109,11 @@ main (int argc, char ** argv) // Parse segmentation parameters std::string segmentation_parameters_file; - pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--segment", segmentation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --segment\n"); + return (1); + } input_stream.open (segmentation_parameters_file.c_str ()); if (input_stream.is_open()) { @@ -125,7 +133,11 @@ main (int argc, char ** argv) // Parse feature estimation parameters std::string feature_estimation_parameters_file; - pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--feature", feature_estimation_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --feature\n"); + return (1); + } input_stream.open (feature_estimation_parameters_file.c_str ()); if (input_stream.is_open()) { @@ -146,7 +158,11 @@ main (int argc, char ** argv) // Parse the registration parameters std::string registration_parameters_file; - pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) > 0; + if (pcl::console::parse_argument (argc, argv, "--registration", registration_parameters_file) < 0) + { + pcl::console::print_error ("Missing option --registration\n"); + return (1); + } input_stream.open (registration_parameters_file.c_str ()); if (input_stream.is_open()) { From 66a4530f18475d68a72fa8ca97806257021a9530 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 14:46:59 +0200 Subject: [PATCH 115/431] Fix unused-variable warnings in tutorials --- .../narf_descriptor_visualization.cpp | 4 ++-- .../openni_narf_keypoint_extraction.cpp | 2 +- .../openni_range_image_visualization.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp b/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp index 87ca778d0bb..3df0b1d359f 100644 --- a/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp +++ b/doc/tutorials/content/sources/narf_descriptor_visualization/narf_descriptor_visualization.cpp @@ -188,7 +188,7 @@ main (int argc, char** argv) float surface_patch_world_size = narf.getSurfacePatchWorldSize (); surface_patch_widget.showFloatImage (narf.getSurfacePatch (), surface_patch_pixel_size, surface_patch_pixel_size, -0.5f*surface_patch_world_size, 0.5f*surface_patch_world_size, true); - float surface_patch_rotation = narf.getSurfacePatchRotation (); + /*float surface_patch_rotation = narf.getSurfacePatchRotation (); float patch_middle = 0.5f* (float (surface_patch_pixel_size-1)); float angle_step_size = pcl::deg2rad (360.0f)/narf.getDescriptorSize (); float cell_size = surface_patch_world_size/float (surface_patch_pixel_size), @@ -208,7 +208,7 @@ main (int argc, char** argv) { //surface_patch_widget.markLine (radius-0.5, radius-0.5, radius-0.5f + 2.0f*radius*sinf (rotations[i]), //radius-0.5f - 2.0f*radius*std::cos (rotations[i]), pcl::visualization::Vector3ub (255,0,0)); - } + }*/ descriptor_widget.showFloatImage (narf.getDescriptor (), narf.getDescriptorSize (), 1, -0.1f, 0.3f, true); diff --git a/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp b/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp index 4ab9cd179e7..6f0dd70d955 100644 --- a/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp +++ b/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp @@ -156,7 +156,7 @@ int main (int argc, char** argv) int width = depth_image_ptr->getWidth (), height = depth_image_ptr->getHeight (); float center_x = width/2, center_y = height/2; float focal_length_x = depth_image_ptr->getFocalLength (), focal_length_y = focal_length_x; - float original_angular_resolution = asinf (0.5f*float (width)/float (focal_length_x)) / (0.5f*float (width)); + // float original_angular_resolution = asinf (0.5f*float (width)/float (focal_length_x)) / (0.5f*float (width)); float desired_angular_resolution = angular_resolution; range_image_planar.setDepthImage (depth_map, width, height, center_x, center_y, focal_length_x, focal_length_y, desired_angular_resolution); diff --git a/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp b/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp index 038512853e9..a7cdbdb9da7 100644 --- a/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp +++ b/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp @@ -121,7 +121,7 @@ int main (int argc, char** argv) int width = depth_image_ptr->getWidth (), height = depth_image_ptr->getHeight (); float center_x = width/2, center_y = height/2; float focal_length_x = depth_image_ptr->getFocalLength (), focal_length_y = focal_length_x; - float original_angular_resolution = asinf (0.5f*float (width)/float (focal_length_x)) / (0.5f*float (width)); + // float original_angular_resolution = asinf (0.5f*float (width)/float (focal_length_x)) / (0.5f*float (width)); float desired_angular_resolution = angular_resolution; range_image_planar.setDepthImage (depth_map, width, height, center_x, center_y, focal_length_x, focal_length_y, desired_angular_resolution); From 5c2b975efa190823840391beb07f1416b84651dc Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 16:08:14 +0200 Subject: [PATCH 116/431] Fix reorder warnings in tutorials --- doc/tutorials/content/sources/iccv2011/src/openni_capture.cpp | 2 +- doc/tutorials/content/sources/iros2011/src/openni_capture.cpp | 4 ++-- doc/tutorials/content/sources/qt_colorize_cloud/pclviewer.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/tutorials/content/sources/iccv2011/src/openni_capture.cpp b/doc/tutorials/content/sources/iccv2011/src/openni_capture.cpp index 1f1c507343d..7266fde4e36 100644 --- a/doc/tutorials/content/sources/iccv2011/src/openni_capture.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/openni_capture.cpp @@ -7,8 +7,8 @@ OpenNICapture::OpenNICapture (const std::string& device_id) : grabber_ (device_id) - , most_recent_frame_ () , frame_counter_ (0) + , most_recent_frame_ () , use_trigger_ (false) , trigger_ (false) { diff --git a/doc/tutorials/content/sources/iros2011/src/openni_capture.cpp b/doc/tutorials/content/sources/iros2011/src/openni_capture.cpp index 29ae70d5649..36c623c97c4 100644 --- a/doc/tutorials/content/sources/iros2011/src/openni_capture.cpp +++ b/doc/tutorials/content/sources/iros2011/src/openni_capture.cpp @@ -7,11 +7,11 @@ OpenNICapture::OpenNICapture (const std::string& device_id) : grabber_ (device_id) - , most_recent_frame_ () + , preview_ () , frame_counter_ (0) + , most_recent_frame_ () , use_trigger_ (false) , trigger_ (false) - , preview_ () { // Register a callback function to our OpenNI grabber... std::function frame_cb = [this] (const PointCloudConstPtr& cloud) { onNewFrame (cloud); }; diff --git a/doc/tutorials/content/sources/qt_colorize_cloud/pclviewer.cpp b/doc/tutorials/content/sources/qt_colorize_cloud/pclviewer.cpp index 9132ec5ceff..2a22446b645 100644 --- a/doc/tutorials/content/sources/qt_colorize_cloud/pclviewer.cpp +++ b/doc/tutorials/content/sources/qt_colorize_cloud/pclviewer.cpp @@ -3,9 +3,9 @@ PCLViewer::PCLViewer (QWidget *parent) : QMainWindow (parent), - ui (new Ui::PCLViewer), filtering_axis_ (1), // = y - color_mode_ (4) // = Rainbow + color_mode_ (4), // = Rainbow + ui (new Ui::PCLViewer) { ui->setupUi (this); this->setWindowTitle ("PCL viewer"); From 09bc4f040f7b406caccb08706142b414d8b3c5af Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sat, 10 Apr 2021 17:06:08 +0200 Subject: [PATCH 117/431] Fix unused-parameter warnings in tutorials --- .../conditional_euclidean_clustering.cpp | 4 ++-- .../sources/iccv2011/include/feature_estimation.h | 2 +- .../content/sources/iccv2011/src/tutorial.cpp | 2 +- .../sources/interactive_icp/interactive_icp.cpp | 2 +- .../sources/iros2011/include/object_recognition.h | 6 +++--- .../iros2011/include/solution/feature_estimation.h | 2 +- .../content/sources/iros2011/include/surface.h | 14 +++++++------- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp b/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp index ee1a827e1c6..eb4eb13e59c 100644 --- a/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp +++ b/doc/tutorials/content/sources/conditional_euclidean_clustering/conditional_euclidean_clustering.cpp @@ -10,7 +10,7 @@ typedef pcl::PointXYZI PointTypeIO; typedef pcl::PointXYZINormal PointTypeFull; bool -enforceIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& point_b, float squared_distance) +enforceIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& point_b, float /*squared_distance*/) { if (std::abs (point_a.intensity - point_b.intensity) < 5.0f) return (true); @@ -19,7 +19,7 @@ enforceIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& p } bool -enforceNormalOrIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& point_b, float squared_distance) +enforceNormalOrIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& point_b, float /*squared_distance*/) { Eigen::Map point_a_normal = point_a.getNormalVector3fMap (), point_b_normal = point_b.getNormalVector3fMap (); if (std::abs (point_a.intensity - point_b.intensity) < 5.0f) diff --git a/doc/tutorials/content/sources/iccv2011/include/feature_estimation.h b/doc/tutorials/content/sources/iccv2011/include/feature_estimation.h index 04b9ed3ea62..92d7d84c23f 100644 --- a/doc/tutorials/content/sources/iccv2011/include/feature_estimation.h +++ b/doc/tutorials/content/sources/iccv2011/include/feature_estimation.h @@ -46,7 +46,7 @@ estimateSurfaceNormals (const PointCloudPtr & input, float radius) * Return: A pointer to a point cloud of keypoints */ PointCloudPtr -detectKeypoints (const PointCloudPtr & points, const SurfaceNormalsPtr & normals, +detectKeypoints (const PointCloudPtr & points, const SurfaceNormalsPtr & /*normals*/, float min_scale, int nr_octaves, int nr_scales_per_octave, float min_contrast) { pcl::SIFTKeypoint sift_detect; diff --git a/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp b/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp index 616e8d440bb..f5f8a7744a3 100644 --- a/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/tutorial.cpp @@ -398,7 +398,7 @@ void ICCVTutorial::run() } template -void ICCVTutorial::keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie) +void ICCVTutorial::keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* /*cookie*/) { if (event.keyUp()) { diff --git a/doc/tutorials/content/sources/interactive_icp/interactive_icp.cpp b/doc/tutorials/content/sources/interactive_icp/interactive_icp.cpp index d0351ae012a..dfb6cbfbc85 100644 --- a/doc/tutorials/content/sources/interactive_icp/interactive_icp.cpp +++ b/doc/tutorials/content/sources/interactive_icp/interactive_icp.cpp @@ -25,7 +25,7 @@ print4x4Matrix (const Eigen::Matrix4d & matrix) void keyboardEventOccurred (const pcl::visualization::KeyboardEvent& event, - void* nothing) + void*) { if (event.getKeySym () == "space" && event.keyDown ()) next_iteration = true; diff --git a/doc/tutorials/content/sources/iros2011/include/object_recognition.h b/doc/tutorials/content/sources/iros2011/include/object_recognition.h index e403efc55f1..ed9080c2ecc 100644 --- a/doc/tutorials/content/sources/iros2011/include/object_recognition.h +++ b/doc/tutorials/content/sources/iros2011/include/object_recognition.h @@ -59,19 +59,19 @@ class ObjectRecognition {} void - populateDatabase (const std::vector & filenames) + populateDatabase (const std::vector & /*filenames*/) { } const ObjectModel & - recognizeObject (const PointCloudPtr & query_cloud) + recognizeObject (const PointCloudPtr & /*query_cloud*/) { int best_match = 0; return (models_[best_match]); } PointCloudPtr - recognizeAndAlignPoints (const PointCloudPtr & query_cloud) + recognizeAndAlignPoints (const PointCloudPtr & /*query_cloud*/) { PointCloudPtr output; return (output); diff --git a/doc/tutorials/content/sources/iros2011/include/solution/feature_estimation.h b/doc/tutorials/content/sources/iros2011/include/solution/feature_estimation.h index 96d11d30aa4..6249aaa20da 100644 --- a/doc/tutorials/content/sources/iros2011/include/solution/feature_estimation.h +++ b/doc/tutorials/content/sources/iros2011/include/solution/feature_estimation.h @@ -47,7 +47,7 @@ estimateSurfaceNormals (const PointCloudPtr & input, float radius) * Return: A pointer to a point cloud of keypoints */ PointCloudPtr -detectKeypoints (const PointCloudPtr & points, const SurfaceNormalsPtr & normals, +detectKeypoints (const PointCloudPtr & points, const SurfaceNormalsPtr & /*normals*/, float min_scale, int nr_octaves, int nr_scales_per_octave, float min_contrast) { pcl::SIFTKeypoint sift_detect; diff --git a/doc/tutorials/content/sources/iros2011/include/surface.h b/doc/tutorials/content/sources/iros2011/include/surface.h index 7749faedd34..189d3d80d72 100644 --- a/doc/tutorials/content/sources/iros2011/include/surface.h +++ b/doc/tutorials/content/sources/iros2011/include/surface.h @@ -21,21 +21,21 @@ class Mesh using MeshPtr = std::shared_ptr; PointCloudPtr -smoothPointCloud (const PointCloudPtr & input, float radius, int polynomial_order) +smoothPointCloud (const PointCloudPtr & /*input*/, float /*radius*/, int /*polynomial_order*/) { PointCloudPtr output (new PointCloud); return (output); } SurfaceElementsPtr -computeSurfaceElements (const PointCloudPtr & input, float radius, int polynomial_order) +computeSurfaceElements (const PointCloudPtr & /*input*/, float /*radius*/, int /*polynomial_order*/) { SurfaceElementsPtr surfels (new SurfaceElements); return (surfels); } MeshPtr -computeConvexHull (const PointCloudPtr & input) +computeConvexHull (const PointCloudPtr & /*input*/) { MeshPtr output (new Mesh); return (output); @@ -43,15 +43,15 @@ computeConvexHull (const PointCloudPtr & input) MeshPtr -computeConcaveHull (const PointCloudPtr & input, float alpha) +computeConcaveHull (const PointCloudPtr & /*input*/, float /*alpha*/) { MeshPtr output (new Mesh); return (output); } pcl::PolygonMesh::Ptr -greedyTriangulation (const SurfaceElementsPtr & surfels, float radius, float mu, int max_nearest_neighbors, - float max_surface_angle, float min_angle, float max_angle) +greedyTriangulation (const SurfaceElementsPtr & /*surfels*/, float /*radius*/, float /*mu*/, int /*max_nearest_neighbors*/, + float /*max_surface_angle*/, float /*min_angle*/, float /*max_angle*/) { pcl::PolygonMesh::Ptr output (new pcl::PolygonMesh); @@ -60,7 +60,7 @@ greedyTriangulation (const SurfaceElementsPtr & surfels, float radius, float mu, pcl::PolygonMesh::Ptr -marchingCubesTriangulation (const SurfaceElementsPtr & surfels, float leaf_size, float iso_level) +marchingCubesTriangulation (const SurfaceElementsPtr & /*surfels*/, float /*leaf_size*/, float /*iso_level*/) { pcl::PolygonMesh::Ptr output (new pcl::PolygonMesh); return (output); From f67053e94ec2654a564c9a691d6e31c47b7108f3 Mon Sep 17 00:00:00 2001 From: Markus Vieth <39675748+mvieth@users.noreply.github.com> Date: Wed, 21 Apr 2021 13:39:48 +0200 Subject: [PATCH 118/431] Suppress cmake warnings for pcl modules (#4431) * Suppress cmake warnings for mismatched names --- PCLConfig.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in index 2ce6bc811cf..283a1a75b2a 100644 --- a/PCLConfig.cmake.in +++ b/PCLConfig.cmake.in @@ -519,6 +519,7 @@ foreach(component ${PCL_TO_FIND_COMPONENTS}) #pcl_message("No include directory found for pcl_${component}.") endif() + set(FPHSA_NAME_MISMATCHED 1) # Suppress warnings, see https://cmake.org/cmake/help/v3.17/module/FindPackageHandleStandardArgs.html # Skip find_library for header only modules list(FIND pcl_header_only_components ${component} _is_header_only) if(_is_header_only EQUAL -1) @@ -555,6 +556,7 @@ foreach(component ${PCL_TO_FIND_COMPONENTS}) find_package_handle_standard_args(PCL_${COMPONENT} DEFAULT_MSG PCL_${COMPONENT}_INCLUDE_DIR) endif() + unset(FPHSA_NAME_MISMATCHED) if(PCL_${COMPONENT}_FOUND) if(NOT "${PCL_${COMPONENT}_INCLUDE_DIRS}" STREQUAL "") From 4f76fd2527bc88b276175cc017744b0b92166a93 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Mon, 19 Apr 2021 12:52:05 +0200 Subject: [PATCH 119/431] Fix PFM --- common/include/pcl/common/point_tests.h | 12 +++++++++++- .../registration/impl/pyramid_feature_matching.hpp | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/common/include/pcl/common/point_tests.h b/common/include/pcl/common/point_tests.h index abd58c3508a..dc11edef481 100644 --- a/common/include/pcl/common/point_tests.h +++ b/common/include/pcl/common/point_tests.h @@ -69,8 +69,13 @@ namespace pcl template<> inline bool isFinite(const pcl::BRISKSignature512&) { return (true); } template<> inline bool isFinite(const pcl::BorderDescription &) { return true; } template<> inline bool isFinite(const pcl::Boundary&) { return (true); } + template<> inline bool isFinite(const pcl::CPPFSignature&) { return (true); } template<> inline bool isFinite(const pcl::ESFSignature640&) { return (true); } template<> inline bool isFinite(const pcl::FPFHSignature33&) { return (true); } + template<> inline bool isFinite(const pcl::GASDSignature512&) { return (true); } + template<> inline bool isFinite(const pcl::GASDSignature984&) { return (true); } + template<> inline bool isFinite(const pcl::GASDSignature7992&) { return (true); } + template<> inline bool isFinite(const pcl::GRSDSignature21&) { return (true); } template<> inline bool isFinite(const pcl::Intensity&) { return (true); } template<> inline bool isFinite(const pcl::IntensityGradient&) { return (true); } template<> inline bool isFinite(const pcl::Label&) { return (true); } @@ -79,7 +84,12 @@ namespace pcl template<> inline bool isFinite(const pcl::PFHRGBSignature250&) { return (true); } template<> inline bool isFinite(const pcl::PFHSignature125&) { return (true); } template<> inline bool isFinite(const pcl::PPFRGBSignature&) { return (true); } - template<> inline bool isFinite(const pcl::PPFSignature&) { return (true); } + + template<> inline bool isFinite(const pcl::PPFSignature& pt) + { + return std::isfinite(pt.f1) && std::isfinite(pt.f2) && std::isfinite(pt.f3) && std::isfinite(pt.f4) && std::isfinite(pt.alpha_m); + } + template<> inline bool isFinite(const pcl::PrincipalCurvatures&) { return (true); } template<> inline bool isFinite(const pcl::PrincipalRadiiRSD&) { return (true); } template<> inline bool isFinite(const pcl::RGB&) { return (true); } diff --git a/registration/include/pcl/registration/impl/pyramid_feature_matching.hpp b/registration/include/pcl/registration/impl/pyramid_feature_matching.hpp index 7e0cf749311..ad5f4a725ed 100644 --- a/registration/include/pcl/registration/impl/pyramid_feature_matching.hpp +++ b/registration/include/pcl/registration/impl/pyramid_feature_matching.hpp @@ -42,6 +42,7 @@ #ifndef PCL_REGISTRATION_IMPL_PYRAMID_FEATURE_MATCHING_H_ #define PCL_REGISTRATION_IMPL_PYRAMID_FEATURE_MATCHING_H_ +#include // for pcl::isFinite #include #include @@ -309,6 +310,9 @@ PyramidFeatureHistogram::compute() for (const auto& point : *input_) { std::vector feature_vector; + // NaN is converted to very high number that gives out of bound exception. + if (!pcl::isFinite(point)) + continue; convertFeatureToVector(point, feature_vector); addFeature(feature_vector); } From a99a594dc035a5adb4d0e3dbc2798727460df097 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Wed, 21 Apr 2021 13:07:45 +0200 Subject: [PATCH 120/431] Update values for test to pass. --- test/registration/test_registration.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/registration/test_registration.cpp b/test/registration/test_registration.cpp index 045fb2eebce..2c33e690cd6 100644 --- a/test/registration/test_registration.cpp +++ b/test/registration/test_registration.cpp @@ -694,7 +694,7 @@ TEST (PCL, PyramidFeatureHistogram) pyramid_target->compute (); float similarity_value = PyramidFeatureHistogram::comparePyramidFeatureHistograms (pyramid_source, pyramid_target); - EXPECT_NEAR (similarity_value, 0.74101555347442627, 1e-4); + EXPECT_NEAR (similarity_value, 0.738492727, 1e-4); std::vector > dim_range_target2; for (std::size_t i = 0; i < 3; ++i) dim_range_target2.emplace_back(static_cast (-M_PI) * 5.0f, static_cast (M_PI) * 5.0f); @@ -707,7 +707,7 @@ TEST (PCL, PyramidFeatureHistogram) pyramid_target->compute (); float similarity_value2 = PyramidFeatureHistogram::comparePyramidFeatureHistograms (pyramid_source, pyramid_target); - EXPECT_NEAR (similarity_value2, 0.80097091197967529, 1e-4); + EXPECT_NEAR (similarity_value2, 0.798465133, 1e-4); std::vector > dim_range_target3; @@ -721,7 +721,7 @@ TEST (PCL, PyramidFeatureHistogram) pyramid_target->compute (); float similarity_value3 = PyramidFeatureHistogram::comparePyramidFeatureHistograms (pyramid_source, pyramid_target); - EXPECT_NEAR (similarity_value3, 0.87623238563537598, 1e-3); + EXPECT_NEAR (similarity_value3, 0.873699546, 1e-3); } // Suat G: disabled, since the transformation does not look correct. From 4dce6354516538d400b499855b80e32ea1140d8f Mon Sep 17 00:00:00 2001 From: Tom Lankhorst Date: Thu, 22 Apr 2021 10:40:25 +0200 Subject: [PATCH 121/431] Pass surface_ point to isFinite This caused segfaults. Seems like the check is done on the wrong dataset. Occurs when `setSearchSurface` is set, so `input_->size()` != `surface_->size()`. --- features/include/pcl/features/impl/fpfh_omp.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/include/pcl/features/impl/fpfh_omp.hpp b/features/include/pcl/features/impl/fpfh_omp.hpp index 5e87d22a94e..a81a4b00cb3 100644 --- a/features/include/pcl/features/impl/fpfh_omp.hpp +++ b/features/include/pcl/features/impl/fpfh_omp.hpp @@ -119,7 +119,7 @@ pcl::FPFHEstimationOMP::computeFeature (PointCloud int p_idx = spfh_indices_vec[i]; // Find the neighborhood around p_idx - if (!isFinite ((*input_)[p_idx]) || + if (!isFinite ((*surface_)[p_idx]) || this->searchForNeighbors (*surface_, p_idx, search_parameter_, nn_indices, nn_dists) == 0) continue; From 88c52d0ba78063c095d5bcd469c0a5532b22c226 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Sat, 24 Apr 2021 18:45:23 +0200 Subject: [PATCH 122/431] Fix GPU Octree test --- test/gpu/octree/test_approx_nearest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/gpu/octree/test_approx_nearest.cpp b/test/gpu/octree/test_approx_nearest.cpp index 2c4f6d2f8e4..c140d770ce0 100644 --- a/test/gpu/octree/test_approx_nearest.cpp +++ b/test/gpu/octree/test_approx_nearest.cpp @@ -18,6 +18,7 @@ #include #include #include +#include // for std::array TEST(PCL_OctreeGPU, approxNearesSearch) { From a05ccf71376ea4361544b605b8a456d0add81c42 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Mon, 26 Apr 2021 10:57:17 +0200 Subject: [PATCH 123/431] Clear cloud at each view iteration. --- tools/virtual_scanner.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virtual_scanner.cpp b/tools/virtual_scanner.cpp index 89e5bbc1539..cda5149a59a 100644 --- a/tools/virtual_scanner.cpp +++ b/tools/virtual_scanner.cpp @@ -252,6 +252,9 @@ main (int argc, char** argv) int sid = -1; for (int i = 0; i < number_of_points; i++) { + // Clear cloud for next view scan + cloud.clear(); + sphere->GetPoint (i, eye); if (std::abs(eye[0]) < EPS) eye[0] = 0; if (std::abs(eye[1]) < EPS) eye[1] = 0; From a42fb1e3a59d1246776ef51d9d53dd6810c8c2d1 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Mon, 26 Apr 2021 11:05:32 +0200 Subject: [PATCH 124/431] Added scale parameter (m / mm) --- tools/virtual_scanner.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/virtual_scanner.cpp b/tools/virtual_scanner.cpp index cda5149a59a..be4d9abe326 100644 --- a/tools/virtual_scanner.cpp +++ b/tools/virtual_scanner.cpp @@ -116,6 +116,7 @@ main (int argc, char** argv) " -view_point : set the camera viewpoint from where the acquisition will take place\n" " -target_point : the target point that the camera should look at (default: 0, 0, 0)\n" " -organized <0|1> : create an organized, grid-like point cloud of width x height (1), or keep it unorganized with height = 1 (0)\n" + " -scale : scaling factor to the points XYZ (default 1(m), 1000(mm))\n" " -noise <0|1> : add gaussian noise (1) or keep the model noiseless (0)\n" " -noise_std : use X times the standard deviation\n" ""); @@ -135,6 +136,9 @@ main (int argc, char** argv) console::parse_3x_arguments (argc, argv, "-target_point", tx, ty, tz); int organized = 0; console::parse_argument (argc, argv, "-organized", organized); + double scale = 1; + console::parse_argument (argc, argv, "-scale", scale); + if (organized) PCL_INFO ("Saving an organized dataset.\n"); else @@ -357,9 +361,9 @@ main (int argc, char** argv) pcl::PointWithViewpoint pt; if (object_coordinates) { - pt.x = static_cast (x[0]); - pt.y = static_cast (x[1]); - pt.z = static_cast (x[2]); + pt.x = static_cast (x[0] * scale); + pt.y = static_cast (x[1] * scale); + pt.z = static_cast (x[2] * scale); pt.vp_x = static_cast (eye[0]); pt.vp_y = static_cast (eye[1]); pt.vp_z = static_cast (eye[2]); @@ -369,9 +373,9 @@ main (int argc, char** argv) // z axis is the viewray // y axis is up // x axis is -right (negative because z*y=-x but viewray*up=right) - pt.x = static_cast (-right[0]*x[1] + up[0]*x[2] + viewray[0]*x[0] + eye[0]); - pt.y = static_cast (-right[1]*x[1] + up[1]*x[2] + viewray[1]*x[0] + eye[1]); - pt.z = static_cast (-right[2]*x[1] + up[2]*x[2] + viewray[2]*x[0] + eye[2]); + pt.x = static_cast ((-right[0]*x[1] + up[0]*x[2] + viewray[0]*x[0] + eye[0])* scale); + pt.y = static_cast ((-right[1]*x[1] + up[1]*x[2] + viewray[1]*x[0] + eye[1]) * scale); + pt.z = static_cast ((-right[2]*x[1] + up[2]*x[2] + viewray[2]*x[0] + eye[2]) * scale); pt.vp_x = pt.vp_y = pt.vp_z = 0.0f; } cloud.push_back (pt); From 842ff6770b27d6d1645e210979816eb33f9b03dc Mon Sep 17 00:00:00 2001 From: Yan Hang Date: Tue, 27 Apr 2021 03:07:51 +0800 Subject: [PATCH 125/431] Moved `PointXYZLAB` to common point types (#4706) * moved PointXYZLAB to common point types * fixed SEGFAULT in registration test * fixed format error from CI patch * made XYZRGB2XYZLAB templated and added array header * Update common/include/pcl/point_types_conversion.h * added constraint for XYZRGB2XYZLAB template function Co-authored-by: Kunal Tyagi * added constraint for XYZRGB2XYZLAB template function * removed some redundant codes & tidied headers * fixed format error in gicp6d.cpp Co-authored-by: Kunal Tyagi --- common/include/pcl/common/colors.h | 1 + common/include/pcl/common/impl/intensity.hpp | 34 +++++++++ common/include/pcl/impl/point_types.hpp | 47 ++++++++++++ common/include/pcl/point_types.h | 5 ++ common/include/pcl/point_types_conversion.h | 53 +++++++++++++ common/src/point_types.cpp | 7 ++ .../include/pcl/registration/gicp6d.h | 32 -------- registration/src/gicp6d.cpp | 75 +++---------------- 8 files changed, 157 insertions(+), 97 deletions(-) diff --git a/common/include/pcl/common/colors.h b/common/include/pcl/common/colors.h index 50599a7a402..7c1fc883c66 100644 --- a/common/include/pcl/common/colors.h +++ b/common/include/pcl/common/colors.h @@ -41,6 +41,7 @@ #include #include // for is_floating_point +#include // for std::array especially in Clang Darwin and MSVC namespace pcl { diff --git a/common/include/pcl/common/impl/intensity.hpp b/common/include/pcl/common/impl/intensity.hpp index 526bcd94a17..687d934c40b 100644 --- a/common/include/pcl/common/impl/intensity.hpp +++ b/common/include/pcl/common/impl/intensity.hpp @@ -276,6 +276,40 @@ namespace pcl } }; + template<> + struct IntensityFieldAccessor + { + inline float + operator () (const pcl::PointXYZLAB &p) const + { + return (p.L); + } + + inline void + get (const pcl::PointXYZLAB &p, float &intensity) const + { + intensity = p.L; + } + + inline void + set (pcl::PointXYZLAB &p, float intensity) const + { + p.L = intensity; + } + + inline void + demean (pcl::PointXYZLAB& p, float value) const + { + p.L -= value; + } + + inline void + add (pcl::PointXYZLAB& p, float value) const + { + p.L += value; + } + }; + template<> struct IntensityFieldAccessor { diff --git a/common/include/pcl/impl/point_types.hpp b/common/include/pcl/impl/point_types.hpp index 7b57a62ed5f..021f63cab4e 100644 --- a/common/include/pcl/impl/point_types.hpp +++ b/common/include/pcl/impl/point_types.hpp @@ -68,6 +68,7 @@ (pcl::PointXYZRGBA) \ (pcl::PointXYZRGB) \ (pcl::PointXYZRGBL) \ + (pcl::PointXYZLAB) \ (pcl::PointXYZHSV) \ (pcl::PointXY) \ (pcl::InterestPoint) \ @@ -125,6 +126,7 @@ (pcl::PointXYZRGBA) \ (pcl::PointXYZRGB) \ (pcl::PointXYZRGBL) \ + (pcl::PointXYZLAB) \ (pcl::PointXYZHSV) \ (pcl::InterestPoint) \ (pcl::PointNormal) \ @@ -690,6 +692,41 @@ namespace pcl }; + struct EIGEN_ALIGN16 _PointXYZLAB + { + PCL_ADD_POINT4D; // this adds the members x,y,z + union + { + struct + { + float L; + float a; + float b; + }; + float data_lab[4]; + }; + PCL_MAKE_ALIGNED_OPERATOR_NEW + }; + + PCL_EXPORTS std::ostream& operator << (std::ostream& os, const PointXYZLAB& p); + /** \brief A point structure representing Euclidean xyz coordinates, and the CIELAB color. + * \ingroup common + */ + struct PointXYZLAB : public _PointXYZLAB + { + inline PointXYZLAB() + { + x = y = z = 0.0f; + data[3] = 1.0f; // important for homogeneous coordinates + L = a = b = 0.0f; + data_lab[3] = 0.0f; + } + + friend std::ostream& operator << (std::ostream& os, const PointXYZLAB& p); + PCL_MAKE_ALIGNED_OPERATOR_NEW + }; + + struct EIGEN_ALIGN16 _PointXYZHSV { PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) @@ -1882,6 +1919,16 @@ POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZRGBL, ) POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZRGBL, pcl::_PointXYZRGBL) +POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZLAB, + (float, x, x) + (float, y, y) + (float, z, z) + (float, L, L) + (float, a, a) + (float, b, b) +) +POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZLAB, pcl::_PointXYZLAB) + POINT_CLOUD_REGISTER_POINT_STRUCT (pcl::_PointXYZHSV, (float, x, x) (float, y, y) diff --git a/common/include/pcl/point_types.h b/common/include/pcl/point_types.h index 1d47ba2edb0..b1f20e0bd5c 100644 --- a/common/include/pcl/point_types.h +++ b/common/include/pcl/point_types.h @@ -111,6 +111,11 @@ namespace pcl */ struct PointXYZRGBL; + /** \brief Members: float x, y, z, L, a, b + * \ingroup common + */ + struct PointXYZLAB; + /** \brief Members: float x, y, z, h, s, v * \ingroup common */ diff --git a/common/include/pcl/point_types_conversion.h b/common/include/pcl/point_types_conversion.h index a220e6060e7..231b5f20108 100644 --- a/common/include/pcl/point_types_conversion.h +++ b/common/include/pcl/point_types_conversion.h @@ -43,6 +43,8 @@ #include #include +#include // for RGB2sRGB_LUT + namespace pcl { // r,g,b, i values are from 0 to 255 @@ -134,6 +136,57 @@ namespace pcl if (out.h < 0.f) out.h += 360.f; } + /** \brief Convert a XYZRGB-based point type to a XYZLAB + * \param[in] in the input XYZRGB(XYZRGBA, XYZRGBL, etc.) point + * \param[out] out the output XYZLAB point + */ + template = true> + inline void + PointXYZRGBtoXYZLAB (const PointT& in, + PointXYZLAB& out) + { + out.x = in.x; + out.y = in.y; + out.z = in.z; + out.data[3] = 1.0; // important for homogeneous coordinates + + // convert sRGB to CIELAB + // for sRGB -> CIEXYZ see http://www.easyrgb.com/index.php?X=MATH&H=02#text2 + // for CIEXYZ -> CIELAB see http://www.easyrgb.com/index.php?X=MATH&H=07#text7 + // an overview at: https://www.comp.nus.edu.sg/~leowwk/papers/colordiff.pdf + + const auto& sRGB_LUT = RGB2sRGB_LUT(); + + const double R = sRGB_LUT[in.r]; + const double G = sRGB_LUT[in.g]; + const double B = sRGB_LUT[in.b]; + + // linear sRGB -> CIEXYZ, D65 illuminant, observer at 2 degrees + const double X = R * 0.4124 + G * 0.3576 + B * 0.1805; + const double Y = R * 0.2126 + G * 0.7152 + B * 0.0722; + const double Z = R * 0.0193 + G * 0.1192 + B * 0.9505; + + // normalize X, Y, Z with tristimulus values for Xn, Yn, Zn + float f[3] = {static_cast(X), static_cast(Y), static_cast(Z)}; + f[0] /= 0.95047; + f[1] /= 1; + f[2] /= 1.08883; + + // CIEXYZ -> CIELAB + for (int i = 0; i < 3; ++i) { + if (f[i] > 0.008856) { + f[i] = std::pow(f[i], 1.0 / 3.0); + } + else { + f[i] = 7.787 * f[i] + 16.0 / 116.0; + } + } + + out.L = 116.0f * f[1] - 16.0f; + out.a = 500.0f * (f[0] - f[1]); + out.b = 200.0f * (f[1] - f[2]); + } + /** \brief Convert a XYZRGBA point type to a XYZHSV * \param[in] in the input XYZRGBA point * \param[out] out the output XYZHSV point diff --git a/common/src/point_types.cpp b/common/src/point_types.cpp index 03d8f7984f4..e3ab796fa79 100644 --- a/common/src/point_types.cpp +++ b/common/src/point_types.cpp @@ -130,6 +130,13 @@ namespace pcl return (os); } + std::ostream& + operator << (std::ostream& os, const PointXYZLAB& p) + { + os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.L << " , " << p.a << " , " << p.b << ")"; + return (os); + } + std::ostream& operator << (std::ostream& os, const PointXYZHSV& p) { diff --git a/registration/include/pcl/registration/gicp6d.h b/registration/include/pcl/registration/gicp6d.h index bc96ecd06fc..2718344bd4a 100644 --- a/registration/include/pcl/registration/gicp6d.h +++ b/registration/include/pcl/registration/gicp6d.h @@ -46,38 +46,6 @@ #include #include -namespace pcl { -struct EIGEN_ALIGN16 _PointXYZLAB { - PCL_ADD_POINT4D; // this adds the members x,y,z - union { - struct { - float L; - float a; - float b; - }; - float data_lab[4]; - }; - PCL_MAKE_ALIGNED_OPERATOR_NEW -}; - -/** \brief A custom point type for position and CIELAB color value */ -struct PointXYZLAB : public _PointXYZLAB { - inline PointXYZLAB() - { - x = y = z = 0.0f; - data[3] = 1.0f; // important for homogeneous coordinates - L = a = b = 0.0f; - data_lab[3] = 0.0f; - } -}; -} // namespace pcl - -// register the custom point type in PCL -POINT_CLOUD_REGISTER_POINT_STRUCT( - pcl::_PointXYZLAB, - (float, x, x)(float, y, y)(float, z, z)(float, L, L)(float, a, a)(float, b, b)) -POINT_CLOUD_REGISTER_POINT_WRAPPER(pcl::PointXYZLAB, pcl::_PointXYZLAB) - namespace pcl { /** \brief GeneralizedIterativeClosestPoint6D integrates L*a*b* color space information * into the Generalized Iterative Closest Point (GICP) algorithm. diff --git a/registration/src/gicp6d.cpp b/registration/src/gicp6d.cpp index 27afd8ccab4..815ac71b93d 100644 --- a/registration/src/gicp6d.cpp +++ b/registration/src/gicp6d.cpp @@ -36,72 +36,11 @@ * */ -#include // for RGB2sRGB_LUT, XYZ2LAB_LUT #include -#include // for pcl::make_shared +#include // for pcl::make_shared +#include // for PointXYZRGBtoXYZLAB namespace pcl { -// convert sRGB to CIELAB -Eigen::Vector3f -RGB2Lab(const Eigen::Vector3i& colorRGB) -{ - // for sRGB -> CIEXYZ see http://www.easyrgb.com/index.php?X=MATH&H=02#text2 - // for CIEXYZ -> CIELAB see http://www.easyrgb.com/index.php?X=MATH&H=07#text7 - // an overview at: https://www.comp.nus.edu.sg/~leowwk/papers/colordiff.pdf - - const auto& sRGB_LUT = RGB2sRGB_LUT(); - - const double R = sRGB_LUT[colorRGB[0]]; - const double G = sRGB_LUT[colorRGB[1]]; - const double B = sRGB_LUT[colorRGB[2]]; - - // linear sRGB -> CIEXYZ, D65 illuminant, observer at 2 degrees - const double X = R * 0.4124 + G * 0.3576 + B * 0.1805; - const double Y = R * 0.2126 + G * 0.7152 + B * 0.0722; - const double Z = R * 0.0193 + G * 0.1192 + B * 0.9505; - - // normalize X, Y, Z with tristimulus values for Xn, Yn, Zn - float f[3] = {static_cast(X), static_cast(Y), static_cast(Z)}; - f[0] /= 0.95047; - f[1] /= 1; - f[2] /= 1.08883; - - // CIEXYZ -> CIELAB - for (int i = 0; i < 3; ++i) { - if (f[i] > 0.008856) { - f[i] = std::pow(f[i], 1.0 / 3.0); - } - else { - f[i] = 7.787 * f[i] + 16.0 / 116.0; - } - } - - Eigen::Vector3f colorLab; - colorLab[0] = 116.0f * f[1] - 16.0f; - colorLab[1] = 500.0f * (f[0] - f[1]); - colorLab[2] = 200.0f * (f[1] - f[2]); - - return colorLab; -} - -// convert a PointXYZRGBA cloud to a PointXYZLAB cloud -void -convertRGBAToLAB(const PointCloud& in, PointCloud& out) -{ - out.resize(in.size()); - - for (std::size_t i = 0; i < in.size(); ++i) { - out[i].x = in[i].x; - out[i].y = in[i].y; - out[i].z = in[i].z; - out[i].data[3] = 1.0; // important for homogeneous coordinates - - Eigen::Vector3f lab = RGB2Lab(in[i].getRGBVector3i()); - out[i].L = lab[0]; - out[i].a = lab[1]; - out[i].b = lab[2]; - } -} GeneralizedIterativeClosestPoint6D::GeneralizedIterativeClosestPoint6D(float lab_weight) : cloud_lab_(new pcl::PointCloud) @@ -121,7 +60,10 @@ GeneralizedIterativeClosestPoint6D::setInputSource( GeneralizedIterativeClosestPoint::setInputSource(cloud); // in addition, convert colors of the cloud to CIELAB - convertRGBAToLAB(*cloud, *cloud_lab_); + cloud_lab_->resize(cloud->size()); + for (std::size_t point_idx = 0; point_idx < cloud->size(); ++point_idx) { + PointXYZRGBtoXYZLAB((*cloud)[point_idx], (*cloud_lab_)[point_idx]); + } } void @@ -132,7 +74,10 @@ GeneralizedIterativeClosestPoint6D::setInputTarget( GeneralizedIterativeClosestPoint::setInputTarget(target); // in addition, convert colors of the cloud to CIELAB... - convertRGBAToLAB(*target, *target_lab_); + target_lab_->resize(target->size()); + for (std::size_t point_idx = 0; point_idx < target->size(); ++point_idx) { + PointXYZRGBtoXYZLAB((*target)[point_idx], (*target_lab_)[point_idx]); + } // ...and build 6d-tree target_tree_lab_.setInputCloud(target_lab_); From cad5d08d9e71ed2aa838cbd73ce103d37b11143f Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Fri, 23 Apr 2021 22:51:11 +0200 Subject: [PATCH 126/431] Fix addition of Carriage Return to PCD files. --- io/include/pcl/io/impl/pcd_io.hpp | 4 ++-- io/src/pcd_io.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/io/include/pcl/io/impl/pcd_io.hpp b/io/include/pcl/io/impl/pcd_io.hpp index 84fb0120200..ad551f79514 100644 --- a/io/include/pcl/io/impl/pcd_io.hpp +++ b/io/include/pcl/io/impl/pcd_io.hpp @@ -447,7 +447,7 @@ pcl::PCDWriter::writeASCII (const std::string &file_name, const pcl::PointCloud< } std::ofstream fs; - fs.open (file_name.c_str ()); // Open file + fs.open (file_name.c_str (), std::ios::binary); // Open file if (!fs.is_open () || fs.fail ()) { @@ -730,7 +730,7 @@ pcl::PCDWriter::writeASCII (const std::string &file_name, } std::ofstream fs; - fs.open (file_name.c_str ()); // Open file + fs.open (file_name.c_str (), std::ios::binary); // Open file if (!fs.is_open () || fs.fail ()) { throw pcl::IOException ("[pcl::PCDWriter::writeASCII] Could not open file for writing!"); diff --git a/io/src/pcd_io.cpp b/io/src/pcd_io.cpp index 31254677533..d329ef56aa8 100644 --- a/io/src/pcd_io.cpp +++ b/io/src/pcd_io.cpp @@ -1128,7 +1128,7 @@ pcl::PCDWriter::writeASCII (const std::string &file_name, const pcl::PCLPointClo std::ofstream fs; fs.precision (precision); fs.imbue (std::locale::classic ()); - fs.open (file_name.c_str ()); // Open file + fs.open (file_name.c_str (), std::ios::binary); // Open file if (!fs.is_open () || fs.fail ()) { PCL_ERROR("[pcl::PCDWriter::writeASCII] Could not open file '%s' for writing! Error : %s\n", file_name.c_str (), strerror(errno)); From 51b8652042db59648a3fd58937f58b578cb692e5 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Thu, 29 Apr 2021 22:40:39 +0200 Subject: [PATCH 127/431] [GPU] Export and template extract clusters (#4196) * Make gpu_extract_clusters templated. --- gpu/segmentation/CMakeLists.txt | 3 +- .../gpu/segmentation/gpu_extract_clusters.h | 21 +++++----- .../gpu_extract_labeled_clusters.h | 9 ++--- .../gpu_seeded_hue_segmentation.h | 7 ++-- .../impl/gpu_extract_clusters.hpp | 40 +++++++++++++------ .../impl/gpu_extract_labeled_clusters.hpp | 4 +- gpu/segmentation/src/extract_clusters.cpp | 3 ++ 7 files changed, 50 insertions(+), 37 deletions(-) diff --git a/gpu/segmentation/CMakeLists.txt b/gpu/segmentation/CMakeLists.txt index f8f3cbb5e4e..9a99a620367 100644 --- a/gpu/segmentation/CMakeLists.txt +++ b/gpu/segmentation/CMakeLists.txt @@ -6,6 +6,7 @@ set(SUBSYS_DEPS common gpu_containers gpu_utils gpu_octree) set(build TRUE) PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON) PCL_SUBSYS_DEPEND(build "${SUBSYS_NAME}" DEPS ${SUBSYS_DEPS}) +PCL_SET_SUBSYS_INCLUDE_DIR("${SUBSYS_NAME}" "${SUBSYS_PATH}") mark_as_advanced("BUILD_${SUBSYS_NAME}") PCL_ADD_DOC("${SUBSYS_NAME}") @@ -33,7 +34,7 @@ set(impl_incs set(LIB_NAME "pcl_${SUBSYS_NAME}") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME} SOURCES ${srcs} ${incs} ${impl_incs}) -target_link_libraries("${LIB_NAME}" pcl_gpu_octree pcl_gpu_utils pcl_gpu_containers) +target_link_libraries("${LIB_NAME}" pcl_common pcl_gpu_octree pcl_gpu_utils pcl_gpu_containers) PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS}) # Install include files diff --git a/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_clusters.h b/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_clusters.h index 5e2ecde9051..3738663ff42 100644 --- a/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_clusters.h +++ b/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_clusters.h @@ -50,8 +50,8 @@ namespace pcl { namespace gpu { - void - extractEuclideanClusters (const pcl::PointCloud::Ptr &host_cloud_, + template void + extractEuclideanClusters (const typename pcl::PointCloud::Ptr &host_cloud_, const pcl::gpu::Octree::Ptr &tree, float tolerance, std::vector &clusters, @@ -62,13 +62,13 @@ namespace pcl * \author Koen Buys, Radu Bogdan Rusu * \ingroup segmentation */ + template class EuclideanClusterExtraction { public: - using PointType = pcl::PointXYZ; - using PointCloudHost = pcl::PointCloud; - using PointCloudHostPtr = PointCloudHost::Ptr; - using PointCloudHostConstPtr = PointCloudHost::ConstPtr; + using PointCloudHost = pcl::PointCloud; + using PointCloudHostPtr = typename PointCloudHost::Ptr; + using PointCloudHostConstPtr = typename PointCloudHost::ConstPtr; using PointIndicesPtr = PointIndices::Ptr; using PointIndicesConstPtr = PointIndices::ConstPtr; @@ -80,8 +80,7 @@ namespace pcl ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** \brief Empty constructor. */ - EuclideanClusterExtraction () : min_pts_per_cluster_ (1), max_pts_per_cluster_ (std::numeric_limits::max ()) - {}; + EuclideanClusterExtraction () = default; /** \brief the destructor */ /* ~EuclideanClusterExtraction () @@ -143,13 +142,13 @@ namespace pcl GPUTreePtr tree_; /** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */ - double cluster_tolerance_; + double cluster_tolerance_ {0}; /** \brief The minimum number of points that a cluster needs to contain in order to be considered valid (default = 1). */ - int min_pts_per_cluster_; + int min_pts_per_cluster_ {1}; /** \brief The maximum number of points that a cluster needs to contain in order to be considered valid (default = MAXINT). */ - int max_pts_per_cluster_; + int max_pts_per_cluster_ {std::numeric_limits::max()}; /** \brief Class getName method. */ virtual std::string getClassName () const { return ("gpu::EuclideanClusterExtraction"); } diff --git a/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_labeled_clusters.h b/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_labeled_clusters.h index bf5b5e2b558..65fc71cc22f 100644 --- a/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_labeled_clusters.h +++ b/gpu/segmentation/include/pcl/gpu/segmentation/gpu_extract_labeled_clusters.h @@ -80,8 +80,7 @@ namespace pcl ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** \brief Empty constructor. */ - EuclideanLabeledClusterExtraction () : min_pts_per_cluster_ (1), max_pts_per_cluster_ (std::numeric_limits::max ()) - {}; + EuclideanLabeledClusterExtraction () = default; /** \brief Provide a pointer to the search object. * \param tree a pointer to the spatial search object. @@ -137,13 +136,13 @@ namespace pcl GPUTreePtr tree_; /** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */ - double cluster_tolerance_; + double cluster_tolerance_ {0}; /** \brief The minimum number of points that a cluster needs to contain in order to be considered valid (default = 1). */ - int min_pts_per_cluster_; + int min_pts_per_cluster_ {1}; /** \brief The maximum number of points that a cluster needs to contain in order to be considered valid (default = MAXINT). */ - int max_pts_per_cluster_; + int max_pts_per_cluster_ {std::numeric_limits::max()}; /** \brief Class getName method. */ virtual std::string getClassName () const { return ("gpu::EuclideanLabeledClusterExtraction"); } diff --git a/gpu/segmentation/include/pcl/gpu/segmentation/gpu_seeded_hue_segmentation.h b/gpu/segmentation/include/pcl/gpu/segmentation/gpu_seeded_hue_segmentation.h index 373f904cbad..b6c974dfae3 100644 --- a/gpu/segmentation/include/pcl/gpu/segmentation/gpu_seeded_hue_segmentation.h +++ b/gpu/segmentation/include/pcl/gpu/segmentation/gpu_seeded_hue_segmentation.h @@ -74,8 +74,7 @@ namespace pcl ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** \brief Empty constructor. */ - SeededHueSegmentation () : delta_hue_ (0.0) - {}; + SeededHueSegmentation () = default; /** \brief Provide a pointer to the search object. * \param tree a pointer to the spatial search object. @@ -126,10 +125,10 @@ namespace pcl GPUTreePtr tree_; /** \brief The spatial cluster tolerance as a measure in the L2 Euclidean space. */ - double cluster_tolerance_; + double cluster_tolerance_ {0}; /** \brief The allowed difference on the hue*/ - float delta_hue_; + float delta_hue_ {0.0}; /** \brief Class getName method. */ virtual std::string getClassName () const { return ("gpu::SeededHueSegmentation"); } diff --git a/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_clusters.hpp b/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_clusters.hpp index b5055e02c5c..ae8ccd9fc57 100644 --- a/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_clusters.hpp +++ b/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_clusters.hpp @@ -36,13 +36,12 @@ * @author: Koen Buys */ -#ifndef PCL_GPU_SEGMENTATION_IMPL_EXTRACT_CLUSTERS_H_ -#define PCL_GPU_SEGMENTATION_IMPL_EXTRACT_CLUSTERS_H_ - +#pragma once +#include #include -void -pcl::gpu::extractEuclideanClusters (const pcl::PointCloud::Ptr &host_cloud_, +template void +pcl::gpu::extractEuclideanClusters (const typename pcl::PointCloud::Ptr &host_cloud_, const pcl::gpu::Octree::Ptr &tree, float tolerance, std::vector &clusters, @@ -80,9 +79,14 @@ pcl::gpu::extractEuclideanClusters (const pcl::PointCloud::Ptr & // Create the query queue on the device, point based not indices pcl::gpu::Octree::Queries queries_device; // Create the query queue on the host - pcl::PointCloud::VectorType queries_host; + pcl::PointCloud::VectorType queries_host; + + // Buffer in a new PointXYZ type + PointXYZ p; + pcl::copyPoint((*host_cloud_)[i], p); + // Push the starting point in the vector - queries_host.push_back ((*host_cloud_)[i]); + queries_host.push_back (p); // Clear vector r.indices.clear(); // Push the starting point in @@ -123,7 +127,12 @@ pcl::gpu::extractEuclideanClusters (const pcl::PointCloud::Ptr & if(processed[data[i]]) continue; processed[data[i]] = true; - queries_host.push_back ((*host_cloud_)[data[i]]); + + // Buffer in a new PointXYZ type + PointXYZ p; + pcl::copyPoint((*host_cloud_)[data[i]], p); + + queries_host.push_back (p); found_points++; r.indices.push_back(data[i]); } @@ -153,7 +162,11 @@ pcl::gpu::extractEuclideanClusters (const pcl::PointCloud::Ptr & if(processed[data[qp_r + qp * max_answers]]) continue; processed[data[qp_r + qp * max_answers]] = true; - queries_host.push_back ((*host_cloud_)[data[qp_r + qp * max_answers]]); + // Buffer in a new PointXYZ type + PointXYZ p; + pcl::copyPoint((*host_cloud_)[data[qp_r + qp * max_answers]], p); + + queries_host.push_back (p); found_points++; r.indices.push_back(data[qp_r + qp * max_answers]); } @@ -176,8 +189,8 @@ pcl::gpu::extractEuclideanClusters (const pcl::PointCloud::Ptr & } } -void -pcl::gpu::EuclideanClusterExtraction::extract (std::vector &clusters) +template void +pcl::gpu::EuclideanClusterExtraction::extract (std::vector &clusters) { /* // Initialize the GPU search tree @@ -200,10 +213,11 @@ pcl::gpu::EuclideanClusterExtraction::extract (std::vector &c } */ // Extract the actual clusters - extractEuclideanClusters (host_cloud_, tree_, cluster_tolerance_, clusters, min_pts_per_cluster_, max_pts_per_cluster_); + extractEuclideanClusters (host_cloud_, tree_, cluster_tolerance_, clusters, min_pts_per_cluster_, max_pts_per_cluster_); std::cout << "INFO: end of extractEuclideanClusters " << std::endl; // Sort the clusters based on their size (largest one first) //std::sort (clusters.rbegin (), clusters.rend (), comparePointClusters); } -#endif //PCL_GPU_SEGMENTATION_IMPL_EXTRACT_CLUSTERS_H_ +#define PCL_INSTANTIATE_extractEuclideanClusters(T) template void PCL_EXPORTS pcl::gpu::extractEuclideanClusters (const typename pcl::PointCloud::Ptr &, const pcl::gpu::Octree::Ptr &,float, std::vector &, unsigned int, unsigned int); +#define PCL_INSTANTIATE_EuclideanClusterExtraction(T) template class PCL_EXPORTS pcl::gpu::EuclideanClusterExtraction; diff --git a/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_labeled_clusters.hpp b/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_labeled_clusters.hpp index cbee62f93e0..af518d99492 100644 --- a/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_labeled_clusters.hpp +++ b/gpu/segmentation/include/pcl/gpu/segmentation/impl/gpu_extract_labeled_clusters.hpp @@ -36,8 +36,7 @@ * */ -#ifndef PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_ -#define PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_ +#pragma once #include @@ -176,4 +175,3 @@ pcl::gpu::EuclideanLabeledClusterExtraction::extract (std::vector (const typename pcl::PointCloud::Ptr &, const pcl::gpu::Octree::Ptr &,float, std::vector &, unsigned int, unsigned int); #define PCL_INSTANTIATE_EuclideanLabeledClusterExtraction(T) template class PCL_EXPORTS pcl::gpu::EuclideanLabeledClusterExtraction; -#endif //PCL_GPU_SEGMENTATION_IMPL_EXTRACT_LABELED_CLUSTERS_H_ diff --git a/gpu/segmentation/src/extract_clusters.cpp b/gpu/segmentation/src/extract_clusters.cpp index fd41feb6146..4f4ddb1db9b 100644 --- a/gpu/segmentation/src/extract_clusters.cpp +++ b/gpu/segmentation/src/extract_clusters.cpp @@ -38,8 +38,11 @@ #include #include //#include +#include #include // Instantiations of specific point types +PCL_INSTANTIATE(extractEuclideanClusters, PCL_XYZ_POINT_TYPES); +PCL_INSTANTIATE(EuclideanClusterExtraction, PCL_XYZ_POINT_TYPES); PCL_INSTANTIATE(extractLabeledEuclideanClusters, PCL_XYZL_POINT_TYPES); PCL_INSTANTIATE(EuclideanLabeledClusterExtraction, PCL_XYZL_POINT_TYPES); From 490ce4119cb8eaa636556b9d734f971b54e33d3b Mon Sep 17 00:00:00 2001 From: Kunal Tyagi Date: Fri, 30 Apr 2021 06:04:23 +0900 Subject: [PATCH 128/431] [Fix] Add missing copy ctor for PointXYZLAB --- common/include/pcl/impl/point_types.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/include/pcl/impl/point_types.hpp b/common/include/pcl/impl/point_types.hpp index 021f63cab4e..609107e48cd 100644 --- a/common/include/pcl/impl/point_types.hpp +++ b/common/include/pcl/impl/point_types.hpp @@ -714,6 +714,12 @@ namespace pcl */ struct PointXYZLAB : public _PointXYZLAB { + inline PointXYZLAB (const _PointXYZLAB &p) + { + x = p.x; y = p.y; z = p.z; data[3] = 1.0f; + L = p.L; a = p.a; b = p.b; + } + inline PointXYZLAB() { x = y = z = 0.0f; From 673cb7df805b4792656bc9ccf1b7fd5644b04881 Mon Sep 17 00:00:00 2001 From: mnobrecastro Date: Sat, 1 May 2021 19:59:26 +0200 Subject: [PATCH 129/431] Namespace in aligned_{malloc/free} (pcl_macros.h) solves Eigen lib's conflict. Fixes issue #4734. --- common/include/pcl/pcl_macros.h | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/common/include/pcl/pcl_macros.h b/common/include/pcl/pcl_macros.h index 6239707a869..dd1ccfbd32b 100644 --- a/common/include/pcl/pcl_macros.h +++ b/common/include/pcl/pcl_macros.h @@ -376,44 +376,48 @@ pcl_round (float number) #endif #endif +namespace pcl { + inline void* -aligned_malloc (std::size_t size) +aligned_malloc(std::size_t size) { - void *ptr; -#if defined (MALLOC_ALIGNED) - ptr = std::malloc (size); -#elif defined (HAVE_POSIX_MEMALIGN) - if (posix_memalign (&ptr, 16, size)) + void* ptr; +#if defined(MALLOC_ALIGNED) + ptr = std::malloc(size); +#elif defined(HAVE_POSIX_MEMALIGN) + if (posix_memalign(&ptr, 16, size)) ptr = 0; -#elif defined (HAVE_MM_MALLOC) - ptr = _mm_malloc (size, 16); -#elif defined (_MSC_VER) - ptr = _aligned_malloc (size, 16); -#elif defined (ANDROID) - ptr = memalign (16, size); +#elif defined(HAVE_MM_MALLOC) + ptr = _mm_malloc(size, 16); +#elif defined(_MSC_VER) + ptr = _aligned_malloc(size, 16); +#elif defined(ANDROID) + ptr = memalign(16, size); #else - #error aligned_malloc not supported on your platform +#error aligned_malloc not supported on your platform ptr = 0; #endif return (ptr); } inline void -aligned_free (void* ptr) +aligned_free(void* ptr) { -#if defined (MALLOC_ALIGNED) || defined (HAVE_POSIX_MEMALIGN) - std::free (ptr); -#elif defined (HAVE_MM_MALLOC) - _mm_free (ptr); -#elif defined (_MSC_VER) - _aligned_free (ptr); -#elif defined (ANDROID) - free (ptr); +#if defined(MALLOC_ALIGNED) || defined(HAVE_POSIX_MEMALIGN) + std::free(ptr); +#elif defined(HAVE_MM_MALLOC) + _mm_free(ptr); +#elif defined(_MSC_VER) + _aligned_free(ptr); +#elif defined(ANDROID) + free(ptr); #else - #error aligned_free not supported on your platform +#error aligned_free not supported on your platform #endif } +} // namespace pcl + /** * \brief Macro to add a no-op or a fallthrough attribute based on compiler feature * From f11cf55f7a6b48eec5de465e6b001da296d2172f Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 4 May 2021 10:15:08 +0300 Subject: [PATCH 130/431] Add `constexpr` to static member functions for point types, add macro for `if constexpr` (#4735) * static mem functions returning constants made constexpr * static mem functions returning constants made constexpr * static mem functions returning constants made constexpr * static mem functions returning constants made constexpr --- common/include/pcl/impl/point_types.hpp | 36 ++++++++++++------------- common/include/pcl/pcl_macros.h | 6 +++++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/common/include/pcl/impl/point_types.hpp b/common/include/pcl/impl/point_types.hpp index 609107e48cd..64e6a80d62a 100644 --- a/common/include/pcl/impl/point_types.hpp +++ b/common/include/pcl/impl/point_types.hpp @@ -1307,7 +1307,7 @@ namespace pcl struct PFHSignature125 { float histogram[125] = {0.f}; - static int descriptorSize () { return 125; } + static constexpr int descriptorSize () { return 125; } inline PFHSignature125 () = default; @@ -1321,7 +1321,7 @@ namespace pcl struct PFHRGBSignature250 { float histogram[250] = {0.f}; - static int descriptorSize () { return 250; } + static constexpr int descriptorSize () { return 250; } inline PFHRGBSignature250 () = default; @@ -1408,7 +1408,7 @@ namespace pcl { float descriptor[1980] = {0.f}; float rf[9] = {0.f}; - static int descriptorSize () { return 1980; } + static constexpr int descriptorSize () { return 1980; } inline ShapeContext1980 () = default; @@ -1423,7 +1423,7 @@ namespace pcl { float descriptor[1960] = {0.f}; float rf[9] = {0.f}; - static int descriptorSize () { return 1960; } + static constexpr int descriptorSize () { return 1960; } inline UniqueShapeContext1960 () = default; @@ -1438,7 +1438,7 @@ namespace pcl { float descriptor[352] = {0.f}; float rf[9] = {0.f}; - static int descriptorSize () { return 352; } + static constexpr int descriptorSize () { return 352; } inline SHOT352 () = default; @@ -1454,7 +1454,7 @@ namespace pcl { float descriptor[1344] = {0.f}; float rf[9] = {0.f}; - static int descriptorSize () { return 1344; } + static constexpr int descriptorSize () { return 1344; } inline SHOT1344 () = default; @@ -1519,7 +1519,7 @@ namespace pcl struct FPFHSignature33 { float histogram[33] = {0.f}; - static int descriptorSize () { return 33; } + static constexpr int descriptorSize () { return 33; } inline FPFHSignature33 () = default; @@ -1533,7 +1533,7 @@ namespace pcl struct VFHSignature308 { float histogram[308] = {0.f}; - static int descriptorSize () { return 308; } + static constexpr int descriptorSize () { return 308; } inline VFHSignature308 () = default; @@ -1547,7 +1547,7 @@ namespace pcl struct GRSDSignature21 { float histogram[21] = {0.f}; - static int descriptorSize () { return 21; } + static constexpr int descriptorSize () { return 21; } inline GRSDSignature21 () = default; @@ -1563,7 +1563,7 @@ namespace pcl float scale = 0.f; float orientation = 0.f; unsigned char descriptor[64] = {0}; - static int descriptorSize () { return 64; } + static constexpr int descriptorSize () { return 64; } inline BRISKSignature512 () = default; @@ -1579,7 +1579,7 @@ namespace pcl struct ESFSignature640 { float histogram[640] = {0.f}; - static int descriptorSize () { return 640; } + static constexpr int descriptorSize () { return 640; } inline ESFSignature640 () = default; @@ -1593,7 +1593,7 @@ namespace pcl struct GASDSignature512 { float histogram[512] = {0.f}; - static int descriptorSize() { return 512; } + static constexpr int descriptorSize() { return 512; } inline GASDSignature512 () = default; @@ -1607,7 +1607,7 @@ namespace pcl struct GASDSignature984 { float histogram[984] = {0.f}; - static int descriptorSize() { return 984; } + static constexpr int descriptorSize() { return 984; } inline GASDSignature984 () = default; @@ -1621,7 +1621,7 @@ namespace pcl struct GASDSignature7992 { float histogram[7992] = {0.f}; - static int descriptorSize() { return 7992; } + static constexpr int descriptorSize() { return 7992; } inline GASDSignature7992 () = default; @@ -1635,7 +1635,7 @@ namespace pcl struct GFPFHSignature16 { float histogram[16] = {0.f}; - static int descriptorSize () { return 16; } + static constexpr int descriptorSize () { return 16; } inline GFPFHSignature16 () = default; @@ -1650,7 +1650,7 @@ namespace pcl { float x = 0.f, y = 0.f, z = 0.f, roll = 0.f, pitch = 0.f, yaw = 0.f; float descriptor[36] = {0.f}; - static int descriptorSize () { return 36; } + static constexpr int descriptorSize () { return 36; } inline Narf36 () = default; @@ -1712,7 +1712,7 @@ namespace pcl struct Histogram { float histogram[N]; - static int descriptorSize () { return N; } + static constexpr int descriptorSize () { return N; } }; struct EIGEN_ALIGN16 _PointWithScale @@ -1861,7 +1861,7 @@ namespace pcl operator << (std::ostream& os, const Histogram& p) { // make constexpr - if (N > 0) + PCL_IF_CONSTEXPR(N > 0) { os << "(" << p.histogram[0]; std::for_each(p.histogram + 1, std::end(p.histogram), diff --git a/common/include/pcl/pcl_macros.h b/common/include/pcl/pcl_macros.h index dd1ccfbd32b..a86497da87f 100644 --- a/common/include/pcl/pcl_macros.h +++ b/common/include/pcl/pcl_macros.h @@ -442,3 +442,9 @@ aligned_free(void* ptr) #else #define PCL_NODISCARD #endif + +#ifdef __cpp_if_constexpr + #define PCL_IF_CONSTEXPR(x) if constexpr(x) +#else + #define PCL_IF_CONSTEXPR(x) if (x) +#endif From 29936f76880261fd334e20242e12c03c11e8e909 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 25 Apr 2021 15:38:57 +0200 Subject: [PATCH 131/431] Optimize includes --- .../pc_source/registered_views_source.h | 2 +- .../include/pcl/apps/in_hand_scanner/icp.h | 2 -- .../pcl/apps/in_hand_scanner/in_hand_scanner.h | 3 +-- .../pcl/apps/in_hand_scanner/input_data_processing.h | 1 - .../pcl/apps/in_hand_scanner/offline_integration.h | 2 -- .../include/pcl/apps/in_hand_scanner/opengl_viewer.h | 2 -- .../pcl/apps/in_hand_scanner/visibility_confidence.h | 1 - apps/in_hand_scanner/src/input_data_processing.cpp | 1 - apps/in_hand_scanner/src/integration.cpp | 1 - apps/in_hand_scanner/src/visibility_confidence.cpp | 1 + apps/include/pcl/apps/nn_classification.h | 1 + apps/src/feature_matching.cpp | 1 - apps/src/openni_klt.cpp | 2 +- apps/src/openni_organized_edge_detection.cpp | 1 - apps/src/stereo_ground_segmentation.cpp | 1 + .../sources/iccv2011/src/build_all_object_models.cpp | 1 + .../sources/iccv2011/src/test_feature_estimation.cpp | 1 + .../sources/iccv2011/src/test_registration.cpp | 2 +- .../content/sources/iccv2011/src/test_surface.cpp | 1 + .../sources/iros2011/src/build_all_object_models.cpp | 1 + .../sources/iros2011/src/test_feature_estimation.cpp | 1 + .../sources/iros2011/src/test_registration.cpp | 2 +- .../content/sources/iros2011/src/test_surface.cpp | 1 + .../openni_narf_keypoint_extraction.cpp | 2 +- .../openni_range_image_visualization.cpp | 2 +- .../sources/pcl_visualizer/pcl_visualizer_demo.cpp | 2 +- .../range_image_visualization.cpp | 2 +- .../content/sources/tracking/tracking_sample.cpp | 11 +---------- .../content/sources/vfh_recognition/build_tree.cpp | 2 +- .../sources/vfh_recognition/nearest_neighbors.cpp | 4 ++-- filters/include/pcl/filters/crop_hull.h | 1 - geometry/include/pcl/geometry/mesh_indices.h | 2 +- gpu/features/test/test_fpfh.cpp | 1 - gpu/kinfu/tools/kinfu_app.cpp | 1 + gpu/kinfu_large_scale/tools/kinfuLS_app.cpp | 1 + gpu/people/tools/people_pcd_prob.cpp | 1 - io/include/pcl/io/ensenso_grabber.h | 1 - io/include/pcl/io/file_io.h | 3 ++- io/include/pcl/io/grabber.h | 2 +- io/include/pcl/io/impl/auto_io.hpp | 4 +--- io/include/pcl/io/impl/pcd_io.hpp | 2 +- io/include/pcl/io/oni_grabber.h | 1 - io/include/pcl/io/openni2_grabber.h | 1 - io/include/pcl/io/openni_grabber.h | 2 +- io/include/pcl/io/pcd_io.h | 1 + io/include/pcl/io/ply/byte_order.h | 1 + io/include/pcl/io/ply/ply.h | 1 + io/include/pcl/io/ply/ply_parser.h | 6 +++++- io/include/pcl/io/real_sense_2_grabber.h | 1 - io/include/pcl/io/robot_eye_grabber.h | 1 + io/src/ascii_io.cpp | 2 ++ io/src/hdl_grabber.cpp | 1 - io/src/ifs_io.cpp | 3 ++- io/src/image_grabber.cpp | 3 +++ io/src/obj_io.cpp | 4 +++- io/src/oni_grabber.cpp | 2 +- io/src/openni2_grabber.cpp | 2 +- io/src/openni_camera/openni_device_primesense.cpp | 1 - io/src/openni_camera/openni_device_xtion.cpp | 1 - io/src/openni_camera/openni_driver.cpp | 2 -- io/src/openni_grabber.cpp | 2 +- io/src/pcd_io.cpp | 3 ++- io/src/ply_io.cpp | 2 +- io/src/real_sense_2_grabber.cpp | 1 - io/tools/openni_grabber_example.cpp | 1 + io/tools/openni_pcd_recorder.cpp | 1 + io/tools/pcd_introduce_nan.cpp | 1 + outofcore/tools/outofcore_print.cpp | 1 + registration/include/pcl/registration/elch.h | 1 - registration/include/pcl/registration/impl/elch.hpp | 3 ++- registration/include/pcl/registration/impl/gicp.hpp | 1 - .../include/pcl/registration/impl/joint_icp.hpp | 1 - registration/include/pcl/registration/impl/ndt_2d.hpp | 2 -- registration/include/pcl/registration/lum.h | 1 - .../pcl/sample_consensus/impl/sac_model_circle.hpp | 2 +- .../pcl/sample_consensus/impl/sac_model_circle3d.hpp | 2 +- .../pcl/sample_consensus/impl/sac_model_cone.hpp | 2 +- .../pcl/sample_consensus/impl/sac_model_cylinder.hpp | 2 +- .../pcl/sample_consensus/impl/sac_model_sphere.hpp | 2 +- .../pcl/sample_consensus/sac_model_registration.h | 1 - .../pcl/segmentation/edge_aware_plane_comparator.h | 1 - .../pcl/segmentation/euclidean_cluster_comparator.h | 2 +- .../euclidean_plane_coefficient_comparator.h | 1 - .../pcl/segmentation/impl/min_cut_segmentation.hpp | 2 +- .../include/pcl/segmentation/min_cut_segmentation.h | 2 +- .../segmentation/rgb_plane_coefficient_comparator.h | 1 - .../include/pcl/segmentation/supervoxel_clustering.h | 2 +- simulation/tools/sim_viewer.cpp | 1 - test/io/test_grabbers.cpp | 2 ++ test/search/test_flann_search.cpp | 2 +- test/search/test_octree.cpp | 2 +- tools/concatenate_points_pcd.cpp | 1 - tools/fast_bilateral_filter.cpp | 2 ++ tools/grid_min.cpp | 2 ++ tools/hdl_viewer_simple.cpp | 1 - tools/image_grabber_saver.cpp | 1 + tools/image_grabber_viewer.cpp | 3 +-- tools/image_viewer.cpp | 2 -- tools/local_max.cpp | 2 ++ tools/morph.cpp | 2 ++ tools/normal_estimation.cpp | 2 ++ tools/octree_viewer.cpp | 1 - tools/oni_viewer_simple.cpp | 1 - tools/openni2_viewer.cpp | 1 - tools/openni_image.cpp | 2 +- tools/openni_save_image.cpp | 3 +-- tools/openni_viewer.cpp | 1 - tools/openni_viewer_simple.cpp | 1 - tools/passthrough_filter.cpp | 3 ++- tools/pcd2png.cpp | 1 + tools/pcd_grabber_viewer.cpp | 4 ++-- tools/pcd_viewer.cpp | 1 - tools/pcl_video.cpp | 4 +++- tools/png2pcd.cpp | 4 +++- tools/progressive_morphological_filter.cpp | 2 ++ tools/radius_filter.cpp | 2 ++ tools/sac_segmentation_plane.cpp | 2 ++ tools/tiff2pcd.cpp | 2 +- tools/unary_classifier_segment.cpp | 1 + tools/uniform_sampling.cpp | 1 - tools/vlp_viewer.cpp | 2 -- tools/xyz2pcd.cpp | 1 + .../include/pcl/visualization/common/actor_map.h | 3 ++- visualization/src/cloud_viewer.cpp | 1 - visualization/src/histogram_visualizer.cpp | 1 - visualization/src/pcl_visualizer.cpp | 3 ++- 126 files changed, 113 insertions(+), 115 deletions(-) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/registered_views_source.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/registered_views_source.h index 690c6c59815..1699f85d96a 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/registered_views_source.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/pc_source/registered_views_source.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h index 46991846e50..1448564fcbd 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/icp.h @@ -41,8 +41,6 @@ #pragma once #include -#include -#include #include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h index b972e66893e..fa2c81db01a 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/in_hand_scanner.h @@ -43,10 +43,9 @@ #include #include #include -#include #include #include - +#include // for connection #include #include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h index 63b9cc153e9..46362e9f0ad 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/input_data_processing.h @@ -41,7 +41,6 @@ #pragma once #include -#include #include #include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h index cff11995d4b..895fe8a348f 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/offline_integration.h @@ -46,8 +46,6 @@ #include #include #include -#include -#include #include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h index a684650c55a..46f73b215f3 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/opengl_viewer.h @@ -44,9 +44,7 @@ #include #include #include -#include #include -#include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/visibility_confidence.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/visibility_confidence.h index 086baacbf86..ef4ed2847dc 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/visibility_confidence.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/visibility_confidence.h @@ -45,7 +45,6 @@ #include #include #include -#include namespace pcl { diff --git a/apps/in_hand_scanner/src/input_data_processing.cpp b/apps/in_hand_scanner/src/input_data_processing.cpp index 1afbb53dff0..22df6626f9a 100644 --- a/apps/in_hand_scanner/src/input_data_processing.cpp +++ b/apps/in_hand_scanner/src/input_data_processing.cpp @@ -42,7 +42,6 @@ #include #include -#include //////////////////////////////////////////////////////////////////////////////// diff --git a/apps/in_hand_scanner/src/integration.cpp b/apps/in_hand_scanner/src/integration.cpp index 76fca477f30..a779afe127e 100644 --- a/apps/in_hand_scanner/src/integration.cpp +++ b/apps/in_hand_scanner/src/integration.cpp @@ -45,7 +45,6 @@ #include #include -#include #include #include diff --git a/apps/in_hand_scanner/src/visibility_confidence.cpp b/apps/in_hand_scanner/src/visibility_confidence.cpp index d0bda321ff8..fb2ff56f85d 100644 --- a/apps/in_hand_scanner/src/visibility_confidence.cpp +++ b/apps/in_hand_scanner/src/visibility_confidence.cpp @@ -39,6 +39,7 @@ */ #include +#include // for Isometry3f pcl::ihs::Dome::Dome () { diff --git a/apps/include/pcl/apps/nn_classification.h b/apps/include/pcl/apps/nn_classification.h index 701510a9ebb..e2977e90138 100644 --- a/apps/include/pcl/apps/nn_classification.h +++ b/apps/include/pcl/apps/nn_classification.h @@ -41,6 +41,7 @@ #include #include +#include // for FLT_MAX namespace pcl { diff --git a/apps/src/feature_matching.cpp b/apps/src/feature_matching.cpp index 3fda149b8c2..488af48cca1 100644 --- a/apps/src/feature_matching.cpp +++ b/apps/src/feature_matching.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/apps/src/openni_klt.cpp b/apps/src/openni_klt.cpp index e0adcdcb551..0c37dd93ae2 100644 --- a/apps/src/openni_klt.cpp +++ b/apps/src/openni_klt.cpp @@ -41,9 +41,9 @@ #include #include #include -#include #include +#include // for to_iso_string, local_time #include #define SHOW_FPS 1 diff --git a/apps/src/openni_organized_edge_detection.cpp b/apps/src/openni_organized_edge_detection.cpp index b06f8c2e4ec..2f4d07cb9cb 100644 --- a/apps/src/openni_organized_edge_detection.cpp +++ b/apps/src/openni_organized_edge_detection.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/apps/src/stereo_ground_segmentation.cpp b/apps/src/stereo_ground_segmentation.cpp index c320bc2c2ba..ba7a7f8de3d 100755 --- a/apps/src/stereo_ground_segmentation.cpp +++ b/apps/src/stereo_ground_segmentation.cpp @@ -49,6 +49,7 @@ #include #include #include +#include // for directory_iterator #include diff --git a/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp b/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp index 53ce73c889d..f82bbf2bd53 100644 --- a/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/build_all_object_models.cpp @@ -7,6 +7,7 @@ #include #include #include +#include // for split, is_any_of namespace bf = boost::filesystem; inline void diff --git a/doc/tutorials/content/sources/iccv2011/src/test_feature_estimation.cpp b/doc/tutorials/content/sources/iccv2011/src/test_feature_estimation.cpp index 0d98d57fd56..d3ceb67834a 100644 --- a/doc/tutorials/content/sources/iccv2011/src/test_feature_estimation.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/test_feature_estimation.cpp @@ -6,6 +6,7 @@ #include #include #include +#include // for split int main (int argc, char ** argv) diff --git a/doc/tutorials/content/sources/iccv2011/src/test_registration.cpp b/doc/tutorials/content/sources/iccv2011/src/test_registration.cpp index 33fb8c38c40..59348ce4c3a 100644 --- a/doc/tutorials/content/sources/iccv2011/src/test_registration.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/test_registration.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include // for split #include "load_clouds.h" int diff --git a/doc/tutorials/content/sources/iccv2011/src/test_surface.cpp b/doc/tutorials/content/sources/iccv2011/src/test_surface.cpp index b704f65564b..d22ca6ab939 100644 --- a/doc/tutorials/content/sources/iccv2011/src/test_surface.cpp +++ b/doc/tutorials/content/sources/iccv2011/src/test_surface.cpp @@ -4,6 +4,7 @@ #include #include #include +#include // for split int main (int argc, char ** argv) diff --git a/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp b/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp index 094c9e220da..81736542100 100644 --- a/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp +++ b/doc/tutorials/content/sources/iros2011/src/build_all_object_models.cpp @@ -7,6 +7,7 @@ #include #include #include +#include // for split, is_any_of namespace bf = boost::filesystem; inline void diff --git a/doc/tutorials/content/sources/iros2011/src/test_feature_estimation.cpp b/doc/tutorials/content/sources/iros2011/src/test_feature_estimation.cpp index 0df4ad0e1f0..3e27e60cf40 100644 --- a/doc/tutorials/content/sources/iros2011/src/test_feature_estimation.cpp +++ b/doc/tutorials/content/sources/iros2011/src/test_feature_estimation.cpp @@ -6,6 +6,7 @@ #include #include #include +#include // for split int main (int argc, char ** argv) diff --git a/doc/tutorials/content/sources/iros2011/src/test_registration.cpp b/doc/tutorials/content/sources/iros2011/src/test_registration.cpp index a1c8c92aac8..2fce34395c3 100644 --- a/doc/tutorials/content/sources/iros2011/src/test_registration.cpp +++ b/doc/tutorials/content/sources/iros2011/src/test_registration.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include // for split #include "load_clouds.h" int diff --git a/doc/tutorials/content/sources/iros2011/src/test_surface.cpp b/doc/tutorials/content/sources/iros2011/src/test_surface.cpp index b704f65564b..d22ca6ab939 100644 --- a/doc/tutorials/content/sources/iros2011/src/test_surface.cpp +++ b/doc/tutorials/content/sources/iros2011/src/test_surface.cpp @@ -4,6 +4,7 @@ #include #include #include +#include // for split int main (int argc, char ** argv) diff --git a/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp b/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp index 6f0dd70d955..8e4d130ca95 100644 --- a/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp +++ b/doc/tutorials/content/sources/openni_narf_keypoint_extraction/openni_narf_keypoint_extraction.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include // for pcl::getTime #include #include #include diff --git a/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp b/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp index a7cdbdb9da7..dabc5432c36 100644 --- a/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp +++ b/doc/tutorials/content/sources/openni_range_image_visualization/openni_range_image_visualization.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include // for pcl::deg2rad #include #include #include diff --git a/doc/tutorials/content/sources/pcl_visualizer/pcl_visualizer_demo.cpp b/doc/tutorials/content/sources/pcl_visualizer/pcl_visualizer_demo.cpp index 376ebe9a620..99d98d58a37 100644 --- a/doc/tutorials/content/sources/pcl_visualizer/pcl_visualizer_demo.cpp +++ b/doc/tutorials/content/sources/pcl_visualizer/pcl_visualizer_demo.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include // for pcl::deg2rad #include #include #include diff --git a/doc/tutorials/content/sources/range_image_visualization/range_image_visualization.cpp b/doc/tutorials/content/sources/range_image_visualization/range_image_visualization.cpp index 2d695b3a2f3..523c1ed2d04 100644 --- a/doc/tutorials/content/sources/range_image_visualization/range_image_visualization.cpp +++ b/doc/tutorials/content/sources/range_image_visualization/range_image_visualization.cpp @@ -1,6 +1,6 @@ #include -#include + #include #include #include diff --git a/doc/tutorials/content/sources/tracking/tracking_sample.cpp b/doc/tutorials/content/sources/tracking/tracking_sample.cpp index 672e6fa2ece..682b4bbc83c 100644 --- a/doc/tutorials/content/sources/tracking/tracking_sample.cpp +++ b/doc/tutorials/content/sources/tracking/tracking_sample.cpp @@ -1,31 +1,22 @@ #include #include #include -#include -#include #include +#include // for transformPointCloud #include #include #include #include -#include #include -#include -#include - -#include -#include - #include #include #include #include #include #include -#include #include #include diff --git a/doc/tutorials/content/sources/vfh_recognition/build_tree.cpp b/doc/tutorials/content/sources/vfh_recognition/build_tree.cpp index 142d221d086..ecc6cf3e8a6 100644 --- a/doc/tutorials/content/sources/vfh_recognition/build_tree.cpp +++ b/doc/tutorials/content/sources/vfh_recognition/build_tree.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -8,6 +7,7 @@ #include #include + typedef std::pair > vfh_model; /** \brief Loads an n-D histogram file as a VFH signature diff --git a/doc/tutorials/content/sources/vfh_recognition/nearest_neighbors.cpp b/doc/tutorials/content/sources/vfh_recognition/nearest_neighbors.cpp index 86995357e7c..de785b48269 100644 --- a/doc/tutorials/content/sources/vfh_recognition/nearest_neighbors.cpp +++ b/doc/tutorials/content/sources/vfh_recognition/nearest_neighbors.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include // for compute3DCentroid #include #include #include @@ -10,7 +10,7 @@ #include #include #include - +#include // for replace_last typedef std::pair > vfh_model; /** \brief Loads an n-D histogram file as a VFH signature diff --git a/filters/include/pcl/filters/crop_hull.h b/filters/include/pcl/filters/crop_hull.h index a24133476d5..26c90654eb9 100644 --- a/filters/include/pcl/filters/crop_hull.h +++ b/filters/include/pcl/filters/crop_hull.h @@ -37,7 +37,6 @@ #pragma once -#include #include #include diff --git a/geometry/include/pcl/geometry/mesh_indices.h b/geometry/include/pcl/geometry/mesh_indices.h index 79cbddc8c9d..f21e1b83a41 100644 --- a/geometry/include/pcl/geometry/mesh_indices.h +++ b/geometry/include/pcl/geometry/mesh_indices.h @@ -40,7 +40,7 @@ #pragma once -#include +#include #include diff --git a/gpu/features/test/test_fpfh.cpp b/gpu/features/test/test_fpfh.cpp index 301468a0c1b..5d2dbb6ed60 100644 --- a/gpu/features/test/test_fpfh.cpp +++ b/gpu/features/test/test_fpfh.cpp @@ -43,7 +43,6 @@ #include #include #include "data_source.hpp" -#include using namespace pcl; using namespace pcl::gpu; diff --git a/gpu/kinfu/tools/kinfu_app.cpp b/gpu/kinfu/tools/kinfu_app.cpp index 6eebd1b0ae8..a18d3dcaa15 100644 --- a/gpu/kinfu/tools/kinfu_app.cpp +++ b/gpu/kinfu/tools/kinfu_app.cpp @@ -44,6 +44,7 @@ #include #include +#include // for microsec_clock::local_time #include #include diff --git a/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp b/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp index b60dedcc36a..d96b6171de3 100644 --- a/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp +++ b/gpu/kinfu_large_scale/tools/kinfuLS_app.cpp @@ -56,6 +56,7 @@ Work in progress: patch by Marco (AUG,19th 2012) #include #include +#include // for microsec_clock::local_time #include #include diff --git a/gpu/people/tools/people_pcd_prob.cpp b/gpu/people/tools/people_pcd_prob.cpp index a22247b2ef7..c29ac7717f0 100644 --- a/gpu/people/tools/people_pcd_prob.cpp +++ b/gpu/people/tools/people_pcd_prob.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include diff --git a/io/include/pcl/io/ensenso_grabber.h b/io/include/pcl/io/ensenso_grabber.h index f03fd6cd9aa..c25684858db 100644 --- a/io/include/pcl/io/ensenso_grabber.h +++ b/io/include/pcl/io/ensenso_grabber.h @@ -44,7 +44,6 @@ #include #include #include -#include #include #include diff --git a/io/include/pcl/io/file_io.h b/io/include/pcl/io/file_io.h index 54f0856a618..ddb6b7aa16e 100644 --- a/io/include/pcl/io/file_io.h +++ b/io/include/pcl/io/file_io.h @@ -40,10 +40,11 @@ #include // for fromPCLPointCloud2, toPCLPointCloud2 #include // for PointCloud #include // for PCLPointCloud2 -#include #include #include #include // for Quaternionf +#include // for numeric_cast +#include // for iequals namespace pcl { diff --git a/io/include/pcl/io/grabber.h b/io/include/pcl/io/grabber.h index 385ae501ebc..fdbd739c22a 100644 --- a/io/include/pcl/io/grabber.h +++ b/io/include/pcl/io/grabber.h @@ -46,8 +46,8 @@ #include #include #include -#include #include +#include // for connection, signal, ... namespace pcl { diff --git a/io/include/pcl/io/impl/auto_io.hpp b/io/include/pcl/io/impl/auto_io.hpp index 5c2ab7c96aa..6a1b50cf291 100644 --- a/io/include/pcl/io/impl/auto_io.hpp +++ b/io/include/pcl/io/impl/auto_io.hpp @@ -40,12 +40,10 @@ #ifndef PCL_IO_AUTO_IO_IMPL_H_ #define PCL_IO_AUTO_IO_IMPL_H_ -// #include -// #include #include #include #include -// #include +#include // for path namespace pcl { diff --git a/io/include/pcl/io/impl/pcd_io.hpp b/io/include/pcl/io/impl/pcd_io.hpp index 84fb0120200..7f012b4fc01 100644 --- a/io/include/pcl/io/impl/pcd_io.hpp +++ b/io/include/pcl/io/impl/pcd_io.hpp @@ -40,13 +40,13 @@ #ifndef PCL_IO_PCD_IO_IMPL_H_ #define PCL_IO_PCD_IO_IMPL_H_ +#include // for trim #include #include #include #include #include // for getFields, ... #include -#include #include #include diff --git a/io/include/pcl/io/oni_grabber.h b/io/include/pcl/io/oni_grabber.h index 150ca094e59..fa4e86a3ca4 100644 --- a/io/include/pcl/io/oni_grabber.h +++ b/io/include/pcl/io/oni_grabber.h @@ -44,7 +44,6 @@ #ifdef HAVE_OPENNI #include -#include #include #include #include diff --git a/io/include/pcl/io/openni2_grabber.h b/io/include/pcl/io/openni2_grabber.h index c4ce5f0bb9c..e0da353961b 100644 --- a/io/include/pcl/io/openni2_grabber.h +++ b/io/include/pcl/io/openni2_grabber.h @@ -46,7 +46,6 @@ #ifdef HAVE_OPENNI2 #include -#include #include #include #include diff --git a/io/include/pcl/io/openni_grabber.h b/io/include/pcl/io/openni_grabber.h index bbe1332c080..54e2251040e 100644 --- a/io/include/pcl/io/openni_grabber.h +++ b/io/include/pcl/io/openni_grabber.h @@ -45,7 +45,6 @@ #ifdef HAVE_OPENNI #include -#include #include #include #include @@ -54,6 +53,7 @@ #include #include #include +#include // for shared_array namespace pcl { diff --git a/io/include/pcl/io/pcd_io.h b/io/include/pcl/io/pcd_io.h index 23f71ef11a4..a3e22fb987d 100644 --- a/io/include/pcl/io/pcd_io.h +++ b/io/include/pcl/io/pcd_io.h @@ -43,6 +43,7 @@ #include #include #include +#include // for file_lock namespace pcl { diff --git a/io/include/pcl/io/ply/byte_order.h b/io/include/pcl/io/ply/byte_order.h index 61316ae07ea..8fb57817558 100644 --- a/io/include/pcl/io/ply/byte_order.h +++ b/io/include/pcl/io/ply/byte_order.h @@ -42,6 +42,7 @@ #include #include +#include // for swap namespace pcl { diff --git a/io/include/pcl/io/ply/ply.h b/io/include/pcl/io/ply/ply.h index 7f3fe1909c6..f658ed69a88 100644 --- a/io/include/pcl/io/ply/ply.h +++ b/io/include/pcl/io/ply/ply.h @@ -41,6 +41,7 @@ #pragma once #include +#include // for int8_t, int16_t, ... /** \file ply.h contains standard typedefs and generic type traits * \author Ares Lagae as part of libply, Nizar Sallem diff --git a/io/include/pcl/io/ply/ply_parser.h b/io/include/pcl/io/ply/ply_parser.h index 55aee22f0c9..64159e6ab6d 100644 --- a/io/include/pcl/io/ply/ply_parser.h +++ b/io/include/pcl/io/ply/ply_parser.h @@ -40,7 +40,6 @@ #pragma once -#include #include #include #include @@ -50,6 +49,11 @@ #include #include #include +#include // for lexical_cast +#include // for inherit +#include // inherit_linearly +#include // for joint_view +#include // for transform namespace pcl { diff --git a/io/include/pcl/io/real_sense_2_grabber.h b/io/include/pcl/io/real_sense_2_grabber.h index f485a326146..6a1a5e6e844 100644 --- a/io/include/pcl/io/real_sense_2_grabber.h +++ b/io/include/pcl/io/real_sense_2_grabber.h @@ -40,7 +40,6 @@ #include #include -#include #include #include #include diff --git a/io/include/pcl/io/robot_eye_grabber.h b/io/include/pcl/io/robot_eye_grabber.h index 546b0d7d08a..6f7c7ec1ebe 100644 --- a/io/include/pcl/io/robot_eye_grabber.h +++ b/io/include/pcl/io/robot_eye_grabber.h @@ -45,6 +45,7 @@ #include #include #include +#include // for shared_array #include #include diff --git a/io/src/ascii_io.cpp b/io/src/ascii_io.cpp index 4a1971f1a65..ad5cd7fcd25 100644 --- a/io/src/ascii_io.cpp +++ b/io/src/ascii_io.cpp @@ -40,6 +40,8 @@ #include #include #include +#include // for lexical_cast +#include // for split #include ////////////////////////////////////////////////////////////////////////////// diff --git a/io/src/hdl_grabber.cpp b/io/src/hdl_grabber.cpp index 8e116e51beb..3774f2f850b 100644 --- a/io/src/hdl_grabber.cpp +++ b/io/src/hdl_grabber.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include #include diff --git a/io/src/ifs_io.cpp b/io/src/ifs_io.cpp index 8b07c4a3d6e..a7a44db3a97 100644 --- a/io/src/ifs_io.cpp +++ b/io/src/ifs_io.cpp @@ -36,13 +36,14 @@ */ #include -#include #include #include #include #include #include +#include // for exists +#include // for mapped_file_source /////////////////////////////////////////////////////////////////////////////////////////// int diff --git a/io/src/image_grabber.cpp b/io/src/image_grabber.cpp index 7e930ca83cc..ce9ac5521f5 100644 --- a/io/src/image_grabber.cpp +++ b/io/src/image_grabber.cpp @@ -41,6 +41,9 @@ #include #include #include +#include // for exists, basename, is_directory, ... +#include // for to_upper_copy +#include // for posix_time #ifdef PCL_BUILT_WITH_VTK #include diff --git a/io/src/obj_io.cpp b/io/src/obj_io.cpp index 4bfb891347f..c6cba33c248 100644 --- a/io/src/obj_io.cpp +++ b/io/src/obj_io.cpp @@ -38,8 +38,10 @@ #include #include #include -#include #include +#include // for lexical_cast +#include // for exists +#include // for split pcl::MTLReader::MTLReader () { diff --git a/io/src/oni_grabber.cpp b/io/src/oni_grabber.cpp index 0dea4cca0ce..76746241fd2 100644 --- a/io/src/oni_grabber.cpp +++ b/io/src/oni_grabber.cpp @@ -42,7 +42,7 @@ #include #include #include -#include // for boost::shared_array +#include // for boost::shared_array #include // for dynamic_pointer_cast #include diff --git a/io/src/openni2_grabber.cpp b/io/src/openni2_grabber.cpp index 0150db14aee..b81467f41f5 100644 --- a/io/src/openni2_grabber.cpp +++ b/io/src/openni2_grabber.cpp @@ -48,9 +48,9 @@ #include #include #include -#include #include #include +#include // for exists using namespace pcl::io::openni2; diff --git a/io/src/openni_camera/openni_device_primesense.cpp b/io/src/openni_camera/openni_device_primesense.cpp index aca1a8a0d36..20072c47cf7 100644 --- a/io/src/openni_camera/openni_device_primesense.cpp +++ b/io/src/openni_camera/openni_device_primesense.cpp @@ -45,7 +45,6 @@ #include #include -#include #include #include diff --git a/io/src/openni_camera/openni_device_xtion.cpp b/io/src/openni_camera/openni_device_xtion.cpp index cd06198ca13..56925743cf3 100644 --- a/io/src/openni_camera/openni_device_xtion.cpp +++ b/io/src/openni_camera/openni_device_xtion.cpp @@ -44,7 +44,6 @@ #endif #include -#include #include #include diff --git a/io/src/openni_camera/openni_driver.cpp b/io/src/openni_camera/openni_driver.cpp index 070c6b810e0..65382c39218 100644 --- a/io/src/openni_camera/openni_driver.cpp +++ b/io/src/openni_camera/openni_driver.cpp @@ -57,8 +57,6 @@ #ifndef _WIN32 #include -#else -#include #endif ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/io/src/openni_grabber.cpp b/io/src/openni_grabber.cpp index cd28989079f..50844d4a794 100644 --- a/io/src/openni_grabber.cpp +++ b/io/src/openni_grabber.cpp @@ -44,10 +44,10 @@ #include #include #include -#include #include #include #include +#include // for exists using namespace std::chrono_literals; diff --git a/io/src/pcd_io.cpp b/io/src/pcd_io.cpp index 31254677533..5e1a2466582 100644 --- a/io/src/pcd_io.cpp +++ b/io/src/pcd_io.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include // pcl::utils::ignore #include #include @@ -51,6 +50,8 @@ #include #include +#include // for permissions +#include // for split /////////////////////////////////////////////////////////////////////////////////////////// void diff --git a/io/src/ply_io.cpp b/io/src/ply_io.cpp index 775860cefd9..c0bf7c3bf2d 100644 --- a/io/src/ply_io.cpp +++ b/io/src/ply_io.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -49,6 +48,7 @@ // https://www.boost.org/doc/libs/1_70_0/libs/filesystem/doc/index.htm#Coding-guidelines #define BOOST_FILESYSTEM_NO_DEPRECATED #include +#include // for split namespace fs = boost::filesystem; diff --git a/io/src/real_sense_2_grabber.cpp b/io/src/real_sense_2_grabber.cpp index 1e1febbffe7..f5dd3ff9566 100644 --- a/io/src/real_sense_2_grabber.cpp +++ b/io/src/real_sense_2_grabber.cpp @@ -35,7 +35,6 @@ * */ -#include #include #include #include diff --git a/io/tools/openni_grabber_example.cpp b/io/tools/openni_grabber_example.cpp index 28ddb5b5597..32448bfb2f4 100644 --- a/io/tools/openni_grabber_example.cpp +++ b/io/tools/openni_grabber_example.cpp @@ -40,6 +40,7 @@ #include #include #include +#include // for setprecision class SimpleOpenNIProcessor { diff --git a/io/tools/openni_pcd_recorder.cpp b/io/tools/openni_pcd_recorder.cpp index 6d30feecb70..a8f7e6f8388 100644 --- a/io/tools/openni_pcd_recorder.cpp +++ b/io/tools/openni_pcd_recorder.cpp @@ -37,6 +37,7 @@ #include #include #include +#include // for to_iso_string, local_time #include #include #include diff --git a/io/tools/pcd_introduce_nan.cpp b/io/tools/pcd_introduce_nan.cpp index 744339988fe..cedebda3662 100644 --- a/io/tools/pcd_introduce_nan.cpp +++ b/io/tools/pcd_introduce_nan.cpp @@ -36,6 +36,7 @@ */ #include +#include // for lexical_cast /** @brief PCL point object */ using PointT = pcl::PointXYZRGBA; diff --git a/outofcore/tools/outofcore_print.cpp b/outofcore/tools/outofcore_print.cpp index 62538b9435d..d8a13a5eb54 100644 --- a/outofcore/tools/outofcore_print.cpp +++ b/outofcore/tools/outofcore_print.cpp @@ -56,6 +56,7 @@ #include #include #include +#include // for replace_first namespace ba = boost::accumulators; diff --git a/registration/include/pcl/registration/elch.h b/registration/include/pcl/registration/elch.h index 736ce6397b6..981b153c23c 100644 --- a/registration/include/pcl/registration/elch.h +++ b/registration/include/pcl/registration/elch.h @@ -40,7 +40,6 @@ #pragma once -#include #include #include #include diff --git a/registration/include/pcl/registration/impl/elch.hpp b/registration/include/pcl/registration/impl/elch.hpp index 011024a3a6e..647386cf880 100644 --- a/registration/include/pcl/registration/impl/elch.hpp +++ b/registration/include/pcl/registration/impl/elch.hpp @@ -42,9 +42,10 @@ #define PCL_REGISTRATION_IMPL_ELCH_H_ #include -#include #include +#include // for dijkstra_shortest_paths + #include #include #include diff --git a/registration/include/pcl/registration/impl/gicp.hpp b/registration/include/pcl/registration/impl/gicp.hpp index ef039547082..3d03d497cba 100644 --- a/registration/include/pcl/registration/impl/gicp.hpp +++ b/registration/include/pcl/registration/impl/gicp.hpp @@ -41,7 +41,6 @@ #ifndef PCL_REGISTRATION_IMPL_GICP_HPP_ #define PCL_REGISTRATION_IMPL_GICP_HPP_ -#include #include namespace pcl { diff --git a/registration/include/pcl/registration/impl/joint_icp.hpp b/registration/include/pcl/registration/impl/joint_icp.hpp index 3fa9a50f9a4..edab731bf9a 100644 --- a/registration/include/pcl/registration/impl/joint_icp.hpp +++ b/registration/include/pcl/registration/impl/joint_icp.hpp @@ -40,7 +40,6 @@ #define PCL_REGISTRATION_IMPL_JOINT_ICP_HPP_ #include -#include #include namespace pcl { diff --git a/registration/include/pcl/registration/impl/ndt_2d.hpp b/registration/include/pcl/registration/impl/ndt_2d.hpp index 687320b3675..6b1ac8800ae 100644 --- a/registration/include/pcl/registration/impl/ndt_2d.hpp +++ b/registration/include/pcl/registration/impl/ndt_2d.hpp @@ -41,8 +41,6 @@ #ifndef PCL_NDT_2D_IMPL_H_ #define PCL_NDT_2D_IMPL_H_ -#include - #include // for SelfAdjointEigenSolver, EigenSolver #include diff --git a/registration/include/pcl/registration/lum.h b/registration/include/pcl/registration/lum.h index fbc64acf2f1..97d2df64408 100644 --- a/registration/include/pcl/registration/lum.h +++ b/registration/include/pcl/registration/lum.h @@ -41,7 +41,6 @@ #pragma once #include -#include #include #include #include diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp index 58c39b707df..b2607bdea06 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_circle.hpp @@ -41,7 +41,7 @@ #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CIRCLE_H_ #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CIRCLE_H_ -#include +#include // for LevenbergMarquardt #include #include 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 d93362e92b0..32ccbda77ea 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 @@ -41,7 +41,7 @@ #include // for DBL_MAX -#include +#include // for LevenbergMarquardt #include #include 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 c8c4fed704f..65280ce7823 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 @@ -39,7 +39,7 @@ #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CONE_H_ #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CONE_H_ -#include +#include // for LevenbergMarquardt #include #include // for getAngle3D #include diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp index 533e7c65931..d21e1a691c6 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_cylinder.hpp @@ -41,7 +41,7 @@ #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CYLINDER_H_ #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_CYLINDER_H_ -#include +#include // for LevenbergMarquardt #include #include // for getAngle3D #include diff --git a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp index 4def914a2c7..fdb7bb924b1 100644 --- a/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp +++ b/sample_consensus/include/pcl/sample_consensus/impl/sac_model_sphere.hpp @@ -41,7 +41,7 @@ #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_SPHERE_H_ #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_SPHERE_H_ -#include +#include // for LevenbergMarquardt #include ////////////////////////////////////////////////////////////////////////// diff --git a/sample_consensus/include/pcl/sample_consensus/sac_model_registration.h b/sample_consensus/include/pcl/sample_consensus/sac_model_registration.h index 51b9b13ea5c..43c15c91fac 100644 --- a/sample_consensus/include/pcl/sample_consensus/sac_model_registration.h +++ b/sample_consensus/include/pcl/sample_consensus/sac_model_registration.h @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/segmentation/include/pcl/segmentation/edge_aware_plane_comparator.h b/segmentation/include/pcl/segmentation/edge_aware_plane_comparator.h index c2a4a5eb468..848dd6e8d5b 100644 --- a/segmentation/include/pcl/segmentation/edge_aware_plane_comparator.h +++ b/segmentation/include/pcl/segmentation/edge_aware_plane_comparator.h @@ -39,7 +39,6 @@ #pragma once -#include #include namespace pcl diff --git a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h index 4e410519c3d..300fb20f073 100644 --- a/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h +++ b/segmentation/include/pcl/segmentation/euclidean_cluster_comparator.h @@ -39,10 +39,10 @@ #pragma once +#include // for std::set #include #include #include -#include #include diff --git a/segmentation/include/pcl/segmentation/euclidean_plane_coefficient_comparator.h b/segmentation/include/pcl/segmentation/euclidean_plane_coefficient_comparator.h index 29e486d2bb5..b752ac0b6d2 100644 --- a/segmentation/include/pcl/segmentation/euclidean_plane_coefficient_comparator.h +++ b/segmentation/include/pcl/segmentation/euclidean_plane_coefficient_comparator.h @@ -39,7 +39,6 @@ #pragma once -#include #include namespace pcl diff --git a/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp b/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp index abdfb81093a..6d0b85ef3c7 100644 --- a/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp +++ b/segmentation/include/pcl/segmentation/impl/min_cut_segmentation.hpp @@ -39,7 +39,7 @@ #ifndef PCL_SEGMENTATION_MIN_CUT_SEGMENTATION_HPP_ #define PCL_SEGMENTATION_MIN_CUT_SEGMENTATION_HPP_ -#include +#include // for boykov_kolmogorov_max_flow #include #include #include diff --git a/segmentation/include/pcl/segmentation/min_cut_segmentation.h b/segmentation/include/pcl/segmentation/min_cut_segmentation.h index f2a26897790..d75d2f8ccb7 100644 --- a/segmentation/include/pcl/segmentation/min_cut_segmentation.h +++ b/segmentation/include/pcl/segmentation/min_cut_segmentation.h @@ -38,7 +38,6 @@ #pragma once -#include #include #include #include @@ -47,6 +46,7 @@ #include #include #include +#include // for adjacency_list namespace pcl { diff --git a/segmentation/include/pcl/segmentation/rgb_plane_coefficient_comparator.h b/segmentation/include/pcl/segmentation/rgb_plane_coefficient_comparator.h index 263ad8c15b7..5c5c5a926d3 100644 --- a/segmentation/include/pcl/segmentation/rgb_plane_coefficient_comparator.h +++ b/segmentation/include/pcl/segmentation/rgb_plane_coefficient_comparator.h @@ -39,7 +39,6 @@ #pragma once -#include #include namespace pcl diff --git a/segmentation/include/pcl/segmentation/supervoxel_clustering.h b/segmentation/include/pcl/segmentation/supervoxel_clustering.h index c3aa569afbb..02377111d23 100644 --- a/segmentation/include/pcl/segmentation/supervoxel_clustering.h +++ b/segmentation/include/pcl/segmentation/supervoxel_clustering.h @@ -51,7 +51,7 @@ #include #include #include -#include +#include // for ptr_list diff --git a/simulation/tools/sim_viewer.cpp b/simulation/tools/sim_viewer.cpp index d92ee326839..52a73683295 100644 --- a/simulation/tools/sim_viewer.cpp +++ b/simulation/tools/sim_viewer.cpp @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include diff --git a/test/io/test_grabbers.cpp b/test/io/test_grabbers.cpp index 4394e944317..a7c794aad00 100644 --- a/test/io/test_grabbers.cpp +++ b/test/io/test_grabbers.cpp @@ -7,6 +7,8 @@ #include #include #include +#include // for directory_iterator, extension +#include // for to_upper_copy using namespace std::chrono_literals; diff --git a/test/search/test_flann_search.cpp b/test/search/test_flann_search.cpp index 663157f194e..8d1786c023b 100644 --- a/test/search/test_flann_search.cpp +++ b/test/search/test_flann_search.cpp @@ -41,7 +41,7 @@ #include // for copyPointCloud #include #include -#include +#include // for pcl::search::KdTree #include #include #include diff --git a/test/search/test_octree.cpp b/test/search/test_octree.cpp index 215d9186951..19d320efdce 100644 --- a/test/search/test_octree.cpp +++ b/test/search/test_octree.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include // for pcl::search::Octree using namespace pcl; using namespace octree; diff --git a/tools/concatenate_points_pcd.cpp b/tools/concatenate_points_pcd.cpp index 9a9364ab732..f96125f9893 100644 --- a/tools/concatenate_points_pcd.cpp +++ b/tools/concatenate_points_pcd.cpp @@ -47,7 +47,6 @@ #include #include #include -#include Eigen::Vector4f translation; Eigen::Quaternionf orientation; diff --git a/tools/fast_bilateral_filter.cpp b/tools/fast_bilateral_filter.cpp index e05998738d8..4bf9835cf0f 100644 --- a/tools/fast_bilateral_filter.cpp +++ b/tools/fast_bilateral_filter.cpp @@ -41,6 +41,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/grid_min.cpp b/tools/grid_min.cpp index 9174164bdc0..3ca8d011aad 100644 --- a/tools/grid_min.cpp +++ b/tools/grid_min.cpp @@ -44,6 +44,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/hdl_viewer_simple.cpp b/tools/hdl_viewer_simple.cpp index 48c3fa55d72..8ae390867db 100644 --- a/tools/hdl_viewer_simple.cpp +++ b/tools/hdl_viewer_simple.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/tools/image_grabber_saver.cpp b/tools/image_grabber_saver.cpp index b327fe78188..764e672d8f9 100644 --- a/tools/image_grabber_saver.cpp +++ b/tools/image_grabber_saver.cpp @@ -40,6 +40,7 @@ #include #include #include +#include // for exists using pcl::console::print_error; using pcl::console::print_info; diff --git a/tools/image_grabber_viewer.cpp b/tools/image_grabber_viewer.cpp index 4ce088b8942..e7117baffc6 100644 --- a/tools/image_grabber_viewer.cpp +++ b/tools/image_grabber_viewer.cpp @@ -40,13 +40,12 @@ #include #include #include -#include #include #include -#include #include #include +#include // for exists using namespace std::chrono_literals; using pcl::console::print_error; diff --git a/tools/image_viewer.cpp b/tools/image_viewer.cpp index f8840eff140..94e048f8562 100644 --- a/tools/image_viewer.cpp +++ b/tools/image_viewer.cpp @@ -38,11 +38,9 @@ #include #include -#include //fps calculations #include #include #include -#include #include int diff --git a/tools/local_max.cpp b/tools/local_max.cpp index 775f66f54b9..b7f1392e7e1 100644 --- a/tools/local_max.cpp +++ b/tools/local_max.cpp @@ -44,6 +44,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/morph.cpp b/tools/morph.cpp index f75090be3b4..1fb9bd15fce 100644 --- a/tools/morph.cpp +++ b/tools/morph.cpp @@ -44,6 +44,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/normal_estimation.cpp b/tools/normal_estimation.cpp index f3f1403b160..34401a8bcb2 100644 --- a/tools/normal_estimation.cpp +++ b/tools/normal_estimation.cpp @@ -45,6 +45,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/octree_viewer.cpp b/tools/octree_viewer.cpp index 8b7bbe95b28..8b40f6c28ae 100644 --- a/tools/octree_viewer.cpp +++ b/tools/octree_viewer.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/tools/oni_viewer_simple.cpp b/tools/oni_viewer_simple.cpp index dcb577895c8..fcf331d6f23 100644 --- a/tools/oni_viewer_simple.cpp +++ b/tools/oni_viewer_simple.cpp @@ -42,7 +42,6 @@ #include //fps calculations #include #include -#include #include #include diff --git a/tools/openni2_viewer.cpp b/tools/openni2_viewer.cpp index 2427af083a3..a6ecabd01f9 100644 --- a/tools/openni2_viewer.cpp +++ b/tools/openni2_viewer.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/tools/openni_image.cpp b/tools/openni_image.cpp index eff110c069e..356858f5c0f 100644 --- a/tools/openni_image.cpp +++ b/tools/openni_image.cpp @@ -39,7 +39,6 @@ #include //fps calculations #include #include -#include #include #include #include @@ -47,6 +46,7 @@ #include #include +#include // for ptime, to_iso_string, ... #include #include diff --git a/tools/openni_save_image.cpp b/tools/openni_save_image.cpp index f579e4ca4ef..e7cad451778 100644 --- a/tools/openni_save_image.cpp +++ b/tools/openni_save_image.cpp @@ -46,11 +46,10 @@ #include #include -#include "boost.h" - #include #include #include +#include // for to_iso_string, local_time #define SHOW_FPS 1 diff --git a/tools/openni_viewer.cpp b/tools/openni_viewer.cpp index 6853be295e3..f35543f6525 100644 --- a/tools/openni_viewer.cpp +++ b/tools/openni_viewer.cpp @@ -39,7 +39,6 @@ #include //fps calculations #include #include -#include #include #include #include diff --git a/tools/openni_viewer_simple.cpp b/tools/openni_viewer_simple.cpp index 7236603ff42..0599ebdb868 100644 --- a/tools/openni_viewer_simple.cpp +++ b/tools/openni_viewer_simple.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/tools/passthrough_filter.cpp b/tools/passthrough_filter.cpp index 32791c75209..87c976f4b9c 100644 --- a/tools/passthrough_filter.cpp +++ b/tools/passthrough_filter.cpp @@ -37,12 +37,13 @@ */ #include -#include #include #include #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/pcd2png.cpp b/tools/pcd2png.cpp index 3e8d9f8a399..4254098addf 100644 --- a/tools/pcd2png.cpp +++ b/tools/pcd2png.cpp @@ -49,6 +49,7 @@ #include #include #include +#include // for lexical_cast using namespace pcl; using namespace pcl::io; diff --git a/tools/pcd_grabber_viewer.cpp b/tools/pcd_grabber_viewer.cpp index d75525d0a42..3dd923b9be8 100644 --- a/tools/pcd_grabber_viewer.cpp +++ b/tools/pcd_grabber_viewer.cpp @@ -39,10 +39,10 @@ #include #include #include -#include #include #include - +#include // for exists, extension, ... +#include // for to_upper_copy #include #include diff --git a/tools/pcd_viewer.cpp b/tools/pcd_viewer.cpp index 175e66d811c..e8cdf1248c6 100644 --- a/tools/pcd_viewer.cpp +++ b/tools/pcd_viewer.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include diff --git a/tools/pcl_video.cpp b/tools/pcl_video.cpp index 7c84aed0784..b9dbf4939f9 100644 --- a/tools/pcl_video.cpp +++ b/tools/pcl_video.cpp @@ -52,7 +52,9 @@ #include #include #include -#include "boost.h" +#include // for date +#include // for local_time +#include // for time_duration using namespace std::chrono_literals; namespace bpt = boost::posix_time; diff --git a/tools/png2pcd.cpp b/tools/png2pcd.cpp index c519a414b91..e0c4e47699a 100644 --- a/tools/png2pcd.cpp +++ b/tools/png2pcd.cpp @@ -51,7 +51,9 @@ #include #include #include -#include +#include // for vtkImageData +#include // for vtkSmartPointer +#include // for vtkPNGReader #define RED_MULTIPLIER 0.299 #define GREEN_MULTIPLIER 0.587 diff --git a/tools/progressive_morphological_filter.cpp b/tools/progressive_morphological_filter.cpp index 8f8c6275c41..b6ea2d002e9 100644 --- a/tools/progressive_morphological_filter.cpp +++ b/tools/progressive_morphological_filter.cpp @@ -46,6 +46,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/radius_filter.cpp b/tools/radius_filter.cpp index 39371899887..60cb56fb855 100644 --- a/tools/radius_filter.cpp +++ b/tools/radius_filter.cpp @@ -40,6 +40,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using PointType = pcl::PointXYZ; diff --git a/tools/sac_segmentation_plane.cpp b/tools/sac_segmentation_plane.cpp index 1a7a1edb059..335eb910155 100644 --- a/tools/sac_segmentation_plane.cpp +++ b/tools/sac_segmentation_plane.cpp @@ -43,6 +43,8 @@ #include #include #include +#include // for path, exists, ... +#include // for to_upper_copy using namespace pcl; using namespace pcl::io; diff --git a/tools/tiff2pcd.cpp b/tools/tiff2pcd.cpp index 0d862c26fa7..8602f859c51 100644 --- a/tools/tiff2pcd.cpp +++ b/tools/tiff2pcd.cpp @@ -48,7 +48,7 @@ #include #include -#include +#include // for vtkImageData #include #include #include diff --git a/tools/unary_classifier_segment.cpp b/tools/unary_classifier_segment.cpp index c7972ec17a2..1a9c6e06fb5 100644 --- a/tools/unary_classifier_segment.cpp +++ b/tools/unary_classifier_segment.cpp @@ -45,6 +45,7 @@ #include // for removeNaNFromPointCloud #include +#include // for path, exists, ... using namespace pcl; using namespace pcl::io; diff --git a/tools/uniform_sampling.cpp b/tools/uniform_sampling.cpp index 48e15f82ed7..2d92fd41f24 100644 --- a/tools/uniform_sampling.cpp +++ b/tools/uniform_sampling.cpp @@ -44,7 +44,6 @@ #include #include #include -#include using namespace pcl; using namespace pcl::io; diff --git a/tools/vlp_viewer.cpp b/tools/vlp_viewer.cpp index 5d281a3df11..e823ece668b 100644 --- a/tools/vlp_viewer.cpp +++ b/tools/vlp_viewer.cpp @@ -44,9 +44,7 @@ #include #include #include -#include #include -#include #include diff --git a/tools/xyz2pcd.cpp b/tools/xyz2pcd.cpp index 2ade40cc9dd..40848038391 100644 --- a/tools/xyz2pcd.cpp +++ b/tools/xyz2pcd.cpp @@ -38,6 +38,7 @@ #include #include #include +#include // for split using namespace pcl; using namespace pcl::io; diff --git a/visualization/include/pcl/visualization/common/actor_map.h b/visualization/include/pcl/visualization/common/actor_map.h index acd9fd247f5..68025d919b1 100644 --- a/visualization/include/pcl/visualization/common/actor_map.h +++ b/visualization/include/pcl/visualization/common/actor_map.h @@ -37,7 +37,8 @@ #pragma once -#include +#include // for PointCloudGeometryHandler +#include // for PointCloudColorHandler #include #include diff --git a/visualization/src/cloud_viewer.cpp b/visualization/src/cloud_viewer.cpp index d670dbb7ec2..002134f69d6 100644 --- a/visualization/src/cloud_viewer.cpp +++ b/visualization/src/cloud_viewer.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include diff --git a/visualization/src/histogram_visualizer.cpp b/visualization/src/histogram_visualizer.cpp index 090e8b5d67b..9d7b7ef7c26 100644 --- a/visualization/src/histogram_visualizer.cpp +++ b/visualization/src/histogram_visualizer.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include diff --git a/visualization/src/pcl_visualizer.cpp b/visualization/src/pcl_visualizer.cpp index 0a110ee5763..370d5ed2243 100644 --- a/visualization/src/pcl_visualizer.cpp +++ b/visualization/src/pcl_visualizer.cpp @@ -58,7 +58,6 @@ #include #include -#include #include #include @@ -100,12 +99,14 @@ #include #include #include +#include // for BOOST_VERSION #if (BOOST_VERSION >= 106600) #include #else #include #endif #include +#include // for split #include // pcl::utils::ignore #include From c9f35621b582ed80949ae822f9161c674f92ea16 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Mon, 26 Apr 2021 18:51:17 +0200 Subject: [PATCH 132/431] Update line numbers in tutorial --- doc/tutorials/content/tracking.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/tutorials/content/tracking.rst b/doc/tutorials/content/tracking.rst index a9ba99d8505..8625bfc3b7e 100644 --- a/doc/tutorials/content/tracking.rst +++ b/doc/tutorials/content/tracking.rst @@ -60,40 +60,40 @@ Now, let's break down the code piece by piece. .. literalinclude:: sources/tracking/tracking_sample.cpp :language: cpp - :lines: 227-242 + :lines: 219-234 First, in main function, these lines set the parameters for tracking. .. literalinclude:: sources/tracking/tracking_sample.cpp :language: cpp - :lines: 246-257 + :lines: 237-249 Here, we set likelihood function which tracker use when calculate weights. You can add more likelihood function as you like. By default, there are normals likelihood and color likelihood functions. When you want to add other likelihood function, all you have to do is initialize new Coherence Class and add the Coherence instance to coherence variable with addPointCoherence function. .. literalinclude:: sources/tracking/tracking_sample.cpp :language: cpp - :lines: 259-272 + :lines: 251-264 In this part, we set the point cloud loaded from pcd file as reference model to tracker and also set model's transform values. .. literalinclude:: sources/tracking/tracking_sample.cpp :language: cpp - :lines: 173-180 + :lines: 165-172 Until the counter variable become equal to 10, we ignore the input point cloud, because the point cloud at first few frames often have noise. After counter variable reach to 10 frame, at each loop, we set downsampled input point cloud to tracker and the tracker will compute particles movement. .. literalinclude:: sources/tracking/tracking_sample.cpp :language: cpp - :lines: 82-82 + :lines: 74-74 In drawParticles function, you can get particles's positions by calling getParticles(). .. literalinclude:: sources/tracking/tracking_sample.cpp :language: cpp - :lines: 116-117 + :lines: 108-109 From ed0c79eeb7a1c2296d5ec7132bbc6f11f81bd096 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Mon, 26 Apr 2021 19:09:01 +0200 Subject: [PATCH 133/431] Deprecate unneeded headers --- apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h | 2 +- apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h | 2 +- io/include/pcl/io/boost.h | 2 +- io/include/pcl/io/io.h | 2 +- registration/include/pcl/registration/boost.h | 2 +- registration/include/pcl/registration/transforms.h | 2 +- sample_consensus/include/pcl/sample_consensus/eigen.h | 2 +- segmentation/include/pcl/segmentation/boost.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h index 5575dccbd68..68491e6ff07 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/boost.h @@ -43,6 +43,6 @@ #ifdef __GNUC__ # pragma GCC system_header #endif - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #include #include diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h index 7c1208e399b..ccbefab4d34 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/eigen.h @@ -43,7 +43,7 @@ #ifdef __GNUC__ # pragma GCC system_header #endif - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #include #include #include diff --git a/io/include/pcl/io/boost.h b/io/include/pcl/io/boost.h index 685b36ae8e7..be19192f2f6 100644 --- a/io/include/pcl/io/boost.h +++ b/io/include/pcl/io/boost.h @@ -36,7 +36,7 @@ */ #pragma once - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #if defined __GNUC__ # pragma GCC system_header #endif diff --git a/io/include/pcl/io/io.h b/io/include/pcl/io/io.h index e579aab7aa0..ab579c77a80 100644 --- a/io/include/pcl/io/io.h +++ b/io/include/pcl/io/io.h @@ -38,5 +38,5 @@ */ #pragma once - +PCL_DEPRECATED_HEADER(1, 15, "Please include pcl/common/io.h directly.") #include diff --git a/registration/include/pcl/registration/boost.h b/registration/include/pcl/registration/boost.h index f5aa5b814a6..6a6f17d115d 100644 --- a/registration/include/pcl/registration/boost.h +++ b/registration/include/pcl/registration/boost.h @@ -38,7 +38,7 @@ */ #pragma once - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #if defined __GNUC__ #pragma GCC system_header #endif diff --git a/registration/include/pcl/registration/transforms.h b/registration/include/pcl/registration/transforms.h index 3101974d530..2f4bfb79cfa 100644 --- a/registration/include/pcl/registration/transforms.h +++ b/registration/include/pcl/registration/transforms.h @@ -39,5 +39,5 @@ */ #pragma once - +PCL_DEPRECATED_HEADER(1, 15, "Please include pcl/common/transforms.h directly.") #include diff --git a/sample_consensus/include/pcl/sample_consensus/eigen.h b/sample_consensus/include/pcl/sample_consensus/eigen.h index 6d4f64900b5..63d733321cc 100644 --- a/sample_consensus/include/pcl/sample_consensus/eigen.h +++ b/sample_consensus/include/pcl/sample_consensus/eigen.h @@ -38,7 +38,7 @@ */ #pragma once - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed eigen headers directly.") #if defined __GNUC__ # pragma GCC system_header #endif diff --git a/segmentation/include/pcl/segmentation/boost.h b/segmentation/include/pcl/segmentation/boost.h index 40c3aac5f77..6ef50c3865b 100644 --- a/segmentation/include/pcl/segmentation/boost.h +++ b/segmentation/include/pcl/segmentation/boost.h @@ -39,7 +39,7 @@ */ #pragma once - +PCL_DEPRECATED_HEADER(1, 15, "Please include the needed boost headers directly.") #ifdef __GNUC__ #pragma GCC system_header #endif From 78dc48d6a4836d1ecee9dd1ceedefe8a3b6877be Mon Sep 17 00:00:00 2001 From: Hang Yan Date: Wed, 5 May 2021 19:48:28 +0800 Subject: [PATCH 134/431] Fixed `PCL_WARNINGS_ARE_ERRORS` option and some compile warnings (#4695) * fixed PCL_WARNINGS_ARE_ERRORS option in CMakeLists * fixed -Werror=class-memaccess in pcl/common/include/pcl/common/impl/io.hpp fixed compile error like this, when using -Werror: pcl/common/include/pcl/common/impl/io.hpp:139:12: error: 'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'struct pcl::PointNormal' from an array of 'const struct pcl::PointXYZ' [-Werror=class-memaccess] * fixed some memset on non-POD types * fixed new errors * restored 3rd opennurbs modification * added compile flags for 3rd party & fixed deprecated copy * fixed errors & set copy functions to default * Update surface/include/pcl/surface/impl/convex_hull.hpp fixed redundancy code with already defined data type Co-authored-by: Kunal Tyagi * fixed hull size in convex_hull.hpp * added type AlignedVector for pcl/types.h * fixed include library of Eigen::aligned_allocator * fixed noexcept-type errors & added exclusive rules in CMakeLists * resolved conflicts with master * added inline comments * added rules and fixed codes for compile on GPU * made unsigned declaration more explict * fixed noexcept-type error in test_common.cpp * Moved for-loop into empty templated function * Moved copyPointCloudMemcpy into detail namespace Co-authored-by: Kunal Tyagi --- CMakeLists.txt | 7 ++-- .../in_hand_scanner/impl/common_types.hpp | 2 ++ .../pcl/apps/point_cloud_editor/selection.h | 5 +++ common/include/pcl/common/impl/io.hpp | 34 +++++++++++++------ common/include/pcl/types.h | 8 +++++ common/src/parse.cpp | 10 ++++-- cuda/CMakeLists.txt | 4 ++- cuda/io/src/debayering.cu | 4 +-- .../pcl/features/impl/integral_image2D.hpp | 4 +-- gpu/CMakeLists.txt | 6 +++- outofcore/CMakeLists.txt | 9 +++++ surface/CMakeLists.txt | 15 ++++++++ .../include/pcl/surface/impl/convex_hull.hpp | 9 +++-- test/common/test_common.cpp | 2 +- test/gpu/octree/perfomance.cpp | 5 +-- visualization/CMakeLists.txt | 6 ++++ 16 files changed, 101 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index beb00c8e4b5..1ff0cd718e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,9 +105,10 @@ if(CMAKE_COMPILER_IS_GNUCXX) string(APPEND CMAKE_CXX_FLAGS " -Wabi") endif() string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare -Wno-invalid-offsetof -Wno-conversion ${SSE_FLAGS}") - if(PCL_WARNINGS_ARE_ERRORS) - string(APPEND CMAKE_CXX_FLAGS " -Werror") - endif() + endif() + + if(PCL_WARNINGS_ARE_ERRORS) + string(APPEND CMAKE_CXX_FLAGS " -Werror -fno-strict-aliasing") endif() if("${CMAKE_SHARED_LINKER_FLAGS}" STREQUAL "" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") diff --git a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp index 76f82bc3036..a0e5a1ebb38 100644 --- a/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp +++ b/apps/in_hand_scanner/include/pcl/apps/in_hand_scanner/impl/common_types.hpp @@ -99,6 +99,8 @@ namespace pcl this->directions = other.directions; } + inline PointIHS& operator=(const PointIHS& other) = default; + inline PointIHS (const pcl::PointXYZRGBNormal& other, const float weight) { this->x = other.x; diff --git a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h index 3e744e30e88..7855e1711cf 100644 --- a/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h +++ b/apps/point_cloud_editor/include/pcl/apps/point_cloud_editor/selection.h @@ -60,6 +60,11 @@ class Selection : public Statistics registerStats(); } + /// @brief Copy constructor. + /// @param selection a const reference to a selection object whose + /// properties will be copied. + Selection (const Selection& selection) = default; + /// @brief Equal operator /// @param selection a const reference to a selection object whose /// properties will be copied. diff --git a/common/include/pcl/common/impl/io.hpp b/common/include/pcl/common/impl/io.hpp index 4a147385f5b..d6d93aaff12 100644 --- a/common/include/pcl/common/impl/io.hpp +++ b/common/include/pcl/common/impl/io.hpp @@ -117,6 +117,28 @@ getFieldsList (const pcl::PointCloud &) return (result); } +namespace detail +{ + + template void + copyPointCloudMemcpy (const pcl::PointCloud &cloud_in, + pcl::PointCloud &cloud_out) + { + // Iterate over each point, if the point types of two clouds are different + for (std::size_t i = 0; i < cloud_in.size (); ++i) + copyPoint (cloud_in[i], cloud_out[i]); + } + + + template void + copyPointCloudMemcpy (const pcl::PointCloud &cloud_in, + pcl::PointCloud &cloud_out) + { + // Use std::copy directly, if the point types of two clouds are same + std::copy (&cloud_in[0], (&cloud_in[0]) + cloud_in.size (), &cloud_out[0]); + } + +} // namespace detail template void copyPointCloud (const pcl::PointCloud &cloud_in, @@ -131,16 +153,8 @@ copyPointCloud (const pcl::PointCloud &cloud_in, cloud_out.sensor_origin_ = cloud_in.sensor_origin_; cloud_out.resize (cloud_in.size ()); - if (cloud_in.empty ()) - return; - - if (isSamePointType ()) - // Copy the whole memory block - memcpy (&cloud_out[0], &cloud_in[0], cloud_in.size () * sizeof (PointInT)); - else - // Iterate over each point - for (std::size_t i = 0; i < cloud_in.size (); ++i) - copyPoint (cloud_in[i], cloud_out[i]); + if (!cloud_in.empty ()) + detail::copyPointCloudMemcpy (cloud_in, cloud_out); } diff --git a/common/include/pcl/types.h b/common/include/pcl/types.h index ca2e8e69e9a..06cfb6a577d 100644 --- a/common/include/pcl/types.h +++ b/common/include/pcl/types.h @@ -49,6 +49,8 @@ #include +#include + namespace pcl { namespace detail { @@ -129,5 +131,11 @@ namespace pcl * \brief Type used for indices in PCL */ using Indices = IndicesAllocator<>; + + /** + * \brief Type used for aligned vector of Eigen objects in PCL + */ + template + using AlignedVector = std::vector>; } // namespace pcl diff --git a/common/src/parse.cpp b/common/src/parse.cpp index b6d67eeb9d7..1d8d9d63e91 100644 --- a/common/src/parse.cpp +++ b/common/src/parse.cpp @@ -181,14 +181,20 @@ parse_argument (int argc, const char * const * argv, const char * str, T &val) n int pcl::console::parse_argument (int argc, const char * const * argv, const char * str, double &val) { - return parse_generic(strtod, argc, argv, str, val); + // added lambda wrapper for `strtod` to handle noexcept-type warning in GCC 7, + // refer to: https://stackoverflow.com/questions/46798456/handling-gccs-noexcept-type-warning + const auto strtod_l = [](const char *str, char **str_end){ return strtod(str, str_end); }; + return parse_generic(strtod_l, argc, argv, str, val); } //////////////////////////////////////////////////////////////////////////////// int pcl::console::parse_argument (int argc, const char * const * argv, const char * str, float &val) { - return parse_generic(strtof, argc, argv, str, val); + // added lambda wrapper for `strtof` to handle noexcept-type warning in GCC 7, + // refer to: https://stackoverflow.com/questions/46798456/handling-gccs-noexcept-type-warning + const auto strtof_l = [](const char *str, char **str_end){ return strtof(str, str_end); }; + return parse_generic(strtof_l, argc, argv, str, val); } //////////////////////////////////////////////////////////////////////////////// diff --git a/cuda/CMakeLists.txt b/cuda/CMakeLists.txt index 72cbd38b772..c327f95e5dc 100644 --- a/cuda/CMakeLists.txt +++ b/cuda/CMakeLists.txt @@ -11,7 +11,9 @@ endif() if(CMAKE_COMPILER_IS_GNUCXX) string(REPLACE "-Wold-style-cast" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-Wno-invalid-offsetof" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable") + string(APPEND CMAKE_CXX_FLAGS " -Wno-conversion -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable") + # allow deprecation warnings in Eigen(3.3.7)/Core, see here: https://gitlab.kitware.com/vtk/vtk/-/issues/17661 + string(APPEND CMAKE_CXX_FLAGS " -Wno-error=cpp") endif() collect_subproject_directory_names("${CMAKE_CURRENT_SOURCE_DIR}" "CMakeLists.txt" PCL_CUDA_MODULES_NAMES PCL_CUDA_MODULES_DIRS) diff --git a/cuda/io/src/debayering.cu b/cuda/io/src/debayering.cu index 9c0e55d9ac2..b9f23e95a7f 100644 --- a/cuda/io/src/debayering.cu +++ b/cuda/io/src/debayering.cu @@ -114,8 +114,8 @@ namespace pcl OpenNIRGB DebayerBilinear::operator () (int index) const { // get position - int xIdx = index % width; - int yIdx = index / width; + unsigned int xIdx = index % width; + unsigned int yIdx = index / width; OpenNIRGB result; diff --git a/features/include/pcl/features/impl/integral_image2D.hpp b/features/include/pcl/features/impl/integral_image2D.hpp index 653dfa2e3d2..a0f424807f4 100644 --- a/features/include/pcl/features/impl/integral_image2D.hpp +++ b/features/include/pcl/features/impl/integral_image2D.hpp @@ -158,7 +158,7 @@ IntegralImage2D::computeIntegralImages ( { ElementType* previous_row = &first_order_integral_image_[0]; ElementType* current_row = previous_row + (width_ + 1); - memset (previous_row, 0, sizeof (ElementType) * (width_ + 1)); + *previous_row = ElementType::Zero(width_ + 1); unsigned* count_previous_row = &finite_values_integral_image_[0]; unsigned* count_current_row = count_previous_row + (width_ + 1); @@ -189,7 +189,7 @@ IntegralImage2D::computeIntegralImages ( { SecondOrderType* so_previous_row = &second_order_integral_image_[0]; SecondOrderType* so_current_row = so_previous_row + (width_ + 1); - memset (so_previous_row, 0, sizeof (SecondOrderType) * (width_ + 1)); + *so_previous_row = SecondOrderType::Zero(width_ + 1); SecondOrderType so_element; for (unsigned rowIdx = 0; rowIdx < height_; ++rowIdx, data += row_stride, diff --git a/gpu/CMakeLists.txt b/gpu/CMakeLists.txt index 99f36bf6405..45daad5c6ef 100644 --- a/gpu/CMakeLists.txt +++ b/gpu/CMakeLists.txt @@ -11,7 +11,11 @@ endif() if(CMAKE_COMPILER_IS_GNUCXX) string(REPLACE "-Wold-style-cast" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "-Wno-invalid-offsetof" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable") + string(APPEND CMAKE_CXX_FLAGS " -Wno-conversion -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable") + # allow deprecation warnings in Eigen(3.3.7)/Core, see here: https://gitlab.kitware.com/vtk/vtk/-/issues/17661 + string(APPEND CMAKE_CXX_FLAGS " -Wno-error=cpp") + # allow maybe-uninitialized warnings from thrust library. + string(APPEND CMAKE_CXX_FLAGS " -Wno-error=maybe-uninitialized") endif() collect_subproject_directory_names("${CMAKE_CURRENT_SOURCE_DIR}" "CMakeLists.txt" PCL_GPU_MODULES_NAMES PCL_GPU_MODULES_DIRS) diff --git a/outofcore/CMakeLists.txt b/outofcore/CMakeLists.txt index 5860204bf5f..7d8073c2547 100644 --- a/outofcore/CMakeLists.txt +++ b/outofcore/CMakeLists.txt @@ -58,6 +58,15 @@ set(visualization_incs "include/pcl/${SUBSYS_NAME}/visualization/scene.h" "include/pcl/${SUBSYS_NAME}/visualization/viewport.h" ) + +# Code in subdirectory `visualization` may use deprecated declarations when using OpenGLv1 +# Add the GCC exclusive rules for -Werror only for OpenGLv1 compile to avoid build interruption +if(VTK_RENDERING_BACKEND_OPENGL_VERSION VERSION_LESS 2) + if(CMAKE_COMPILER_IS_GNUCXX) + add_compile_options("-Wno-error=deprecated-declarations") + endif() +endif() + set(LIB_NAME "pcl_${SUBSYS_NAME}") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/surface/CMakeLists.txt b/surface/CMakeLists.txt index eae2d3ae011..d8a8566ea3b 100644 --- a/surface/CMakeLists.txt +++ b/surface/CMakeLists.txt @@ -49,6 +49,21 @@ endif() set(BUILD_surface_on_nurbs 0 CACHE BOOL "Fitting NURBS to point-clouds using openNURBS") if(BUILD_surface_on_nurbs) + # Add the GCC exclusive rules for -Werror only for 3rd party OpenNURBS compile + # -Wno-error = (deprecated-declarations, class-memaccess, deprecated-copy, uninitialized, parentheses) + # Note: class-memaccess warning added exactly in GCC 8.0, see here: https://www.gnu.org/software/gcc/gcc-8/changes.html + # deprecated-copy warning added exactly in GCC 9.1, see here: https://www.gnu.org/software/gcc/gcc-9/changes.html + # Since GCC8 and GCC9 are still widely-used, compile version check is required for the two options. + if(CMAKE_COMPILER_IS_GNUCXX) + add_compile_options("-Wno-error=deprecated-declarations" "-Wno-error=uninitialized" "-Wno-error=parentheses") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) + add_compile_options("-Wno-error=class-memaccess") + endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.1) + add_compile_options("-Wno-error=deprecated-copy") + endif() + endif() + include(src/3rdparty/opennurbs/openNURBS.cmake) include(src/on_nurbs/on_nurbs.cmake) endif() diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index 3d911b7a0a4..b8cbb5f14fd 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -214,15 +214,14 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto } int num_vertices = qh num_vertices; - hull.resize (num_vertices); - memset (&hull.points[0], hull.size (), sizeof (PointInT)); + + hull.clear(); + hull.resize(num_vertices, PointInT{}); vertexT * vertex; int i = 0; - std::vector, Eigen::aligned_allocator > > idx_points (num_vertices); - idx_points.resize (hull.size ()); - memset (&idx_points[0], hull.size (), sizeof (std::pair)); + AlignedVector> idx_points (num_vertices); FORALLvertices { diff --git a/test/common/test_common.cpp b/test/common/test_common.cpp index 964bf2b0984..5829090bda6 100644 --- a/test/common/test_common.cpp +++ b/test/common/test_common.cpp @@ -503,7 +503,7 @@ TEST (PCL, computeMedian) EXPECT_EQ(median1, 3.5f); std::vector vector2{1.0, 25.0, 9.0, 4.0, 16.0}; - const auto median2 = computeMedian (vector2.begin (), vector2.end (), static_cast(std::sqrt)); + const auto median2 = computeMedian (vector2.begin (), vector2.end (), [](const double& x){ return std::sqrt(x); }); EXPECT_EQ(median2, 3.0); std::vector vector3{1.0, 2.0, 6.0, 5.0, 4.0, 3.0}; diff --git a/test/gpu/octree/perfomance.cpp b/test/gpu/octree/perfomance.cpp index 4e80d32d8d9..d8cbc40b178 100644 --- a/test/gpu/octree/perfomance.cpp +++ b/test/gpu/octree/perfomance.cpp @@ -223,8 +223,9 @@ TEST(PCL_OctreeGPU, performance) std::cout << "====== Approx nearest search =====" << std::endl; { - ScopeTime up("gpu-approx-nearest-batch-all"); - octree_device.approxNearestSearch(queries_device, result_device); + ScopeTime up("gpu-approx-nearest-batch-all"); + pcl::gpu::Octree::ResultSqrDists sqr_distance; + octree_device.approxNearestSearch(queries_device, result_device, sqr_distance); } { diff --git a/visualization/CMakeLists.txt b/visualization/CMakeLists.txt index ed2c4ca1b99..e676a202599 100644 --- a/visualization/CMakeLists.txt +++ b/visualization/CMakeLists.txt @@ -61,6 +61,12 @@ if(VTK_RENDERING_BACKEND_OPENGL_VERSION VERSION_LESS 2) "src/vtk/vtkVertexBufferObject.cxx" "src/vtk/vtkVertexBufferObjectMapper.cxx" ) + + # Code in this module may use deprecated declarations when using OpenGLv1 + # Add the GCC exclusive rules for -Werror only for OpenGLv1 compile to avoid build interruption + if(CMAKE_COMPILER_IS_GNUCXX) + add_compile_options("-Wno-error=deprecated-declarations") + endif() endif() if(NOT (${VTK_VERSION} VERSION_LESS 9.0)) From 11ab21b71c8e9fd3e35d86143743b35aaa6dcc71 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 18 Apr 2021 19:58:07 +0200 Subject: [PATCH 135/431] Add more output for sac test that sometimes fails --- test/sample_consensus/test_sample_consensus.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/sample_consensus/test_sample_consensus.cpp b/test/sample_consensus/test_sample_consensus.cpp index e81a8e3ae6c..5d56c571cb6 100644 --- a/test/sample_consensus/test_sample_consensus.cpp +++ b/test/sample_consensus/test_sample_consensus.cpp @@ -110,6 +110,16 @@ TYPED_TEST(SacTest, InfiniteLoop) SampleConsensusModelSpherePtr model (new SampleConsensusModelSphere (cloud.makeShared ())); TypeParam sac (model, 0.03); + // This test sometimes fails for LMedS on azure, but always passes when run locally. + // Enable all output for LMedS, so that when it fails next time, we hopefully see why. + // This can be removed again when the failure reason is found and fixed. + int debug_verbosity_level = 0; + const auto previous_verbosity_level = pcl::console::getVerbosityLevel(); + if (std::is_same>::value) { + debug_verbosity_level = 2; + pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE); + } + // Set up timed conditions std::condition_variable cv; std::mutex mtx; @@ -117,7 +127,7 @@ TYPED_TEST(SacTest, InfiniteLoop) // Create the RANSAC object std::thread thread ([&] () { - sac.computeModel (0); + sac.computeModel (debug_verbosity_level); // Notify things are done std::lock_guard lock (mtx); @@ -135,6 +145,8 @@ TYPED_TEST(SacTest, InfiniteLoop) // release lock to avoid deadlock lock.unlock(); thread.join (); + + pcl::console::setVerbosityLevel(previous_verbosity_level); // reset verbosity level } int From 28320f56ca66a44182666d43fc025957bfd36f47 Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 18 Apr 2021 20:55:44 +0200 Subject: [PATCH 136/431] Improve test_organized_index - do not use geometry::distance. That is (partly) optimized for speed, but for the tests, accuracy is most important. Use custom point_distance function instead - store random seed and print it with SCOPED_TRACE, so that tests are reproducible --- test/search/test_organized_index.cpp | 48 +++++++++++++++++++--------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/test/search/test_organized_index.cpp b/test/search/test_organized_index.cpp index 2a5c3c56494..683e7476958 100644 --- a/test/search/test_organized_index.cpp +++ b/test/search/test_organized_index.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,16 @@ using namespace pcl; std::string pcd_filename; +// Here we want a very precise distance function, speed is less important. So we use +// double precision, unlike euclideanDistance() in pcl/common/distances and distance() +// in pcl/common/geometry which use float (single precision) and possibly vectorization +template inline double +point_distance(const PointT& p1, const PointT& p2) +{ + const double x_diff = p1.x - p2.x, y_diff = p1.y - p2.y, z_diff = p1.z - p2.z; + return std::sqrt(x_diff * x_diff + y_diff * y_diff + z_diff * z_diff); +} + // helper class for priority queue class prioPointQueueEntry { @@ -79,7 +88,9 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search) // instantiate point cloud PointCloud::Ptr cloudIn (new PointCloud ()); - srand (time (NULL)); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); // create organized search search::OrganizedNeighbor organizedNeighborSearch; @@ -135,7 +146,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search) for (auto it = cloudIn->begin(); it != cloudIn->end(); ++it) { - const auto pointDist = geometry::distance(*it, searchPoint); + const auto pointDist = point_distance(*it, searchPoint); prioPointQueueEntry pointEntry (*it, pointDist, std::distance(cloudIn->begin(), it)); pointCandidates.push (pointEntry); } @@ -174,7 +185,9 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search_Kinec // instantiate point cloud - srand (time (NULL)); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); // create organized search search::OrganizedNeighbor organizedNeighborSearch; @@ -226,7 +239,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Nearest_K_Neighbour_Search_Kinec // push all points and their distance to the search point into a priority queue - bruteforce approach. for (auto it = cloudIn->begin(); it != cloudIn->end(); ++it) { - const auto pointDist = geometry::distance(*it, searchPoint); + const auto pointDist = point_distance(*it, searchPoint); prioPointQueueEntry pointEntry (*it, pointDist, std::distance(cloudIn->begin(), it)); pointCandidates.push (pointEntry); } @@ -251,7 +264,9 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) { constexpr unsigned int test_runs = 10; - srand (time (NULL)); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); search::OrganizedNeighbor organizedNeighborSearch; std::vector k_indices; @@ -299,7 +314,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) for (auto it = cloudIn->points.cbegin(); it != cloudIn->points.cend(); ++it) { - const auto pointDist = geometry::distance(*it, searchPoint); + const auto pointDist = point_distance(*it, searchPoint); if (pointDist <= searchRadius) { @@ -319,7 +334,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) // check if result from organized radius search can be also found in bruteforce search for (const auto it : cloudNWRSearch) { - auto const pointDist = geometry::distance((*cloudIn)[it], searchPoint); + const auto pointDist = point_distance((*cloudIn)[it], searchPoint); ASSERT_LE (pointDist, searchRadius); } @@ -327,7 +342,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) // check if bruteforce result from organized radius search can be also found in bruteforce search for (const auto it : cloudSearchBruteforce) { - const auto pointDist = geometry::distance((*cloudIn)[it], searchPoint); + const auto pointDist = point_distance((*cloudIn)[it], searchPoint); ASSERT_LE (pointDist, searchRadius); } @@ -344,7 +359,8 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search) TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_Benchmark_Test) { constexpr unsigned int test_runs = 10; - srand (time (NULL)); + const unsigned int seed = time (nullptr); + srand (seed); search::OrganizedNeighbor organizedNeighborSearch; @@ -396,7 +412,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ for (auto it = cloudIn->points.cbegin(); it != cloudIn->points.cend(); ++it) { - const auto pointDist = geometry::distance(*it, searchPoint); + const auto pointDist = point_distance(*it, searchPoint); if (pointDist <= searchRadius) { @@ -436,7 +452,9 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ return; } constexpr unsigned int test_runs = 10; - srand (time (NULL)); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); search::OrganizedNeighbor organizedNeighborSearch; @@ -510,7 +528,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ for (auto it = cloudIn->points.cbegin(); it != cloudIn->points.cend(); ++it) { - const auto pointDist = geometry::distance(*it, searchPoint); + const auto pointDist = point_distance(*it, searchPoint); if (pointDist <= searchRadius) { @@ -522,7 +540,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ // check if result from organized radius search can be also found in bruteforce search for (const auto it : cloudNWRSearch) { - double pointDist = geometry::distance((*cloudIn)[it], searchPoint); + const auto pointDist = point_distance((*cloudIn)[it], searchPoint); ASSERT_LE (pointDist, searchRadius); } @@ -530,7 +548,7 @@ TEST (PCL, Organized_Neighbor_Search_Pointcloud_Neighbours_Within_Radius_Search_ // check if bruteforce result from organized radius search can be also found in bruteforce search for (const auto it : cloudSearchBruteforce) { - double pointDist = geometry::distance((*cloudIn)[it], searchPoint); + const auto pointDist = point_distance((*cloudIn)[it], searchPoint); ASSERT_LE (pointDist, searchRadius); } From 75f06c3d37e86816d0370b5b15ebc8c5f8e089bb Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Mon, 26 Apr 2021 20:43:36 +0200 Subject: [PATCH 137/431] Add SCOPED_TRACE to more tests --- test/search/test_octree.cpp | 12 +++++++++--- test/search/test_organized.cpp | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/search/test_octree.cpp b/test/search/test_octree.cpp index 215d9186951..54159107274 100644 --- a/test/search/test_octree.cpp +++ b/test/search/test_octree.cpp @@ -76,7 +76,9 @@ TEST (PCL, Octree_Pointcloud_Nearest_K_Neighbour_Search) // instantiate point cloud PointCloud::Ptr cloudIn (new PointCloud ()); - srand (static_cast (time (nullptr))); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); std::priority_queue::VectorType> pointCandidates; @@ -173,7 +175,9 @@ TEST (PCL, Octree_Pointcloud_Approx_Nearest_Neighbour_Search) // instantiate point cloud PointCloud::Ptr cloudIn (new PointCloud ()); - srand (time (NULL)); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); double voxelResolution = 0.1; @@ -275,7 +279,9 @@ TEST (PCL, Octree_Pointcloud_Neighbours_Within_Radius_Search) PointCloud::Ptr cloudIn (new PointCloud ()); PointCloud::Ptr cloudOut (new PointCloud ()); - srand (static_cast (time (nullptr))); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); for (unsigned int test_id = 0; test_id < test_runs; test_id++) { diff --git a/test/search/test_organized.cpp b/test/search/test_organized.cpp index ae2dcb4697c..c974b3e7179 100644 --- a/test/search/test_organized.cpp +++ b/test/search/test_organized.cpp @@ -79,7 +79,9 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Nearest_K_Neighbour_Search) // instantiate point cloud PointCloud::Ptr cloudIn (new PointCloud ()); - srand (int (time (nullptr))); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); // create organized search search::OrganizedNeighbor organizedNeighborSearch; @@ -180,7 +182,9 @@ TEST (PCL, Organized_Neighbor_Pointcloud_Neighbours_Within_Radius_Search) { constexpr unsigned int test_runs = 10; - srand (int (time (nullptr))); + const unsigned int seed = time (nullptr); + srand (seed); + SCOPED_TRACE("seed=" + std::to_string(seed)); search::OrganizedNeighbor organizedNeighborSearch; From 10190eb94701205485d07bde5e0c1f03ddf12a6a Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Fri, 30 Apr 2021 18:46:47 +0200 Subject: [PATCH 138/431] Add more output to (k)fpcs test --- registration/include/pcl/registration/impl/ia_fpcs.hpp | 9 +++++++-- test/registration/test_kfpcs_ia.cpp | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/registration/include/pcl/registration/impl/ia_fpcs.hpp b/registration/include/pcl/registration/impl/ia_fpcs.hpp index 61f610523b9..d089c8a0bca 100644 --- a/registration/include/pcl/registration/impl/ia_fpcs.hpp +++ b/registration/include/pcl/registration/impl/ia_fpcs.hpp @@ -178,7 +178,10 @@ pcl::registration::FPCSInitialAlignment(std::time(NULL)) ^ omp_get_thread_num()); + const unsigned int seed = + static_cast(std::time(NULL)) ^ omp_get_thread_num(); + std::srand(seed); + PCL_DEBUG("[%s::computeTransformation] Using seed=%u\n", reg_name_.c_str(), seed); #pragma omp for schedule(dynamic) #endif for (int i = 0; i < max_iterations_; i++) { @@ -236,7 +239,9 @@ bool pcl::registration::FPCSInitialAlignment:: initCompute() { - std::srand(static_cast(std::time(nullptr))); + const unsigned int seed = std::time(nullptr); + std::srand(seed); + PCL_DEBUG("[%s::initCompute] Using seed=%u\n", reg_name_.c_str(), seed); // basic pcl initialization if (!pcl::PCLBase::initCompute()) diff --git a/test/registration/test_kfpcs_ia.cpp b/test/registration/test_kfpcs_ia.cpp index 81cda560b03..3fe305164d5 100644 --- a/test/registration/test_kfpcs_ia.cpp +++ b/test/registration/test_kfpcs_ia.cpp @@ -52,6 +52,8 @@ PointCloud cloud_source, cloud_target; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TEST (PCL, KFPCSInitialAlignment) { + const auto previous_verbosity_level = pcl::console::getVerbosityLevel(); + pcl::console::setVerbosityLevel(pcl::console::L_VERBOSE); // create shared pointers PointCloud::Ptr cloud_source_ptr, cloud_target_ptr; cloud_source_ptr = cloud_source.makeShared (); @@ -93,6 +95,7 @@ TEST (PCL, KFPCSInitialAlignment) EXPECT_EQ (cloud_source_aligned.size (), cloud_source.size ()); EXPECT_NEAR (angle3d, 0.f, max_angle3d); EXPECT_NEAR (translation3d, 0.f, max_translation3d); + pcl::console::setVerbosityLevel(previous_verbosity_level); // reset verbosity level } From db76e0c5f627acdacf9b7a0422342ebe89ae8eee Mon Sep 17 00:00:00 2001 From: Kosmas Tsiakas Date: Fri, 7 May 2021 17:06:32 +0300 Subject: [PATCH 139/431] Fix typo in kdtree_search.cpp tutorial source (#1) NKN changed to KNN. --- .../sources/kdtree_search/kdtree_search.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp b/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp index d2b99cfa2ef..c53e3f5f268 100644 --- a/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp +++ b/doc/tutorials/content/sources/kdtree_search/kdtree_search.cpp @@ -38,21 +38,21 @@ main () int K = 10; - std::vector pointIdxNKNSearch(K); - std::vector pointNKNSquaredDistance(K); + std::vector pointIdxKNNSearch(K); + std::vector pointKNNSquaredDistance(K); std::cout << "K nearest neighbor search at (" << searchPoint.x << " " << searchPoint.y << " " << searchPoint.z << ") with K=" << K << std::endl; - if ( kdtree.nearestKSearch (searchPoint, K, pointIdxNKNSearch, pointNKNSquaredDistance) > 0 ) + if ( kdtree.nearestKSearch (searchPoint, K, pointIdxKNNSearch, pointKNNSquaredDistance) > 0 ) { - for (std::size_t i = 0; i < pointIdxNKNSearch.size (); ++i) - std::cout << " " << (*cloud)[ pointIdxNKNSearch[i] ].x - << " " << (*cloud)[ pointIdxNKNSearch[i] ].y - << " " << (*cloud)[ pointIdxNKNSearch[i] ].z - << " (squared distance: " << pointNKNSquaredDistance[i] << ")" << std::endl; + for (std::size_t i = 0; i < pointIdxKNNSearch.size (); ++i) + std::cout << " " << (*cloud)[ pointIdxKNNSearch[i] ].x + << " " << (*cloud)[ pointIdxKNNSearch[i] ].y + << " " << (*cloud)[ pointIdxKNNSearch[i] ].z + << " (squared distance: " << pointKNNSquaredDistance[i] << ")" << std::endl; } // Neighbors within radius search From a380379f282ce8f762a973b1df7c4d54e6a418ac Mon Sep 17 00:00:00 2001 From: Jacob Seibert Date: Fri, 7 May 2021 20:07:17 +0200 Subject: [PATCH 140/431] Fix missing verb in sample_consensus doc --- doc/tutorials/content/walkthrough.rst | 2 +- sample_consensus/sample_consensus.doxy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/tutorials/content/walkthrough.rst b/doc/tutorials/content/walkthrough.rst index 8f3a9baa6c8..03ea403e3b2 100644 --- a/doc/tutorials/content/walkthrough.rst +++ b/doc/tutorials/content/walkthrough.rst @@ -376,7 +376,7 @@ Sample Consensus **Background** - The *sample_consensus* library holds SAmple Consensus (SAC) methods like RANSAC and models like planes and cylinders. These can combined freely in order to detect specific models and their parameters in point clouds. + The *sample_consensus* library holds SAmple Consensus (SAC) methods like RANSAC and models like planes and cylinders. These can be combined freely in order to detect specific models and their parameters in point clouds. A theoretical primer explaining how sample consensus algorithms work can be found in the `Random Sample Consensus tutorial `_ diff --git a/sample_consensus/sample_consensus.doxy b/sample_consensus/sample_consensus.doxy index aeaf62d401b..a73462a99ca 100644 --- a/sample_consensus/sample_consensus.doxy +++ b/sample_consensus/sample_consensus.doxy @@ -4,7 +4,7 @@ \section secSampleConsensusPresentation Overview The pcl_sample_consensus library holds SAmple Consensus (SAC) methods like - RANSAC and models like planes and cylinders. These can + RANSAC and models like planes and cylinders. These can be combined freely in order to detect specific models and their parameters in point clouds. Some of the models implemented in this library include: lines, planes, cylinders, and spheres. Plane fitting From 52c3d73fc1ea3c65bbccdd5db066314d510e65cf Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Wed, 25 Nov 2020 12:38:33 +0100 Subject: [PATCH 141/431] Fix ensenso_grabber --- io/src/ensenso_grabber.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/io/src/ensenso_grabber.cpp b/io/src/ensenso_grabber.cpp index 06cdabadf49..53263e8a469 100644 --- a/io/src/ensenso_grabber.cpp +++ b/io/src/ensenso_grabber.cpp @@ -123,9 +123,17 @@ pcl::EnsensoGrabber::enumDevices () const for (int n = 0; n < cams.count (); ++n) { +#if NXLIB_VERSION_MAJOR > 2 PCL_INFO ("%s %s %s\n", cams[n][itmSerialNumber].asString ().c_str (), cams[n][itmModelName].asString ().c_str (), - cams[n][itmStatus].asString ().c_str ()); + cams[n][itmStatus][itmOpen].asBool() + ? "Open" + : (cams[n][itmStatus][itmAvailable].asBool() ? "Available" : "In Use")); +#else + PCL_INFO ("%s %s %s\n", cams[n][itmSerialNumber].asString().c_str(), + cams[n][itmModelName].asString().c_str(), + cams[n][itmStatus].asString().c_str()); +#endif } PCL_INFO ("\n"); } From 84b7abfcc9c8dc5c8a6840420983e3ca4f159e4d Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Sun, 9 May 2021 11:19:36 +0200 Subject: [PATCH 142/431] Remove definition of QT_NO_DEBUG as it will be automatically set since Qt 5.1.1 --- apps/cloud_composer/ComposerTool.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/cloud_composer/ComposerTool.cmake b/apps/cloud_composer/ComposerTool.cmake index cfef108043d..fc92006faaa 100644 --- a/apps/cloud_composer/ComposerTool.cmake +++ b/apps/cloud_composer/ComposerTool.cmake @@ -16,7 +16,6 @@ function(define_composer_tool TOOL_NAME TOOL_SOURCES TOOL_HEADERS DEPS) endif() add_definitions(${QT_DEFINITIONS}) add_definitions(-DQT_PLUGIN) - target_compile_definitions(${TOOL_TARGET} PUBLIC $<$:-DQT_NO_DEBUG>) add_definitions(-DQT_SHARED) target_link_libraries(${TOOL_TARGET} pcl_cc_tool_interface pcl_common pcl_io ${DEPS} Qt5::Widgets) From 82f4f07da04769058ff54a916ea6eb5a335439b3 Mon Sep 17 00:00:00 2001 From: Heiko Thiel Date: Sun, 9 May 2021 23:03:34 +0200 Subject: [PATCH 143/431] Fix compile issue due to missing include under MSVC 2019 --- .../include/pcl/outofcore/outofcore_breadth_first_iterator.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/outofcore/include/pcl/outofcore/outofcore_breadth_first_iterator.h b/outofcore/include/pcl/outofcore/outofcore_breadth_first_iterator.h index 86d84297570..14efd5a1ae0 100644 --- a/outofcore/include/pcl/outofcore/outofcore_breadth_first_iterator.h +++ b/outofcore/include/pcl/outofcore/outofcore_breadth_first_iterator.h @@ -39,6 +39,9 @@ #pragma once #include + +#include + namespace pcl { namespace outofcore From 77c27c35e14e3e2a753d97639eb591336a8c6ce6 Mon Sep 17 00:00:00 2001 From: Hang Yan Date: Tue, 11 May 2021 20:17:54 +0800 Subject: [PATCH 144/431] Use range-based for & `std::find` to modernize codes in `segmentation` (#4738) Co-authored-by: Lars Glud --- .../pcl/segmentation/extract_clusters.h | 8 +-- .../pcl/segmentation/impl/region_growing.hpp | 19 +++---- .../segmentation/impl/region_growing_rgb.hpp | 50 +++++++------------ .../segmentation/impl/unary_classifier.hpp | 15 +++--- 4 files changed, 34 insertions(+), 58 deletions(-) diff --git a/segmentation/include/pcl/segmentation/extract_clusters.h b/segmentation/include/pcl/segmentation/extract_clusters.h index 6e4b2108158..d7234ade46f 100644 --- a/segmentation/include/pcl/segmentation/extract_clusters.h +++ b/segmentation/include/pcl/segmentation/extract_clusters.h @@ -251,16 +251,16 @@ namespace pcl Indices nn_indices; std::vector nn_distances; // Process all points in the indices vector - for (std::size_t i = 0; i < indices.size (); ++i) + for (const auto& point_idx : indices) { - if (processed[indices[i]]) + if (processed[point_idx]) continue; Indices seed_queue; int sq_idx = 0; - seed_queue.push_back (indices[i]); + seed_queue.push_back (point_idx); - processed[indices[i]] = true; + processed[point_idx] = true; while (sq_idx < static_cast (seed_queue.size ())) { diff --git a/segmentation/include/pcl/segmentation/impl/region_growing.hpp b/segmentation/include/pcl/segmentation/impl/region_growing.hpp index b14c5b42f5d..d4787ab94e5 100644 --- a/segmentation/include/pcl/segmentation/impl/region_growing.hpp +++ b/segmentation/include/pcl/segmentation/impl/region_growing.hpp @@ -611,20 +611,13 @@ pcl::RegionGrowing::getSegmentFromPoint (pcl::index_t index, pc // to which this point belongs for (const auto& i_segment : clusters_) { - bool segment_was_found = false; - for (const auto& i_point : (i_segment.indices)) - { - if (i_point == index) - { - segment_was_found = true; - cluster.indices.clear (); - cluster.indices.reserve (i_segment.indices.size ()); - std::copy (i_segment.indices.begin (), i_segment.indices.end (), std::back_inserter (cluster.indices)); - break; - } - } - if (segment_was_found) + const auto it = std::find (i_segment.indices.cbegin (), i_segment.indices.cend (), index); + if (it != i_segment.indices.cend()) { + // if segment was found + cluster.indices.clear (); + cluster.indices.reserve (i_segment.indices.size ()); + std::copy (i_segment.indices.begin (), i_segment.indices.end (), std::back_inserter (cluster.indices)); break; } }// next segment diff --git a/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp b/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp index 718c5e96ce9..8d6520a5a2e 100644 --- a/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp +++ b/segmentation/include/pcl/segmentation/impl/region_growing_rgb.hpp @@ -482,24 +482,19 @@ pcl::RegionGrowingRGB::applyRegionMergingAlgorithm () num_seg_in_homogeneous_region[i_reg] = 0; final_segment_number -= 1; - int nghbr_number = static_cast (region_neighbours[reg_index].size ()); - for (int i_nghbr = 0; i_nghbr < nghbr_number; i_nghbr++) + for (auto& nghbr : region_neighbours[reg_index]) { - if ( segment_labels_[ region_neighbours[reg_index][i_nghbr].second ] == reg_index ) + if ( segment_labels_[ nghbr.second ] == reg_index ) { - region_neighbours[reg_index][i_nghbr].first = std::numeric_limits::max (); - region_neighbours[reg_index][i_nghbr].second = 0; + nghbr.first = std::numeric_limits::max (); + nghbr.second = 0; } } - nghbr_number = static_cast (region_neighbours[i_reg].size ()); - for (int i_nghbr = 0; i_nghbr < nghbr_number; i_nghbr++) + for (const auto& nghbr : region_neighbours[i_reg]) { - if ( segment_labels_[ region_neighbours[i_reg][i_nghbr].second ] != reg_index ) + if ( segment_labels_[ nghbr.second ] != reg_index ) { - std::pair pair; - pair.first = region_neighbours[i_reg][i_nghbr].first; - pair.second = region_neighbours[i_reg][i_nghbr].second; - region_neighbours[reg_index].push_back (pair); + region_neighbours[reg_index].push_back (nghbr); } } region_neighbours[i_reg].clear (); @@ -533,11 +528,9 @@ pcl::RegionGrowingRGB::findRegionNeighbours (std::vector< std:: for (int i_reg = 0; i_reg < region_number; i_reg++) { - int segment_num = static_cast (regions_in[i_reg].size ()); - neighbours_out[i_reg].reserve (segment_num * region_neighbour_number_); - for (int i_seg = 0; i_seg < segment_num; i_seg++) + neighbours_out[i_reg].reserve (regions_in[i_reg].size () * region_neighbour_number_); + for (const auto& curr_segment : regions_in[i_reg]) { - int curr_segment = regions_in[i_reg][i_seg]; int nghbr_number = static_cast (segment_neighbours_[curr_segment].size ()); std::pair pair; for (int i_nghbr = 0; i_nghbr < nghbr_number; i_nghbr++) @@ -571,10 +564,8 @@ pcl::RegionGrowingRGB::assembleRegions (std::vector counter; counter.resize (num_regions, 0); - int point_number = static_cast (indices_->size ()); - for (int i_point = 0; i_point < point_number; i_point++) + for (const auto& point_index : (*indices_)) { - int point_index = (*indices_)[i_point]; int index = point_labels_[point_index]; index = segment_labels_[index]; clusters_[index].indices[ counter[index] ] = point_index; @@ -735,22 +726,15 @@ pcl::RegionGrowingRGB::getSegmentFromPoint (pcl::index_t index, } // if we have already made the segmentation, then find the segment // to which this point belongs - for (auto i_segment = clusters_.cbegin (); i_segment != clusters_.cend (); i_segment++) + for (const auto& i_segment : clusters_) { - bool segment_was_found = false; - for (std::size_t i_point = 0; i_point < i_segment->indices.size (); i_point++) - { - if (i_segment->indices[i_point] == index) - { - segment_was_found = true; - cluster.indices.clear (); - cluster.indices.reserve (i_segment->indices.size ()); - std::copy (i_segment->indices.begin (), i_segment->indices.end (), std::back_inserter (cluster.indices)); - break; - } - } - if (segment_was_found) + const auto it = std::find (i_segment.indices.cbegin (), i_segment.indices.cend (), index); + if (it != i_segment.indices.cend()) { + // if segment was found + cluster.indices.clear (); + cluster.indices.reserve (i_segment.indices.size ()); + std::copy (i_segment.indices.begin (), i_segment.indices.end (), std::back_inserter (cluster.indices)); break; } }// next segment diff --git a/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp b/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp index 133d27d28fd..354956f02ba 100644 --- a/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp +++ b/segmentation/include/pcl/segmentation/impl/unary_classifier.hpp @@ -174,25 +174,24 @@ pcl::UnaryClassifier::getCloudWithLabel (typename pcl::PointCloud fields; int label_idx = -1; - pcl::PointCloud point; label_idx = pcl::getFieldIndex ("label", fields); if (label_idx != -1) { - for (std::size_t i = 0; i < in->size (); i++) + for (const auto& point : (*in)) { // get the 'label' field std::uint32_t label; - memcpy (&label, reinterpret_cast (&(*in)[i]) + fields[label_idx].offset, sizeof(std::uint32_t)); + memcpy (&label, reinterpret_cast (&point) + fields[label_idx].offset, sizeof(std::uint32_t)); if (static_cast (label) == label_num) { - pcl::PointXYZ point; + pcl::PointXYZ tmp; // X Y Z - point.x = (*in)[i].x; - point.y = (*in)[i].y; - point.z = (*in)[i].z; - out->points.push_back (point); + tmp.x = point.x; + tmp.y = point.y; + tmp.z = point.z; + out->push_back (tmp); } } out->width = out->size (); From 270e05128b5915057dc1cfd93ab2304051960a20 Mon Sep 17 00:00:00 2001 From: Markus Vieth <39675748+mvieth@users.noreply.github.com> Date: Wed, 12 May 2021 10:30:57 +0200 Subject: [PATCH 145/431] Add formal documentation of PCD binary_compressed format (#4753) --- doc/tutorials/content/pcd_file_format.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/tutorials/content/pcd_file_format.rst b/doc/tutorials/content/pcd_file_format.rst index 210b37becf9..688da23b86f 100644 --- a/doc/tutorials/content/pcd_file_format.rst +++ b/doc/tutorials/content/pcd_file_format.rst @@ -151,7 +151,7 @@ As of version 0.7, the PCD header contains the following entries: * **DATA** - specifies the data type that the point cloud data is stored in. As - of version 0.7, two data types are supported: *ascii* and *binary*. See the + of version 0.7, three data types are supported: *ascii*, *binary*, and *binary_compressed*. See the next section for more details. @@ -178,7 +178,7 @@ As of version 0.7, the PCD header contains the following entries: Data storage types ------------------ -As of version 0.7, the **.PCD** file format uses two different modes for storing data: +As of version 0.7, the **.PCD** file format uses three different modes for storing data: * in **ASCII** form, with each point on a new line:: @@ -198,6 +198,8 @@ As of version 0.7, the **.PCD** file format uses two different modes for storing `pcl::PointCloud.points` array/vector. On Linux systems, we use `mmap`/`munmap` operations for the fastest possible read/write access to the data. +* in **binary_compressed** form. The body (everything after the header) starts with a 32 bit unsigned binary number which specifies the size in bytes of the data in *compressed* form. Next is another 32 bit unsigned binary number which specifies the size in bytes of the data in *uncompressed* form. Then follows the compressed data. The compression and decompression is done using Marc Lehmann's LZF algorithm. It is mediocre in terms of size reduction, but very fast. For typical point clouds, the compressed data has 30 to 60 percent of the original size. Before compressing, the data is reordered to improve compression, from the standard array-of-structures layout to a structure-of-arrays layout. So for example a cloud with three points and fields x, y, z would be reordered from xyzxyzxyz to xxxyyyzzz. + Storing point cloud data in both a simple ascii form with each point on a line, space or tab separated, without any other characters on it, as well as in a From 1ae76606d5cc266af282241f4a023372626eb604 Mon Sep 17 00:00:00 2001 From: "Taehong Jeong (Hugh)" Date: Fri, 14 May 2021 04:27:02 +0900 Subject: [PATCH 146/431] Fix `PolygonMesh::concatenate` and its unit test (#4745) * Update PolygonMesh.h * Update test_polygon_mesh.cpp ensure that each vertex id in a polygon is always in the correct range * Update test_polygon_mesh.cpp use EXPECT_EQ_VECTORS for simplicity * Update test_polygon_mesh.cpp fix for the lambda capture issue (https://dev.azure.com/PointCloudLibrary/pcl/_build/results?buildId=18956&view=logs&j=8042da28-3549-5cef-c93d-1a000d12f42a&t=118ad2c4-6739-5a83-709b-f149f9853975&l=192) * Update test_polygon_mesh.cpp - refectored to copy gnd truth for modification - added comments * Update test_polygon_mesh.cpp - moved the temp vector out of the loop - removed redundant comments * Update test_polygon_mesh.cpp - used assignment operator instead - put brackets in one-liner foreach loop Co-authored-by: duhuanxianzi --- common/include/pcl/PolygonMesh.h | 3 ++- test/common/test_polygon_mesh.cpp | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common/include/pcl/PolygonMesh.h b/common/include/pcl/PolygonMesh.h index ae610dcc34f..55d69995ade 100644 --- a/common/include/pcl/PolygonMesh.h +++ b/common/include/pcl/PolygonMesh.h @@ -30,6 +30,8 @@ namespace pcl static bool concatenate (pcl::PolygonMesh &mesh1, const pcl::PolygonMesh &mesh2) { + const auto point_offset = mesh1.cloud.width * mesh1.cloud.height; + bool success = pcl::PCLPointCloud2::concatenate(mesh1.cloud, mesh2.cloud); if (success == false) { return false; @@ -37,7 +39,6 @@ namespace pcl // Make the resultant polygon mesh take the newest stamp mesh1.header.stamp = std::max(mesh1.header.stamp, mesh2.header.stamp); - const auto point_offset = mesh1.cloud.width * mesh1.cloud.height; std::transform(mesh2.polygons.begin (), mesh2.polygons.end (), std::back_inserter (mesh1.polygons), diff --git a/test/common/test_polygon_mesh.cpp b/test/common/test_polygon_mesh.cpp index 4f2d41a218d..d03038ab192 100644 --- a/test/common/test_polygon_mesh.cpp +++ b/test/common/test_polygon_mesh.cpp @@ -91,11 +91,13 @@ TEST(PolygonMesh, concatenate_cloud) TEST(PolygonMesh, concatenate_vertices) { + const std::size_t size = 15; + PolygonMesh test, dummy; - test.cloud.width = 10; - test.cloud.height = 5; + // The algorithm works regardless of the organization. + test.cloud.width = dummy.cloud.width = size; + test.cloud.height = dummy.cloud.height = 1; - const std::size_t size = 15; for (std::size_t i = 0; i < size; ++i) { dummy.polygons.emplace_back(); @@ -111,18 +113,16 @@ TEST(PolygonMesh, concatenate_vertices) EXPECT_EQ(2 * dummy.polygons.size(), test.polygons.size()); const auto cloud_size = test.cloud.width * test.cloud.height; - for (std::size_t i = 0; i < dummy.polygons.size(); ++i) - { - EXPECT_EQ(dummy.polygons[i].vertices.size(), test.polygons[i].vertices.size()); - EXPECT_EQ(dummy.polygons[i].vertices.size(), - test.polygons[i + dummy.polygons.size()].vertices.size()); - for (std::size_t j = 0; j < size; ++j) - { - EXPECT_EQ(dummy.polygons[i].vertices[j], - test.polygons[i].vertices[j]); - EXPECT_EQ(dummy.polygons[i].vertices[j] + cloud_size, - test.polygons[i + dummy.polygons.size()].vertices[j]); - } + for (const auto& polygon : test.polygons) + for (const auto& vertex : polygon.vertices) + EXPECT_LT(vertex, cloud_size); + + pcl::Indices vertices(size); + for (std::size_t i = 0; i < size; ++i) { + vertices = dummy.polygons[i].vertices; + EXPECT_EQ_VECTORS(vertices, test.polygons[i].vertices); + for (auto& vertex : vertices) { vertex += size; } + EXPECT_EQ_VECTORS(vertices, test.polygons[i + size].vertices); } } From 5d4625033784e1ed5f42f27fb5ab2cb01032d5d7 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Thu, 26 Mar 2020 14:32:31 +0100 Subject: [PATCH 147/431] Add windows container. --- .ci/azure-pipelines/azure-pipelines.yaml | 19 +++++++++++++------ .ci/azure-pipelines/build/windows.yaml | 20 ++++---------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml index 69881c08317..6ddc39600e7 100644 --- a/.ci/azure-pipelines/azure-pipelines.yaml +++ b/.ci/azure-pipelines/azure-pipelines.yaml @@ -16,6 +16,10 @@ pr: resources: containers: + - container: winx86 + image: pointcloudlibrary/env:winx86 + - container: winx64 + image: pointcloudlibrary/env:winx64 - container: fmt image: pointcloudlibrary/fmt - container: env1804 @@ -140,24 +144,27 @@ stages: displayName: Build MSVC dependsOn: formatting jobs: - - job: vs2017 - displayName: Windows VS2017 Build + - job: Windows + displayName: Windows Build pool: - vmImage: 'vs2017-win2016' + vmImage: 'windows-2019' strategy: matrix: x86: + CONTAINER: winx86 PLATFORM: 'x86' ARCHITECTURE: 'x86' - GENERATOR: 'Visual Studio 15 2017' + GENERATOR: '"Visual Studio 16 2019" -A Win32' x64: + CONTAINER: winx64 PLATFORM: 'x64' ARCHITECTURE: 'x86_amd64' - GENERATOR: 'Visual Studio 15 2017 Win64' + GENERATOR: '"Visual Studio 16 2019" -A x64' + container: $[ variables['CONTAINER'] ] timeoutInMinutes: 0 variables: BUILD_DIR: 'c:\build' CONFIGURATION: 'Release' - VCPKG_ROOT: 'C:\vcpkg' + VCPKG_ROOT: 'c:\vcpkg' steps: - template: build/windows.yaml diff --git a/.ci/azure-pipelines/build/windows.yaml b/.ci/azure-pipelines/build/windows.yaml index 813089ce405..ab657dda4d2 100644 --- a/.ci/azure-pipelines/build/windows.yaml +++ b/.ci/azure-pipelines/build/windows.yaml @@ -2,22 +2,13 @@ steps: - checkout: self # find the commit hash on a quick non-forced update too fetchDepth: 10 - - pwsh: Get-PSDrive - displayName: "Check free space" - script: | - vcpkg.exe install eigen3 flann gtest qhull ^ - boost-date-time boost-filesystem boost-iostreams ^ - boost-property-tree boost-graph boost-interprocess ^ - boost-signals2 boost-sort boost-multi-array boost-asio ^ - boost-ptr-container ^ - --triplet %PLATFORM%-windows && vcpkg.exe list - displayName: 'Install C++ Dependencies Via Vcpkg' - - script: | - mkdir %BUILD_DIR% && cd %BUILD_DIR% + mkdir %BUILD_DIR% && cd %BUILD_DIR% && dir cmake $(Build.SourcesDirectory) ^ - -G"%GENERATOR%" ^ + -G%GENERATOR% ^ + -DVCPKG_TARGET_TRIPLET=%PLATFORM%-windows-rel ^ -DCMAKE_BUILD_TYPE="MinSizeRel" ^ - -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake ^ + -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake" ^ -DVCPKG_APPLOCAL_DEPS=ON ^ -DPCL_BUILD_WITH_BOOST_DYNAMIC_LINKING_WIN32=ON ^ -DPCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32=ON ^ @@ -26,15 +17,12 @@ steps: -DBUILD_tools=OFF ^ -DBUILD_surface_on_nurbs=ON displayName: 'CMake Configuration' - workingDirectory: 'c:' - script: | cd %BUILD_DIR% && cmake --build . --config %CONFIGURATION% displayName: 'Build Library' - workingDirectory: 'c:' - script: | cd %BUILD_DIR% && cmake --build . --target tests --config %CONFIGURATION% displayName: 'Run Unit Tests' - workingDirectory: 'c:' - task: PublishTestResults@2 inputs: testResultsFormat: 'CTest' From 76cd5c86308e6d85ebc71e74e676f78fb94d953d Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Mon, 5 Apr 2021 22:33:12 +0200 Subject: [PATCH 148/431] Enable to exlude visualization tests --- .ci/azure-pipelines/build/windows.yaml | 3 ++- cmake/pcl_options.cmake | 3 +++ test/CMakeLists.txt | 14 +++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.ci/azure-pipelines/build/windows.yaml b/.ci/azure-pipelines/build/windows.yaml index ab657dda4d2..8076d736924 100644 --- a/.ci/azure-pipelines/build/windows.yaml +++ b/.ci/azure-pipelines/build/windows.yaml @@ -15,7 +15,8 @@ steps: -DPCL_BUILD_WITH_QHULL_DYNAMIC_LINKING_WIN32=ON ^ -DBUILD_global_tests=ON ^ -DBUILD_tools=OFF ^ - -DBUILD_surface_on_nurbs=ON + -DBUILD_surface_on_nurbs=ON ^ + -DPCL_DISABLE_VISUALIZATION_TESTS=ON displayName: 'CMake Configuration' - script: | cd %BUILD_DIR% && cmake --build . --config %CONFIGURATION% diff --git a/cmake/pcl_options.cmake b/cmake/pcl_options.cmake index c8d0a6506dc..6570d75f166 100644 --- a/cmake/pcl_options.cmake +++ b/cmake/pcl_options.cmake @@ -89,3 +89,6 @@ endif() # (Used to prevent gpu tests from executing in CI where GPU hardware is unavailable) option(PCL_DISABLE_GPU_TESTS "Disable running GPU tests. If disabled, tests will still be built." OFF) +# Set whether visualizations tests should be run +# (Used to prevent visualizations tests from executing in CI where visualization is unavailable) +option(PCL_DISABLE_VISUALIZATION_TESTS "Disable running visualizations tests. If disabled, tests will still be built." OFF) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cc3043699c1..cb7f77530de 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,9 +23,21 @@ if(MSVC) set(PCL_CTEST_ARGUMENTS ${PCL_CTEST_ARGUMENTS} -C $<$:Debug>$<$:Release>) endif() +# Enables you to disable visualization tests. Used on CI. +if(PCL_DISABLE_VISUALIZATION_TESTS) + list(APPEND EXCLUDE_TESTS visualization) +endif() + # Enables you to disable GPU tests. Used on CI as it has no access to GPU hardware if(PCL_DISABLE_GPU_TESTS) - set(PCL_CTEST_ARGUMENTS ${PCL_CTEST_ARGUMENTS} -E gpu) + list(APPEND EXCLUDE_TESTS gpu) +endif() + +#Check if there are any tests to exclude +if(EXCLUDE_TESTS) + message(STATUS "Tests excluded: ${EXCLUDE_TESTS}") + string(REPLACE ";" "|" EXCLUDE_TESTS_REGEX "${EXCLUDE_TESTS}") + set(PCL_CTEST_ARGUMENTS ${PCL_CTEST_ARGUMENTS} -E "(${EXCLUDE_TESTS_REGEX})") endif() add_custom_target(tests "${CMAKE_CTEST_COMMAND}" ${PCL_CTEST_ARGUMENTS} -V -T Test VERBATIM) From 1903b0e11da7f9cf1aaae3920c57a4daaca2fc4a Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 16 May 2021 19:03:33 +0200 Subject: [PATCH 149/431] Improve explanation what PassThrough filter does in tutorials --- .../content/sources/concave_hull_2d/concave_hull_2d.cpp | 2 +- doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp | 2 +- .../sources/cylinder_segmentation/cylinder_segmentation.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp b/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp index 9293d61a0a5..8e9ee14827a 100644 --- a/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp +++ b/doc/tutorials/content/sources/concave_hull_2d/concave_hull_2d.cpp @@ -17,7 +17,7 @@ main () pcl::PCDReader reader; reader.read ("table_scene_mug_stereo_textured.pcd", *cloud); - // Build a filter to remove spurious NaNs + // Build a filter to remove spurious NaNs and scene background pcl::PassThrough pass; pass.setInputCloud (cloud); pass.setFilterFieldName ("z"); diff --git a/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp b/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp index b2118533421..e12c7d19350 100644 --- a/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp +++ b/doc/tutorials/content/sources/convex_hull_2d/convex_hull_2d.cpp @@ -15,7 +15,7 @@ int pcl::PCDReader reader; reader.read ("table_scene_mug_stereo_textured.pcd", *cloud); - // Build a filter to remove spurious NaNs + // Build a filter to remove spurious NaNs and scene background pcl::PassThrough pass; pass.setInputCloud (cloud); pass.setFilterFieldName ("z"); diff --git a/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp b/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp index 1c2f7a4b2ff..326ebc3a5e5 100644 --- a/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp +++ b/doc/tutorials/content/sources/cylinder_segmentation/cylinder_segmentation.cpp @@ -36,7 +36,7 @@ main () reader.read ("table_scene_mug_stereo_textured.pcd", *cloud); std::cerr << "PointCloud has: " << cloud->size () << " data points." << std::endl; - // Build a passthrough filter to remove spurious NaNs + // Build a passthrough filter to remove spurious NaNs and scene background pass.setInputCloud (cloud); pass.setFilterFieldName ("z"); pass.setFilterLimits (0, 1.5); From cf988ddb3636706faf330e4b137516d0fba92d5b Mon Sep 17 00:00:00 2001 From: Markus Vieth Date: Sun, 16 May 2021 20:52:40 +0200 Subject: [PATCH 150/431] Replace PassThrough with removeNaNFromPointCloud in 3 tutorials - and adapt corresponding rst files - the PassThrough was a bad choice because it removes (large) parts of the clouds that should be segmented - for region_growing_rgb_segmentation this messes up the whole tutorial - for region_growing_segmentation this would be a problem if the result of the PassThrough would not be discarded - removeNaNFromPointCloud is the right choice since it only removes the invalid points, and it still serves as an example that the segmentation classes can work with indices --- .../content/min_cut_segmentation.rst | 22 +++++++++---------- .../region_growing_rgb_segmentation.rst | 14 ++++++------ .../content/region_growing_segmentation.rst | 17 +++++++------- .../min_cut_segmentation.cpp | 8 ++----- .../region_growing_rgb_segmentation.cpp | 8 ++----- .../region_growing_segmentation.cpp | 10 +++------ 6 files changed, 33 insertions(+), 46 deletions(-) diff --git a/doc/tutorials/content/min_cut_segmentation.rst b/doc/tutorials/content/min_cut_segmentation.rst index f20774c0854..3fb1dd8823a 100644 --- a/doc/tutorials/content/min_cut_segmentation.rst +++ b/doc/tutorials/content/min_cut_segmentation.rst @@ -69,62 +69,62 @@ These lines are simply loading the cloud from the .pcd file. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 18-23 + :lines: 18-19 -This few lines are not necessary. Their only purpose is to show that ``pcl::MinCutSegmentation`` class can work with indices. +The purpose of these lines is to show that ``pcl::MinCutSegmentation`` class can work with indices. Here, only the valid points are chosen for segmentation. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 25-25 + :lines: 21-21 Here is the line where the instantiation of the ``pcl::MinCutSegmentation`` class takes place. It is the tamplate class that has only one parameter - PointT - which says what type of points will be used. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 26-27 + :lines: 22-23 These lines provide the algorithm with the cloud that must be segmented and the indices. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 29-35 + :lines: 25-31 As mentioned before, algorithm requires point that is known to be the objects center. These lines provide it. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 37-38 + :lines: 33-34 These lines set :math:`\sigma` and objects radius required for smooth cost calculation. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 39-39 + :lines: 35-35 This line tells how much neighbours to find when constructing the graph. The more neighbours is set, the more number of edges it will contain. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 40-40 + :lines: 36-36 Here is the line where foreground penalty is set. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 42-43 + :lines: 38-39 These lines are responsible for launching the algorithm. After the segmentation clusters will contain the result. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 45-45 + :lines: 41-41 You can easily access the flow value that was computed during the graph cut. This is exactly what happening here. .. literalinclude:: sources/min_cut_segmentation/min_cut_segmentation.cpp :language: cpp - :lines: 47-52 + :lines: 43-48 These lines simply create the instance of ``CloudViewer`` class for result visualization. diff --git a/doc/tutorials/content/region_growing_rgb_segmentation.rst b/doc/tutorials/content/region_growing_rgb_segmentation.rst index a32ccf6d951..bbb81c79039 100644 --- a/doc/tutorials/content/region_growing_rgb_segmentation.rst +++ b/doc/tutorials/content/region_growing_rgb_segmentation.rst @@ -39,7 +39,7 @@ They are simply loading the cloud from the .pcd file. Note that points must have .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 34-34 + :lines: 30-30 This line is responsible for ``pcl::RegionGrowingRGB`` instantiation. This class has two parameters: @@ -49,40 +49,40 @@ This line is responsible for ``pcl::RegionGrowingRGB`` instantiation. This class .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 35-37 + :lines: 31-33 These lines provide the instance with the input cloud, indices and search method. .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 38-38 + :lines: 34-34 Here the distance threshold is set. It is used to determine whether the point is neighbouring or not. If the point is located at a distance less than the given threshold, then it is considered to be neighbouring. It is used for clusters neighbours search. .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 39-39 + :lines: 35-35 This line sets the color threshold. Just as angle threshold is used for testing points normals in ``pcl::RegionGrowing`` to determine if the point belongs to cluster, this value is used for testing points colors. .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 40-40 + :lines: 36-36 Here the color threshold for clusters is set. This value is similar to the previous, but is used when the merging process takes place. .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 41-41 + :lines: 37-37 This value is similar to that which was used in the :ref:`region_growing_segmentation` tutorial. In addition to that, it is used for merging process mentioned in the beginning. If cluster has less points than was set through ``setMinClusterSize`` method, then it will be merged with the nearest neighbour. .. literalinclude:: sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp :language: cpp - :lines: 43-44 + :lines: 39-40 Here is the place where the algorithm is launched. It will return the array of clusters when the segmentation process will be over. diff --git a/doc/tutorials/content/region_growing_segmentation.rst b/doc/tutorials/content/region_growing_segmentation.rst index 65193dc009b..91c8fab370c 100644 --- a/doc/tutorials/content/region_growing_segmentation.rst +++ b/doc/tutorials/content/region_growing_segmentation.rst @@ -116,14 +116,13 @@ To learn more about how it is done you should take a look at the :ref:`normal_es .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 30-35 + :lines: 30-31 -These lines are given only for example. You can safely comment this part. Insofar as ``pcl::RegionGrowing`` is derived from ``pcl::PCLBase``, -it can work with indices. It means you can instruct that you only segment those points that are listed in the indices array instead of the whole point cloud. +Insofar as ``pcl::RegionGrowing`` is derived from ``pcl::PCLBase``, it can work with indices. It means you can instruct that you only segment those points that are listed in the indices array instead of the whole point cloud. Here, only the valid points are chosen for segmentation. .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 37-39 + :lines: 33-35 You have finally reached the part where ``pcl::RegionGrowing`` is instantiated. It is a template class that has two parameters: @@ -136,14 +135,14 @@ The default values for minimum and maximum are 1 and 'as much as possible' respe .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 40-44 + :lines: 36-40 The algorithm needs K nearest search in its internal structure, so here is the place where a search method is provided and number of neighbours is set. After that it receives the cloud that must be segmented, point indices and normals. .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 45-46 + :lines: 41-42 These two lines are the most important part in the algorithm initialization, because they are responsible for the mentioned smoothness constraint. First method sets the angle in radians that will be used as the allowable range for the normals deviation. @@ -154,20 +153,20 @@ And if this value is less than the curvature threshold then the algorithm will c .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 48-49 + :lines: 44-45 This method simply launches the segmentation algorithm. After its work it will return clusters array. .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 51-63 + :lines: 47-59 These lines are simple enough, so they won't be commented. They are intended for those who are not familiar with how to work with ``pcl::PointIndices`` and how to access its elements. .. literalinclude:: sources/region_growing_segmentation/region_growing_segmentation.cpp :language: cpp - :lines: 65-73 + :lines: 61-69 The ``pcl::RegionGrowing`` class provides a method that returns the colored cloud where each cluster has its own color. So in this part of code the ``pcl::visualization::CloudViewer`` is instantiated for viewing the result of the segmentation - the same colored cloud. diff --git a/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp b/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp index c3b23a3f378..5e4076aeb11 100644 --- a/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp +++ b/doc/tutorials/content/sources/min_cut_segmentation/min_cut_segmentation.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include // for pcl::removeNaNFromPointCloud #include int main () @@ -16,11 +16,7 @@ int main () } pcl::IndicesPtr indices (new std::vector ); - pcl::PassThrough pass; - pass.setInputCloud (cloud); - pass.setFilterFieldName ("z"); - pass.setFilterLimits (0.0, 1.0); - pass.filter (*indices); + pcl::removeNaNFromPointCloud(*cloud, *indices); pcl::MinCutSegmentation seg; seg.setInputCloud (cloud); diff --git a/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp b/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp index 1066d52a9e1..fc1196df3ec 100644 --- a/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp +++ b/doc/tutorials/content/sources/region_growing_rgb_segmentation/region_growing_rgb_segmentation.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include // for pcl::removeNaNFromPointCloud #include using namespace std::chrono_literals; @@ -25,11 +25,7 @@ main () } pcl::IndicesPtr indices (new std::vector ); - pcl::PassThrough pass; - pass.setInputCloud (cloud); - pass.setFilterFieldName ("z"); - pass.setFilterLimits (0.0, 1.0); - pass.filter (*indices); + pcl::removeNaNFromPointCloud (*cloud, *indices); pcl::RegionGrowingRGB reg; reg.setInputCloud (cloud); diff --git a/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp b/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp index 2702b411036..f783f84e4d6 100644 --- a/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp +++ b/doc/tutorials/content/sources/region_growing_segmentation/region_growing_segmentation.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include // for pcl::removeNaNFromPointCloud #include int @@ -28,11 +28,7 @@ main () normal_estimator.compute (*normals); pcl::IndicesPtr indices (new std::vector ); - pcl::PassThrough pass; - pass.setInputCloud (cloud); - pass.setFilterFieldName ("z"); - pass.setFilterLimits (0.0, 1.0); - pass.filter (*indices); + pcl::removeNaNFromPointCloud(*cloud, *indices); pcl::RegionGrowing reg; reg.setMinClusterSize (50); @@ -40,7 +36,7 @@ main () reg.setSearchMethod (tree); reg.setNumberOfNeighbours (30); reg.setInputCloud (cloud); - //reg.setIndices (indices); + reg.setIndices (indices); reg.setInputNormals (normals); reg.setSmoothnessThreshold (3.0 / 180.0 * M_PI); reg.setCurvatureThreshold (1.0); From 6cc233a04e4e00646d1b1ea4260f94f32bcdfceb Mon Sep 17 00:00:00 2001 From: Fabian Schuetze Date: Mon, 17 May 2021 04:46:12 +0200 Subject: [PATCH 151/431] Small container improvement (#4748) --- cmake/pcl_find_cuda.cmake | 2 +- gpu/containers/src/initialization.cpp | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cmake/pcl_find_cuda.cmake b/cmake/pcl_find_cuda.cmake index 58096b36b4a..ab1810a15cb 100644 --- a/cmake/pcl_find_cuda.cmake +++ b/cmake/pcl_find_cuda.cmake @@ -31,7 +31,7 @@ if(CUDA_FOUND) # https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#deprecated-features if(NOT ${CUDA_VERSION_STRING} VERSION_LESS "11.0") - set(__cuda_arch_bin "3.5 3.7 5.0 5.2 5.3 6.0 6.1 6.2 7.0 7.2 7.5 8.0") + set(__cuda_arch_bin "3.5 3.7 5.0 5.2 5.3 6.0 6.1 6.2 7.0 7.2 7.5 8.0 8.6") elseif(NOT ${CUDA_VERSION_STRING} VERSION_LESS "10.0") set(__cuda_arch_bin "3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.1 6.2 7.0 7.2 7.5") elseif(NOT ${CUDA_VERSION_STRING} VERSION_LESS "9.0") diff --git a/gpu/containers/src/initialization.cpp b/gpu/containers/src/initialization.cpp index 4a8ac185ddd..5ad20544d63 100644 --- a/gpu/containers/src/initialization.cpp +++ b/gpu/containers/src/initialization.cpp @@ -39,6 +39,7 @@ #include "cuda.h" #include +#include // replace c-style array with std::array #define HAVE_CUDA //#include @@ -115,16 +116,14 @@ namespace int Cores; }; - SMtoCores gpuArchCoresPerSM[] = { - {0x10, 8}, {0x11, 8}, {0x12, 8}, {0x13, 8}, {0x20, 32}, {0x21, 48}, {0x30, 192}, - {0x35, 192}, {0x50, 128}, {0x52, 128}, {0x53, 128}, {0x60, 64}, {0x61, 128}, {-1, -1} - }; - int index = 0; - while (gpuArchCoresPerSM[index].SM != -1) - { - if (gpuArchCoresPerSM[index].SM == ((major << 4) + minor) ) - return gpuArchCoresPerSM[index].Cores; - index++; + std::array gpuArchCoresPerSM = {{ + {0x30, 192}, {0x32, 192}, {0x35, 192}, {0x37, 192}, {0x50, 128}, {0x52, 128}, + {0x53, 128}, {0x60, 64}, {0x61, 128}, {0x62, 128}, {0x70, 64}, {0x72, 64}, + {0x75, 64}, {0x80, 64}, {0x86, 128} + }}; + for (const auto& sm2cores : gpuArchCoresPerSM) { + if (sm2cores.SM == ((major << 4) + minor) ) + return sm2cores.Cores; } printf("\nCan't determine number of cores. Unknown SM version %d.%d!\n", major, minor); return 0; From b19c99a5f45950c0e519e631d09adb0c5257596e Mon Sep 17 00:00:00 2001 From: Alexander Turkin Date: Tue, 18 May 2021 16:06:53 +0300 Subject: [PATCH 152/431] Add support for reentrant qhull (#4540) * using reentrant qhull by default, qhull calls edits * using reentrant qhull by default, qhull calls edits * using reentrant qhull by default, qhull calls edits * cmake for qhull fix * cmake for qhull fix * static libs made reentrant as well * turning surface tests on for 20.10 * typos fixes, using errfile for qh_zero second param * removing HAVE_QHULL_2011 and assuming its always true * removing QHULL_MAJOR_VERSION --- .ci/azure-pipelines/azure-pipelines.yaml | 2 - cmake/Modules/FindQhull.cmake | 12 ++-- pcl_config.h.in | 2 - surface/include/pcl/surface/convex_hull.h | 4 +- .../include/pcl/surface/impl/concave_hull.hpp | 49 +++++++------- .../include/pcl/surface/impl/convex_hull.hpp | 66 ++++++++++--------- surface/include/pcl/surface/qhull.h | 27 +++----- 7 files changed, 75 insertions(+), 87 deletions(-) diff --git a/.ci/azure-pipelines/azure-pipelines.yaml b/.ci/azure-pipelines/azure-pipelines.yaml index 6ddc39600e7..281540424c3 100644 --- a/.ci/azure-pipelines/azure-pipelines.yaml +++ b/.ci/azure-pipelines/azure-pipelines.yaml @@ -56,8 +56,6 @@ stages: CC: gcc CXX: g++ BUILD_GPU: OFF - # surface is not ready for re-entrant QHull - CMAKE_ARGS: '-DBUILD_tests_surface=OFF' container: $[ variables['CONTAINER'] ] timeoutInMinutes: 0 variables: diff --git a/cmake/Modules/FindQhull.cmake b/cmake/Modules/FindQhull.cmake index 7f3cf90dc11..f9f628452b8 100644 --- a/cmake/Modules/FindQhull.cmake +++ b/cmake/Modules/FindQhull.cmake @@ -9,14 +9,12 @@ # If QHULL_USE_STATIC is specified then look for static libraries ONLY else # look for shared ones -set(QHULL_MAJOR_VERSION 6) - if(QHULL_USE_STATIC) - set(QHULL_RELEASE_NAME qhullstatic) - set(QHULL_DEBUG_NAME qhullstatic_d) + set(QHULL_RELEASE_NAME qhullstatic_r) + set(QHULL_DEBUG_NAME qhullstatic_rd) else() - set(QHULL_RELEASE_NAME qhull_p qhull${QHULL_MAJOR_VERSION} qhull) - set(QHULL_DEBUG_NAME qhull_p_d qhull${QHULL_MAJOR_VERSION}_d qhull_d${QHULL_MAJOR_VERSION} qhull_d) + set(QHULL_RELEASE_NAME qhull_r qhull) + set(QHULL_DEBUG_NAME qhull_rd qhull_d) endif() find_file(QHULL_HEADER @@ -30,10 +28,8 @@ set(QHULL_HEADER "${QHULL_HEADER}" CACHE INTERNAL "QHull header" FORCE ) if(QHULL_HEADER) get_filename_component(qhull_header ${QHULL_HEADER} NAME_WE) if("${qhull_header}" STREQUAL "qhull") - set(HAVE_QHULL_2011 OFF) get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH) elseif("${qhull_header}" STREQUAL "libqhull") - set(HAVE_QHULL_2011 ON) get_filename_component(QHULL_INCLUDE_DIR ${QHULL_HEADER} PATH) get_filename_component(QHULL_INCLUDE_DIR ${QHULL_INCLUDE_DIR} PATH) endif() diff --git a/pcl_config.h.in b/pcl_config.h.in index 3eccb95c975..e41128d2dc5 100644 --- a/pcl_config.h.in +++ b/pcl_config.h.in @@ -42,8 +42,6 @@ #cmakedefine HAVE_QHULL 1 -#cmakedefine HAVE_QHULL_2011 1 - #cmakedefine HAVE_CUDA 1 #cmakedefine HAVE_ENSENSO 1 diff --git a/surface/include/pcl/surface/convex_hull.h b/surface/include/pcl/surface/convex_hull.h index d82bbf0b0ea..917b42c412f 100644 --- a/surface/include/pcl/surface/convex_hull.h +++ b/surface/include/pcl/surface/convex_hull.h @@ -88,11 +88,11 @@ namespace pcl using PointCloudConstPtr = typename PointCloud::ConstPtr; /** \brief Empty constructor. */ - ConvexHull () : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (0), + ConvexHull () : compute_area_ (false), total_area_ (0), total_volume_ (0), dimension_ (0), projection_angle_thresh_ (std::cos (0.174532925) ), qhull_flags ("qhull "), x_axis_ (1.0, 0.0, 0.0), y_axis_ (0.0, 1.0, 0.0), z_axis_ (0.0, 0.0, 1.0) { - }; + } /** \brief Empty destructor */ ~ConvexHull () {} diff --git a/surface/include/pcl/surface/impl/concave_hull.hpp b/surface/include/pcl/surface/impl/concave_hull.hpp index 50216d15512..0019b2d395f 100644 --- a/surface/include/pcl/surface/impl/concave_hull.hpp +++ b/surface/include/pcl/surface/impl/concave_hull.hpp @@ -194,8 +194,13 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: points[i * dim_ + 2] = static_cast (cloud_transformed[i].z); } + qhT qh_qh; + qhT* qh = &qh_qh; + QHULL_LIB_CHECK + qh_zero(qh, errfile); + // Compute concave hull - exitcode = qh_new_qhull (dim_, static_cast (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile); + exitcode = qh_new_qhull (qh, dim_, static_cast (cloud_transformed.size ()), points, ismalloc, flags, outfile, errfile); if (exitcode != 0) { @@ -227,16 +232,16 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: alpha_shape.width = alpha_shape.height = 0; polygons.resize (0); - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); return; } - qh_setvoronoi_all (); + qh_setvoronoi_all (qh); - int num_vertices = qh num_vertices; + int num_vertices = qh->num_vertices; alpha_shape.resize (num_vertices); vertexT *vertex; @@ -253,11 +258,11 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: ++max_vertex_id; std::vector qhid_to_pcidx (max_vertex_id); - int num_facets = qh num_facets; + int num_facets = qh->num_facets; if (dim_ == 3) { - setT *triangles_set = qh_settemp (4 * num_facets); + setT *triangles_set = qh_settemp (qh, 4 * num_facets); if (voronoi_centers_) voronoi_centers_->points.resize (num_facets); @@ -283,29 +288,29 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: if (r <= alpha_) { // all triangles in tetrahedron are good, add them all to the alpha shape (triangles_set) - qh_makeridges (facet); + qh_makeridges (qh, facet); facet->good = true; - facet->visitid = qh visit_id; + facet->visitid = qh->visit_id; ridgeT *ridge, **ridgep; FOREACHridge_ (facet->ridges) { facetT *neighb = otherfacet_ (ridge, facet); - if ((neighb->visitid != qh visit_id)) - qh_setappend (&triangles_set, ridge); + if ((neighb->visitid != qh->visit_id)) + qh_setappend (qh, &triangles_set, ridge); } } else { // consider individual triangles from the tetrahedron... facet->good = false; - facet->visitid = qh visit_id; - qh_makeridges (facet); + facet->visitid = qh->visit_id; + qh_makeridges (qh, facet); ridgeT *ridge, **ridgep; FOREACHridge_ (facet->ridges) { facetT *neighb; neighb = otherfacet_ (ridge, facet); - if ((neighb->visitid != qh visit_id)) + if ((neighb->visitid != qh->visit_id)) { // check if individual triangle is good and add it to triangles_set @@ -322,7 +327,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: double r = pcl::getCircumcircleRadius (a, b, c); if (r <= alpha_) - qh_setappend (&triangles_set, ridge); + qh_setappend (qh, &triangles_set, ridge); } } } @@ -354,7 +359,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: { polygons[triangles].vertices.resize (3); int vertex_n, vertex_i; - FOREACHvertex_i_ ((*ridge).vertices) //3 vertices per ridge! + FOREACHvertex_i_ (qh, (*ridge).vertices) //3 vertices per ridge! { if (!added_vertices[vertex->id]) { @@ -383,7 +388,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: { // Compute the alpha complex for the set of points // Filters the delaunay triangles - setT *edges_set = qh_settemp (3 * num_facets); + setT *edges_set = qh_settemp (qh, 3 * num_facets); if (voronoi_centers_) voronoi_centers_->points.resize (num_facets); @@ -403,12 +408,12 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: if (r <= alpha_) { pcl::Vertices facet_vertices; //TODO: is not used!! - qh_makeridges (facet); + qh_makeridges (qh, facet); facet->good = true; ridgeT *ridge, **ridgep; FOREACHridge_ (facet->ridges) - qh_setappend (&edges_set, ridge); + qh_setappend (qh, &edges_set, ridge); if (voronoi_centers_) { @@ -438,7 +443,7 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: std::vector pcd_indices; pcd_indices.resize (2); - FOREACHvertex_i_ ((*ridge).vertices) //in 2-dim, 2 vertices per ridge! + FOREACHvertex_i_ (qh, (*ridge).vertices) //in 2-dim, 2 vertices per ridge! { if (!added_vertices[vertex->id]) { @@ -540,9 +545,9 @@ pcl::ConcaveHull::performReconstruction (PointCloud &alpha_shape, std: voronoi_centers_->points.resize (dd); } - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); Eigen::Affine3d transInverse = transform1.inverse (); pcl::transformPointCloud (alpha_shape, alpha_shape, transInverse); diff --git a/surface/include/pcl/surface/impl/convex_hull.hpp b/surface/include/pcl/surface/impl/convex_hull.hpp index b8cbb5f14fd..aa36cdd9efb 100644 --- a/surface/include/pcl/surface/impl/convex_hull.hpp +++ b/surface/include/pcl/surface/impl/convex_hull.hpp @@ -136,10 +136,8 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // output from qh_produce_output(), use NULL to skip qh_produce_output() FILE *outfile = nullptr; -#ifndef HAVE_QHULL_2011 if (compute_area_) outfile = stderr; -#endif // option flags for qhull, see qh_opt.htm const char* flags = qhull_flags.c_str (); @@ -180,18 +178,21 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // This should only happen if we had invalid input PCL_ERROR ("[pcl::%s::performReconstruction2D] Invalid input!\n", getClassName ().c_str ()); } + + qhT qh_qh; + qhT* qh = &qh_qh; + QHULL_LIB_CHECK + qh_zero(qh, errfile); // Compute convex hull - int exitcode = qh_new_qhull (dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); -#ifdef HAVE_QHULL_2011 + int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); if (compute_area_) { - qh_prepare_output(); + qh_prepare_output(qh); } -#endif // 0 if no error from qhull or it doesn't find any vertices - if (exitcode != 0 || qh num_vertices == 0) + if (exitcode != 0 || qh->num_vertices == 0) { PCL_ERROR ("[pcl::%s::performReconstrution2D] ERROR: qhull was unable to compute a convex hull for the given point cloud (%lu)!\n", getClassName ().c_str (), indices_->size ()); @@ -199,9 +200,9 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto hull.width = hull.height = 0; polygons.resize (0); - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); return; } @@ -209,11 +210,11 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto // Qhull returns the area in volume for 2D if (compute_area_) { - total_area_ = qh totvol; + total_area_ = qh->totvol; total_volume_ = 0.0; } - int num_vertices = qh num_vertices; + int num_vertices = qh->num_vertices; hull.clear(); hull.resize(num_vertices, PointInT{}); @@ -225,8 +226,8 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto FORALLvertices { - hull[i] = (*input_)[(*indices_)[qh_pointid (vertex->point)]]; - idx_points[i].first = qh_pointid (vertex->point); + hull[i] = (*input_)[(*indices_)[qh_pointid (qh, vertex->point)]]; + idx_points[i].first = qh_pointid (qh, vertex->point); ++i; } @@ -273,9 +274,9 @@ pcl::ConvexHull::performReconstruction2D (PointCloud &hull, std::vecto polygons[0].vertices[j] = static_cast (j); } - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); hull.width = hull.size (); hull.height = 1; @@ -298,10 +299,8 @@ pcl::ConvexHull::performReconstruction3D ( // output from qh_produce_output(), use NULL to skip qh_produce_output() FILE *outfile = nullptr; -#ifndef HAVE_QHULL_2011 if (compute_area_) outfile = stderr; -#endif // option flags for qhull, see qh_opt.htm const char *flags = qhull_flags.c_str (); @@ -319,14 +318,17 @@ pcl::ConvexHull::performReconstruction3D ( points[j + 2] = static_cast ((*input_)[(*indices_)[i]].z); } + qhT qh_qh; + qhT* qh = &qh_qh; + QHULL_LIB_CHECK + qh_zero(qh, errfile); + // Compute convex hull - int exitcode = qh_new_qhull (dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); -#ifdef HAVE_QHULL_2011 + int exitcode = qh_new_qhull (qh, dimension, static_cast (indices_->size ()), points, ismalloc, const_cast (flags), outfile, errfile); if (compute_area_) { - qh_prepare_output(); + qh_prepare_output(qh); } -#endif // 0 if no error from qhull if (exitcode != 0) @@ -340,18 +342,18 @@ pcl::ConvexHull::performReconstruction3D ( hull.width = hull.height = 0; polygons.resize (0); - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); return; } - qh_triangulate (); + qh_triangulate (qh); - int num_facets = qh num_facets; + int num_facets = qh->num_facets; - int num_vertices = qh num_vertices; + int num_vertices = qh->num_vertices; hull.resize (num_vertices); vertexT * vertex; @@ -374,7 +376,7 @@ pcl::ConvexHull::performReconstruction3D ( FORALLvertices { // Add vertices to hull point_cloud and store index - hull_indices_.indices.push_back ((*indices_)[qh_pointid (vertex->point)]); + hull_indices_.indices.push_back ((*indices_)[qh_pointid (qh, vertex->point)]); hull[i] = (*input_)[hull_indices_.indices.back ()]; qhid_to_pcidx[vertex->id] = i; // map the vertex id of qhull to the point cloud index @@ -383,8 +385,8 @@ pcl::ConvexHull::performReconstruction3D ( if (compute_area_) { - total_area_ = qh totarea; - total_volume_ = qh totvol; + total_area_ = qh->totarea; + total_volume_ = qh->totvol; } if (fill_polygon_data) @@ -399,16 +401,16 @@ pcl::ConvexHull::performReconstruction3D ( // Needed by FOREACHvertex_i_ int vertex_n, vertex_i; - FOREACHvertex_i_ ((*facet).vertices) + FOREACHvertex_i_ (qh, (*facet).vertices) //facet_vertices.vertices.push_back (qhid_to_pcidx[vertex->id]); polygons[dd].vertices[vertex_i] = qhid_to_pcidx[vertex->id]; ++dd; } } // Deallocates memory (also the points) - qh_freeqhull (!qh_ALL); + qh_freeqhull (qh, !qh_ALL); int curlong, totlong; - qh_memfreeshort (&curlong, &totlong); + qh_memfreeshort (qh, &curlong, &totlong); hull.width = hull.size (); hull.height = 1; diff --git a/surface/include/pcl/surface/qhull.h b/surface/include/pcl/surface/qhull.h index 39eee73e401..da370497082 100644 --- a/surface/include/pcl/surface/qhull.h +++ b/surface/include/pcl/surface/qhull.h @@ -48,25 +48,14 @@ extern "C" { -#ifdef HAVE_QHULL_2011 -# include "libqhull/libqhull.h" -# include "libqhull/mem.h" -# include "libqhull/qset.h" -# include "libqhull/geom.h" -# include "libqhull/merge.h" -# include "libqhull/poly.h" -# include "libqhull/io.h" -# include "libqhull/stat.h" -#else -# include "qhull/qhull.h" -# include "qhull/mem.h" -# include "qhull/qset.h" -# include "qhull/geom.h" -# include "qhull/merge.h" -# include "qhull/poly.h" -# include "qhull/io.h" -# include "qhull/stat.h" -#endif +#include "libqhull_r/libqhull_r.h" +#include "libqhull_r/mem_r.h" +#include "libqhull_r/qset_r.h" +#include "libqhull_r/geom_r.h" +#include "libqhull_r/merge_r.h" +#include "libqhull_r/poly_r.h" +#include "libqhull_r/io_r.h" +#include "libqhull_r/stat_r.h" } #endif From 52aed361e13787ac9157da20bc54ef39277bb0c4 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Tue, 18 May 2021 16:33:31 +0200 Subject: [PATCH 153/431] Updated minimum required boost to 1.65.0. --- cmake/pcl_find_boost.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/pcl_find_boost.cmake b/cmake/pcl_find_boost.cmake index f4eb87c54dd..e1b019eede4 100644 --- a/cmake/pcl_find_boost.cmake +++ b/cmake/pcl_find_boost.cmake @@ -24,14 +24,14 @@ set(Boost_ADDITIONAL_VERSIONS set(Boost_NO_BOOST_CMAKE ON) # Optional boost modules -find_package(Boost 1.55.0 QUIET COMPONENTS serialization mpi) +find_package(Boost 1.65.0 QUIET COMPONENTS serialization mpi) if(Boost_SERIALIZATION_FOUND) set(BOOST_SERIALIZATION_FOUND TRUE) endif() # Required boost modules set(BOOST_REQUIRED_MODULES filesystem date_time iostreams system) -find_package(Boost 1.55.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES}) +find_package(Boost 1.65.0 REQUIRED COMPONENTS ${BOOST_REQUIRED_MODULES}) if(Boost_FOUND) set(BOOST_FOUND TRUE) From 89fe1c7e82a520fb7b66b90fc827b04f25c855f2 Mon Sep 17 00:00:00 2001 From: Lars Glud Date: Fri, 21 May 2021 09:25:37 +0200 Subject: [PATCH 154/431] Update required FLANN --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ff0cd718e1..78ec1a5923b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ find_package(Eigen 3.1 REQUIRED) include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS}) # FLANN (required) -find_package(FLANN 1.7.0 REQUIRED) +find_package(FLANN 1.9.1 REQUIRED) if(NOT (${FLANN_LIBRARY_TYPE} MATCHES ${PCL_FLANN_REQUIRED_TYPE}) AND NOT (${PCL_FLANN_REQUIRED_TYPE} MATCHES "DONTCARE")) message(FATAL_ERROR "Flann was selected with ${PCL_FLANN_REQUIRED_TYPE} but found as ${FLANN_LIBRARY_TYPE}") endif() From 562ac9dd6d1b862da581f9d239ec362b69ee7ed6 Mon Sep 17 00:00:00 2001 From: tin1254 Date: Mon, 24 May 2021 02:55:22 +0200 Subject: [PATCH 155/431] Improve code style in documentation Update include guard to #pragma once, fix link to style guide --- doc/tutorials/content/writing_new_classes.rst | 42 ++++--------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/doc/tutorials/content/writing_new_classes.rst b/doc/tutorials/content/writing_new_classes.rst index b9eccd49689..bca60f66fdd 100644 --- a/doc/tutorials/content/writing_new_classes.rst +++ b/doc/tutorials/content/writing_new_classes.rst @@ -160,7 +160,7 @@ Setting up the structure If you're not familiar with the PCL file structure already, please go ahead and read the `PCL C++ Programming Style Guide - `_ to + `_ to familiarize yourself with the concepts. There're two different ways we could set up the structure: i) set up the code @@ -193,8 +193,7 @@ skeleton: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_H_ - #define PCL_FILTERS_BILATERAL_H_ + #pragma once #include @@ -206,8 +205,6 @@ skeleton: }; } - #endif // PCL_FILTERS_BILATERAL_H_ - bilateral.hpp ============= @@ -217,12 +214,9 @@ While we're at it, let's set up two skeleton *bilateral.hpp* and .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include - - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ This should be straightforward. We haven't declared any methods for `BilateralFilter` yet, therefore there is no implementation. @@ -511,8 +505,7 @@ header file becomes: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_H_ - #define PCL_FILTERS_BILATERAL_H_ + #pragma once #include #include @@ -584,8 +577,6 @@ header file becomes: }; } - #endif // PCL_FILTERS_BILATERAL_H_ - bilateral.hpp ============= @@ -651,8 +642,7 @@ entry for the class: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include @@ -660,8 +650,6 @@ entry for the class: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - One additional thing that we can do is error checking on: * whether the two `sigma_s_` and `sigma_r_` parameters have been given; @@ -709,8 +697,7 @@ The implementation file header thus becomes: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include #include @@ -770,8 +757,6 @@ The implementation file header thus becomes: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - Taking advantage of other PCL concepts -------------------------------------- @@ -824,8 +809,7 @@ The implementation file header thus becomes: .. code-block:: cpp :linenos: - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include #include @@ -885,8 +869,6 @@ The implementation file header thus becomes: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - To make :pcl:`indices_` work without typing the full construct, we need to add a new line to *bilateral.h* that specifies the class where `indices_` is declared: @@ -1020,8 +1002,7 @@ class look like: * */ - #ifndef PCL_FILTERS_BILATERAL_H_ - #define PCL_FILTERS_BILATERAL_H_ + #pragma once #include #include @@ -1131,8 +1112,6 @@ class look like: }; } - #endif // PCL_FILTERS_BILATERAL_H_ - And the *bilateral.hpp* likes: .. code-block:: cpp @@ -1175,8 +1154,7 @@ And the *bilateral.hpp* likes: * */ - #ifndef PCL_FILTERS_BILATERAL_IMPL_H_ - #define PCL_FILTERS_BILATERAL_IMPL_H_ + #pragma once #include #include @@ -1249,8 +1227,6 @@ And the *bilateral.hpp* likes: #define PCL_INSTANTIATE_BilateralFilter(T) template class PCL_EXPORTS pcl::BilateralFilter; - #endif // PCL_FILTERS_BILATERAL_IMPL_H_ - Testing the new class --------------------- From d0ebd87d3650b2205222f4a254051d5f92124549 Mon Sep 17 00:00:00 2001 From: tin1254 Date: Mon, 24 May 2021 15:18:57 +0200 Subject: [PATCH 156/431] Update license in documentation --- doc/tutorials/content/writing_new_classes.rst | 132 ++++-------------- 1 file changed, 24 insertions(+), 108 deletions(-) diff --git a/doc/tutorials/content/writing_new_classes.rst b/doc/tutorials/content/writing_new_classes.rst index bca60f66fdd..4c53f0e72bb 100644 --- a/doc/tutorials/content/writing_new_classes.rst +++ b/doc/tutorials/content/writing_new_classes.rst @@ -900,42 +900,14 @@ file, as follows: .. code-block:: cpp :linenos: - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2011, Willow Garage, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ + /* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2014-, Open Perception Inc. + * + * All rights reserved + */ An additional like can be inserted if additional copyright is needed (or the original copyright can be changed): @@ -965,42 +937,14 @@ class look like: .. code-block:: cpp :linenos: - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2011, Willow Garage, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ + /* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2014-, Open Perception Inc. + * + * All rights reserved + */ #pragma once @@ -1117,42 +1061,14 @@ And the *bilateral.hpp* likes: .. code-block:: cpp :linenos: - /* - * Software License Agreement (BSD License) - * - * Point Cloud Library (PCL) - www.pointclouds.org - * Copyright (c) 2010-2011, Willow Garage, Inc. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Willow Garage, Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ + /* + * SPDX-License-Identifier: BSD-3-Clause + * + * Point Cloud Library (PCL) - www.pointclouds.org + * Copyright (c) 2014-, Open Perception Inc. + * + * All rights reserved + */ #pragma once From 9427050881ce1d6c184d7faa10ac56f4cc021e3d Mon Sep 17 00:00:00 2001 From: Markus Vieth <39675748+mvieth@users.noreply.github.com> Date: Tue, 25 May 2021 18:28:41 +0200 Subject: [PATCH 157/431] Use more pcl::Indices (#4758) * Use more pcl::Indices and fix sign-compare warnings * Fixup * Fix some typos in test * Change pair type in region growing * Use more pcl::uindex_t in segmentation --- .../feature_wrapper/normal_estimator.h | 1 - .../tools/impl/organized_segmentation.hpp | 2 +- .../tools/euclidean_clustering.cpp | 2 +- apps/modeler/src/cloud_mesh.cpp | 4 +- apps/modeler/src/normal_estimation_worker.cpp | 2 +- apps/modeler/src/normals_actor_item.cpp | 2 +- apps/src/ni_linemod.cpp | 2 +- cuda/sample_consensus/src/sac_model.cu | 2 +- .../impl/organized_edge_detection.hpp | 4 +- .../include/pcl/filters/impl/bilateral.hpp | 6 +-- filters/include/pcl/filters/impl/crop_box.hpp | 4 +- filters/src/crop_box.cpp | 4 +- .../kinfu_large_scale/impl/world_model.hpp | 2 +- .../pcl/gpu/kinfu_large_scale/world_model.h | 2 +- .../include/pcl/gpu/people/label_tree.h | 4 +- .../include/pcl/gpu/people/people_detector.h | 2 +- gpu/people/src/people_detector.cpp | 6 +-- io/src/vtk_lib_io.cpp | 4 +- .../pcl/octree/impl/octree_pointcloud.hpp | 2 +- .../include/pcl/recognition/impl/hv/hv_go.hpp | 2 +- .../correspondence_rejection_features.h | 2 +- ...orrespondence_rejection_sample_consensus.h | 4 +- registration/include/pcl/registration/gicp.h | 16 ++++---- ...rrespondence_estimation_backprojection.hpp | 6 +-- ...pondence_rejection_sample_consensus_2d.hpp | 6 +-- .../include/pcl/registration/impl/gicp.hpp | 8 ++-- .../include/pcl/registration/impl/ia_fpcs.hpp | 18 ++++----- .../pcl/registration/impl/ia_ransac.hpp | 6 +-- .../impl/sample_consensus_prerejective.hpp | 4 +- ...estimation_point_to_plane_lls_weighted.hpp | 6 +-- ...ion_estimation_point_to_plane_weighted.hpp | 16 ++++---- .../transformation_validation_euclidean.hpp | 2 +- ...n_estimation_point_to_plane_lls_weighted.h | 6 +-- ...ation_estimation_point_to_plane_weighted.h | 10 ++--- registration/src/gicp6d.cpp | 4 +- .../impl/conditional_euclidean_clustering.hpp | 4 +- .../segmentation/impl/extract_clusters.hpp | 4 +- .../impl/grabcut_segmentation.hpp | 2 +- .../pcl/segmentation/impl/region_growing.hpp | 14 +++---- .../segmentation/impl/region_growing_rgb.hpp | 39 +++++++++---------- .../include/pcl/segmentation/region_growing.h | 14 +++---- .../pcl/segmentation/region_growing_rgb.h | 4 +- surface/include/pcl/surface/gp3.h | 28 ++++++------- surface/include/pcl/surface/impl/gp3.hpp | 14 +++---- test/gpu/octree/perfomance.cpp | 19 +++++---- test/gpu/octree/test_approx_nearest.cpp | 2 +- test/gpu/octree/test_host_radius_search.cpp | 7 ++-- test/gpu/octree/test_knn_search.cpp | 4 +- tools/obj_rec_ransac_result.cpp | 7 ++-- tools/octree_viewer.cpp | 2 +- .../pcl/visualization/impl/pcl_visualizer.hpp | 2 +- 51 files changed, 168 insertions(+), 171 deletions(-) diff --git a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h index 0e2a86f8b55..a8f49baa622 100644 --- a/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h +++ b/apps/3d_rec_framework/include/pcl/apps/3d_rec_framework/feature_wrapper/normal_estimator.h @@ -32,7 +32,6 @@ class PreProcessorAndNormalEstimator { pcl::Indices nn_indices(9); std::vector nn_distances(9); - std::vector src_indices; float sum_distances = 0.0; std::vector avg_distances(input->size()); diff --git a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp index 1b32f201fe0..708ea1f34b1 100644 --- a/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp +++ b/apps/cloud_composer/include/pcl/apps/cloud_composer/tools/impl/organized_segmentation.hpp @@ -122,7 +122,7 @@ pcl::cloud_composer::OrganizedSegmentationTool::performTemplatedAction (const QL euclidean_segmentation.setInputCloud (input_cloud); euclidean_segmentation.segment (euclidean_labels, euclidean_label_indices); - pcl::IndicesPtr extracted_indices (new std::vector ()); + pcl::IndicesPtr extracted_indices (new pcl::Indices ()); for (std::size_t i = 0; i < euclidean_label_indices.size (); i++) { if (euclidean_label_indices[i].indices.size () >= (std::size_t) min_cluster_size) diff --git a/apps/cloud_composer/tools/euclidean_clustering.cpp b/apps/cloud_composer/tools/euclidean_clustering.cpp index 4a52dd75c1e..13f5d914dbb 100644 --- a/apps/cloud_composer/tools/euclidean_clustering.cpp +++ b/apps/cloud_composer/tools/euclidean_clustering.cpp @@ -69,7 +69,7 @@ pcl::cloud_composer::EuclideanClusteringTool::performAction (ConstItemList input Eigen::Vector4f source_origin = input_item->data (ItemDataRole::ORIGIN).value (); Eigen::Quaternionf source_orientation = input_item->data (ItemDataRole::ORIENTATION).value (); //Vector to accumulate the extracted indices - pcl::IndicesPtr extracted_indices (new std::vector ()); + pcl::IndicesPtr extracted_indices (new pcl::Indices ()); //Put found clusters into new cloud_items! qDebug () << "Found "<()); + pcl::IndicesPtr indices(new pcl::Indices()); pcl::removeNaNFromPointCloud(*cloud_, *indices); data->SetNumberOfValues(3 * indices->size()); @@ -203,7 +203,7 @@ pcl::modeler::CloudMesh::updateVtkPolygons() } } else { - pcl::IndicesPtr indices(new std::vector()); + pcl::IndicesPtr indices(new pcl::Indices()); pcl::removeNaNFromPointCloud(*cloud_, *indices); for (const auto& polygon : polygons_) { diff --git a/apps/modeler/src/normal_estimation_worker.cpp b/apps/modeler/src/normal_estimation_worker.cpp index 56fce622185..468d7362fea 100755 --- a/apps/modeler/src/normal_estimation_worker.cpp +++ b/apps/modeler/src/normal_estimation_worker.cpp @@ -112,7 +112,7 @@ pcl::modeler::NormalEstimationWorker::processImpl(CloudMeshItem* cloud_mesh_item pcl::NormalEstimation normal_estimator; normal_estimator.setInputCloud(cloud); - pcl::IndicesPtr indices(new std::vector()); + pcl::IndicesPtr indices(new pcl::Indices()); pcl::removeNaNFromPointCloud(*cloud, *indices); normal_estimator.setIndices(indices); diff --git a/apps/modeler/src/normals_actor_item.cpp b/apps/modeler/src/normals_actor_item.cpp index b9141fdafa5..6530c56095e 100644 --- a/apps/modeler/src/normals_actor_item.cpp +++ b/apps/modeler/src/normals_actor_item.cpp @@ -95,7 +95,7 @@ pcl::modeler::NormalsActorItem::createNormalLines() } } else { - pcl::IndicesPtr indices(new std::vector()); + pcl::IndicesPtr indices(new pcl::Indices()); pcl::removeNaNFromPointCloud(*cloud, *indices); vtkIdType nr_normals = static_cast((indices->size() - 1) / level_ + 1); diff --git a/apps/src/ni_linemod.cpp b/apps/src/ni_linemod.cpp index b4e04aa385d..52452ec0bd6 100644 --- a/apps/src/ni_linemod.cpp +++ b/apps/src/ni_linemod.cpp @@ -569,7 +569,7 @@ class NILinemod { bool first_frame_; // Segmentation - std::vector indices_fullset_; + pcl::Indices indices_fullset_; PointIndices::Ptr plane_indices_; CloudPtr plane_; IntegralImageNormalEstimation ne_; diff --git a/cuda/sample_consensus/src/sac_model.cu b/cuda/sample_consensus/src/sac_model.cu index adeee90922d..461e66f5922 100644 --- a/cuda/sample_consensus/src/sac_model.cu +++ b/cuda/sample_consensus/src/sac_model.cu @@ -57,7 +57,7 @@ namespace pcl template