PointCloudLibrary / PointCloudLibrary/pcl

OUR-CVFH Bin Calculations

Open
#3,340 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module: filters needs: feedback
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Your Environment

  • Operating System and version: Ubuntu 16.04
  • PCL Version: 1.9

Context

Attempting to use OUR-CVFH. A few years ago, there were too many seg. faults, so we wrote our own version in a different language. Now I'm trying to move back to PCL, but there are some notable differences in the way the features histograms are binned.

Expected Behavior

When calculating the bin locations, the bin length values, should be one less than their actual length because c++ is counting from zero. Suppose the feature pfh_tuple[2] has range from -1 to +1. Then the code changes the range to 0 to +1 with the code below. With that range, the bin (h_index) is found by multiplying by 44.

int nr_bins_f3_ (44);
int h_index = static_cast<int> (floor (nr_bins_f3_ * ((pfh_tuple[2] + 1.0) * 0.5)));

Current Behavior

Currently, the code set the bin counts at the length of histogram, i.e.

int nr_bins_f1_ (45);
int nr_bins_f2_ (45);
int nr_bins_f3_ (45);
int nr_bins_f4_ (128);
int size_hists (13);

Then when using the code

int h_index = static_cast<int> (floor (nr_bins_f3_ * ((pfh_tuple[2] + 1.0) * 0.5)));

yields h_index values in the range from 0 to 45, which is the unintended length of 46.

This happens similarly with all the other features for PFH, FPFH, VFH, CVFH, and OUR-CVFH. Someone made an attempt to fix the OUR-CVFH shape distribution component (from pcl/features/our_cvfh.hpp line 499) by subtracting 1 and resetting the largest bin

int h_index = (d <= 0) ? 0 : std::ceil (size_hists * (d / distance_normalization_factor)) - 1;
if(h_index > 12)
h_index = 12;

There is even a reference to the users mailing list
/*
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:
*/

This is the wrong way of setting the bins, because nr_bins_f1_ (45) actually creates 46 equally spaced bins, from 0 to 45. Or size_hists (13) actually creates 14 equally spaced bins from 0 to 13.

Possible Solution

Luckily, super simple solution to all this. Just need to change some of the presets.

In pcl/features/vfh.h lines 90 to

nr_bins_f1_ (44), nr_bins_f2_ (44), nr_bins_f3_ (44), nr_bins_f4_ (44), nr_bins_vp_ (127),

and in pcl/features/impl/our_cvfh.hpp line 401

int size_hists = 12;

and in pcl/features/impl/our_cvfh.hpp line 499 to use std::floor instead of std::ceil and remove the -1

int h_index = (d <= 0) ? 0 : std::floor (size_hists * (d / distance_normalization_factor)) ;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the bin-count presets in pcl/features/vfh.h and the OUR-CVFH calculations in pcl/features/impl/our_cvfh.hpp, especially the locations cited in the issue. Compare the indexing behavior for boundary values across the PFH, FPFH, VFH, CVFH, and OUR-CVFH histogram calculations. Done means the configured ranges produce the intended number of bins without the reported extra-bin behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.