PointCloudLibrary / PointCloudLibrary/pcl

Why not use CropBox inside CropHull?

Open
#3,875 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

CropHull<PointT>::filter Ω (n * m)
CropBox<PointT>::filter O (n)

Where n - size of filtered point cloud, m - size of hull cloud.
To find bounding box for CropBox need O (m) time.

In my practical case using CropBox before CropHull significantly reduces runtime.
So why not always use CropBox inside CropHull?

This function is a template, which could be embed in CropHull.

template <class PointT>
std::vector<int>
filter(pcl::CropHull<PointT> & cropHullFilter, pcl::PointCloud<PointT>::ConstPtr bigCloudPtr, bool cropOutside = true)
{
	// just because pcl::CropHull haven't got getCropOutside() function
	cropHullFilter.setCropOutside(cropOutside);
	// cropOutside = cropHullFilter.getCropOutside();

	std::vector<int> cropInlierIndices;
	Eigen::Vector4f minPt, maxPt;
	pcl::getMinMax3D(*cropHullFilter.getHullCloud(), minPt, maxPt);
	pcl::CropBox<pcl::PointXYZ> cropBoxFilter(true);
	cropBoxFilter.setMin(minPt);
	cropBoxFilter.setMax(maxPt);
	cropBoxFilter.setInputCloud(bigCloudPtr);
	cropBoxFilter.filter(cropInlierIndices);
	pcl::PointCloud<PointT>::Ptr croppedCloudPtr(new pcl::PointCloud<PointT>);
	pcl::copyPointCloud(*rootCloudPtr, cropInlierIndices, *croppedCloudPtr);

	std::vector<int> filteredInlierIndices;
	cropHullFilter.setInputCloud(croppedCloudPtr);
	cropHullFilter.filter(filteredInlierIndices);
	
	std::vector<int> inlierIndices;
	if (!cropOutside) {
		for (int idx : cropBoxFilter.getRemovedIndices()) {
			inlierIndices.push_back(idx);
		}
	}
	for (int idx : filteredInlierIndices) {
		inlierIndices.push_back(cropInlierIndices[idx]);
	}
	return inlierIndices;
}

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 by reading the pcl::CropHull::filter and pcl::CropBox::filter entry points mentioned in the issue. Evaluate whether applying the CropBox bounding-box prefilter inside CropHull preserves cropOutside behavior and original indices. Done means a resolved design with validation that the optimization improves runtime without changing filtering results.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-vision, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.