Skip to content

Commit

Permalink
Merge pull request #903 from PDAL/approximate-pdal-ground
Browse files Browse the repository at this point in the history
Add --approximate option to 'pdal ground' for much faster computation #883
  • Loading branch information
hobu committed May 12, 2015
2 parents 23eecaa + 41aec1f commit 3a56acd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
40 changes: 30 additions & 10 deletions plugins/pcl/filters/GroundFilter.cpp
Expand Up @@ -46,6 +46,7 @@
#include <pcl/filters/extract_indices.h>
#include <pcl/io/pcd_io.h>
#include <pcl/segmentation/progressive_morphological_filter.h>
#include <pcl/segmentation/approximate_progressive_morphological_filter.h>

namespace pdal
{
Expand All @@ -68,6 +69,7 @@ void GroundFilter::processOptions(const Options& options)
m_cellSize = options.getValueOrDefault<double>("cellSize", 1);
m_classify = options.getValueOrDefault<bool>("classify", true);
m_extract = options.getValueOrDefault<bool>("extract", false);
m_approximate = options.getValueOrDefault<bool>("approximate", false);
}

void GroundFilter::addDimensions(PointLayoutPtr layout)
Expand Down Expand Up @@ -113,17 +115,35 @@ PointViewSet GroundFilter::run(PointViewPtr input)
}

// setup the PMF filter
pcl::ProgressiveMorphologicalFilter<pcl::PointXYZ> pmf;
pmf.setInputCloud(cloud);
pmf.setMaxWindowSize(m_maxWindowSize);
pmf.setSlope(m_slope);
pmf.setMaxDistance(m_maxDistance);
pmf.setInitialDistance(m_initialDistance);
pmf.setCellSize(m_cellSize);

// run the PMF filter, grabbing indices of ground returns
pcl::PointIndicesPtr idx(new pcl::PointIndices);
pmf.extract(idx->indices);
if (!m_approximate)
{

pcl::ProgressiveMorphologicalFilter<pcl::PointXYZ> pmf;
pmf.setInputCloud(cloud);
pmf.setMaxWindowSize(m_maxWindowSize);
pmf.setSlope(m_slope);
pmf.setMaxDistance(m_maxDistance);
pmf.setInitialDistance(m_initialDistance);
pmf.setCellSize(m_cellSize);

// run the PMF filter, grabbing indices of ground returns
pcl::PointIndicesPtr idx(new pcl::PointIndices);
pmf.extract(idx->indices);
} else
{
pcl::ApproximateProgressiveMorphologicalFilter<pcl::PointXYZ> pmf;
pmf.setInputCloud(cloud);
pmf.setMaxWindowSize(m_maxWindowSize);
pmf.setSlope(m_slope);
pmf.setMaxDistance(m_maxDistance);
pmf.setInitialDistance(m_initialDistance);
pmf.setCellSize(m_cellSize);

// run the PMF filter, grabbing indices of ground returns
pmf.extract(idx->indices);

}

PointViewSet viewSet;
if (!idx->indices.empty() && (m_classify || m_extract))
Expand Down
1 change: 1 addition & 0 deletions plugins/pcl/filters/GroundFilter.hpp
Expand Up @@ -65,6 +65,7 @@ class PDAL_DLL GroundFilter : public Filter
double m_cellSize;
bool m_classify;
bool m_extract;
bool m_approximate;

virtual void addDimensions(PointLayoutPtr layout);
virtual void processOptions(const Options& options);
Expand Down
2 changes: 2 additions & 0 deletions plugins/pcl/kernel/GroundKernel.cpp
Expand Up @@ -71,6 +71,7 @@ GroundKernel::GroundKernel()
, m_cellSize(1)
, m_classify(true)
, m_extract(false)
, m_approximate(false)
{}

void GroundKernel::validateSwitches()
Expand Down Expand Up @@ -100,6 +101,7 @@ void GroundKernel::addSwitches()
("cellSize", po::value<double>(&m_cellSize)->default_value(1), "cell size")
("classify", po::bool_switch(&m_classify), "apply classification labels?")
("extract", po::bool_switch(&m_extract), "extract ground returns?")
("approximate,a", po::bool_switch(&m_approximate), "use approximate algorithm? (much faster)")
;

addSwitchSet(file_options);
Expand Down
1 change: 1 addition & 0 deletions plugins/pcl/kernel/GroundKernel.hpp
Expand Up @@ -72,6 +72,7 @@ class PDAL_DLL GroundKernel : public Kernel
double m_cellSize;
bool m_classify;
bool m_extract;
bool m_approximate;
};

} // namespace pdal
Expand Down

0 comments on commit 3a56acd

Please sign in to comment.