Configurable miss_per_hit_limit in outlier removing processor. (#1476)
Was hardcoded to 3 before, but it makes sense to make this a parameter.master
parent
9c92616567
commit
2abe1c72a6
|
@ -27,13 +27,23 @@ std::unique_ptr<OutlierRemovingPointsProcessor>
|
||||||
OutlierRemovingPointsProcessor::FromDictionary(
|
OutlierRemovingPointsProcessor::FromDictionary(
|
||||||
common::LuaParameterDictionary* const dictionary,
|
common::LuaParameterDictionary* const dictionary,
|
||||||
PointsProcessor* const next) {
|
PointsProcessor* const next) {
|
||||||
|
const double miss_per_hit_limit = [&]() {
|
||||||
|
if (!dictionary->HasKey("miss_per_hit_limit")) {
|
||||||
|
LOG(INFO) << "Using default value of 3 for miss_per_hit_limit.";
|
||||||
|
return 3.;
|
||||||
|
} else {
|
||||||
|
return dictionary->GetDouble("miss_per_hit_limit");
|
||||||
|
}
|
||||||
|
}();
|
||||||
return absl::make_unique<OutlierRemovingPointsProcessor>(
|
return absl::make_unique<OutlierRemovingPointsProcessor>(
|
||||||
dictionary->GetDouble("voxel_size"), next);
|
dictionary->GetDouble("voxel_size"), miss_per_hit_limit, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
OutlierRemovingPointsProcessor::OutlierRemovingPointsProcessor(
|
OutlierRemovingPointsProcessor::OutlierRemovingPointsProcessor(
|
||||||
const double voxel_size, PointsProcessor* next)
|
const double voxel_size, const double miss_per_hit_limit,
|
||||||
|
PointsProcessor* next)
|
||||||
: voxel_size_(voxel_size),
|
: voxel_size_(voxel_size),
|
||||||
|
miss_per_hit_limit_(miss_per_hit_limit),
|
||||||
next_(next),
|
next_(next),
|
||||||
state_(State::kPhase1),
|
state_(State::kPhase1),
|
||||||
voxels_(voxel_size_) {
|
voxels_(voxel_size_) {
|
||||||
|
@ -106,12 +116,11 @@ void OutlierRemovingPointsProcessor::ProcessInPhaseTwo(
|
||||||
|
|
||||||
void OutlierRemovingPointsProcessor::ProcessInPhaseThree(
|
void OutlierRemovingPointsProcessor::ProcessInPhaseThree(
|
||||||
std::unique_ptr<PointsBatch> batch) {
|
std::unique_ptr<PointsBatch> batch) {
|
||||||
constexpr double kMissPerHitLimit = 3;
|
|
||||||
absl::flat_hash_set<int> to_remove;
|
absl::flat_hash_set<int> to_remove;
|
||||||
for (size_t i = 0; i < batch->points.size(); ++i) {
|
for (size_t i = 0; i < batch->points.size(); ++i) {
|
||||||
const VoxelData voxel =
|
const VoxelData voxel =
|
||||||
voxels_.value(voxels_.GetCellIndex(batch->points[i].position));
|
voxels_.value(voxels_.GetCellIndex(batch->points[i].position));
|
||||||
if (!(voxel.rays < kMissPerHitLimit * voxel.hits)) {
|
if (!(voxel.rays < miss_per_hit_limit_ * voxel.hits)) {
|
||||||
to_remove.insert(i);
|
to_remove.insert(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ class OutlierRemovingPointsProcessor : public PointsProcessor {
|
||||||
constexpr static const char* kConfigurationFileActionName =
|
constexpr static const char* kConfigurationFileActionName =
|
||||||
"voxel_filter_and_remove_moving_objects";
|
"voxel_filter_and_remove_moving_objects";
|
||||||
|
|
||||||
OutlierRemovingPointsProcessor(double voxel_size, PointsProcessor* next);
|
OutlierRemovingPointsProcessor(double voxel_size, double miss_per_hit_limit,
|
||||||
|
PointsProcessor* next);
|
||||||
|
|
||||||
static std::unique_ptr<OutlierRemovingPointsProcessor> FromDictionary(
|
static std::unique_ptr<OutlierRemovingPointsProcessor> FromDictionary(
|
||||||
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
||||||
|
@ -76,6 +77,7 @@ class OutlierRemovingPointsProcessor : public PointsProcessor {
|
||||||
void ProcessInPhaseThree(std::unique_ptr<PointsBatch> batch);
|
void ProcessInPhaseThree(std::unique_ptr<PointsBatch> batch);
|
||||||
|
|
||||||
const double voxel_size_;
|
const double voxel_size_;
|
||||||
|
const double miss_per_hit_limit_;
|
||||||
PointsProcessor* const next_;
|
PointsProcessor* const next_;
|
||||||
State state_;
|
State state_;
|
||||||
mapping::HybridGridBase<VoxelData> voxels_;
|
mapping::HybridGridBase<VoxelData> voxels_;
|
||||||
|
|
Loading…
Reference in New Issue