60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
#ifndef POINTCLOUDFILTER_H
|
|
#define POINTCLOUDFILTER_H
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#include "VZNL_Types.h"
|
|
|
|
// Selects the outlier removal algorithm.
|
|
enum class PointCloudFilterMethod
|
|
{
|
|
None = 0,
|
|
ScanLineContinuity,
|
|
RadiusOutlier,
|
|
StatisticalOutlier
|
|
};
|
|
|
|
struct PointCloudFilterParams
|
|
{
|
|
PointCloudFilterMethod method = PointCloudFilterMethod::None;
|
|
|
|
// ScanLineContinuity parameters. Units follow the point cloud (normally mm).
|
|
double continuityThreshold = 20.0;
|
|
std::size_t minSegmentLength = 5;
|
|
|
|
// RadiusOutlier parameters. minNeighbors excludes the point itself.
|
|
double radius = 5.0;
|
|
std::size_t minNeighbors = 2;
|
|
|
|
// StatisticalOutlier parameters.
|
|
std::size_t meanK = 8;
|
|
double standardDeviationMultiplier = 1.0;
|
|
// Zero estimates a radius from the cloud density; non-zero limits the search.
|
|
double searchRadius = 0.0;
|
|
};
|
|
|
|
struct PointCloudFilterStats
|
|
{
|
|
std::size_t inputPointCount = 0;
|
|
std::size_t outputPointCount = 0;
|
|
std::size_t removedPointCount = 0;
|
|
};
|
|
|
|
class PointCloudFilter
|
|
{
|
|
public:
|
|
// The input is not modified. Original nPointIdx values are retained.
|
|
static bool Filter(const std::vector<std::vector<SVzNL3DPosition>>& input,
|
|
std::vector<std::vector<SVzNL3DPosition>>& output,
|
|
const PointCloudFilterParams& params = PointCloudFilterParams(),
|
|
PointCloudFilterStats* stats = nullptr);
|
|
|
|
static bool Filter(const std::vector<SVzNL3DPosition>& input,
|
|
std::vector<SVzNL3DPosition>& output,
|
|
const PointCloudFilterParams& params = PointCloudFilterParams(),
|
|
PointCloudFilterStats* stats = nullptr);
|
|
};
|
|
|
|
#endif // POINTCLOUDFILTER_H
|