From 75467dd3b80f99a4088d3883fbaa85891f931be0 Mon Sep 17 00:00:00 2001 From: Lekan Date: Tue, 21 Feb 2017 10:02:55 -0600 Subject: [PATCH] Fixes segfault in our-cvfh when h_index is > 12. This wraps h_index around to 12 when the number of quadrants is > 12. --- features/include/pcl/features/impl/our_cvfh.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/features/include/pcl/features/impl/our_cvfh.hpp b/features/include/pcl/features/impl/our_cvfh.hpp index 7ddd84c6254..cad23f02627 100644 --- a/features/include/pcl/features/impl/our_cvfh.hpp +++ b/features/include/pcl/features/impl/our_cvfh.hpp @@ -497,6 +497,13 @@ pcl::OURCVFHEstimation::computeRFAndShapeDistribut } int h_index = (d <= 0) ? 0 : std::ceil (size_hists * (d / distance_normalization_factor)) - 1; + /* from http://www.pcl-users.org/OUR-CVFH-problem-td4028436.html + h_index will be 13 when d is computed on the farthest away point. + + adding the following after computing h_index fixes the problem: + */ + if(h_index > 12) + h_index = 12; for (int j = 0; j < num_hists; j++) quadrants[j][h_index] += hist_incr * weights[j];