ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
Toggle main menu visibility
Loading...
Searching...
No Matches
segment_planes.hpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2025 Povl Filip Sonne-Frederiksen
2
//
3
// SPDX-License-Identifier: GPL-3.0-or-later
4
5
#pragma once
6
#include "reusex/core/logging.hpp"
7
#include "reusex/core/processing_observer.hpp"
8
#include "reusex/types/point_types.hpp"
9
#include "reusex/utils/fmt_formatter.hpp"
10
11
#include <fmt/format.h>
12
#include <pcl/common/colors.h>
13
#include <pcl/filters/filter.h>
14
#include <pcl/io/auto_io.h>
15
#include <pcl/io/pcd_io.h>
16
#include <pcl/planar_region_growing.hpp>
17
18
#include <atomic>
19
#include <optional>
20
21
namespace
reusex::geometry
{
22
23
struct
SegmentPlanesOptions
{
24
IndicesConstPtr
filter
=
nullptr
;
// Optional filter to limit processing
25
26
float
angle_threshold
= 25.0F;
27
28
// Distance and inlier thresholds are derived per-cloud from the measured
29
// noise/density when `adaptive` is true (issue #214), UNLESS the caller
30
// supplies an explicit override below. An explicit override always wins over
31
// adaptivity for that one parameter (e.g. a `-d` CLI flag pins the distance
32
// threshold while `min_inliers` still adapts). When `adaptive` is false the
33
// legacy fixed defaults are used.
34
float
plane_dist_threshold
= 0.07F;
35
int
min_inliers
= 1000;
36
37
float
radius
= 0.5F;
38
float
interval_0
= 16.0F;
39
float
interval_factor
= 1.5F;
40
42
bool
adaptive
=
true
;
44
std::optional<float>
plane_dist_threshold_override
;
46
std::optional<int>
min_inliers_override
;
48
unsigned
noise_seed
= 42;
49
50
// --- Adaptive scaling constants (issue #214) ------------------------------
53
float
dist_sigma_factor
= 3.0F;
54
float
dist_min
= 0.01F;
55
float
dist_max
= 0.15F;
58
float
min_surface_area
= 0.5F;
59
int
min_inliers_floor
= 100;
60
int
min_inliers_ceiling
= 5000;
61
62
// --- Post-segmentation sanity thresholds (issue #214) ---------------------
64
int
warn_plane_count
= 60;
66
float
warn_labeled_fraction
= 0.30F;
67
68
// Optional cancellation flag. Caller retains ownership and must keep this
69
// alive for the full duration of the segment_planes(...) call.
70
const
std::atomic_bool *
cancel_token
=
nullptr
;
71
};
72
73
auto
segment_planes_impl
(
CloudConstPtr
cloud,
CloudNConstPtr
normals,
74
const
SegmentPlanesOptions
&options)
75
-> std::tuple<CloudLPtr, CloudLocPtr, CloudNPtr>;
76
77
auto
segment_planes
(
78
CloudConstPtr
cloud,
CloudNConstPtr
normals,
79
const
SegmentPlanesOptions
&options =
SegmentPlanesOptions
{})
80
-> std::tuple<CloudLPtr, CloudLocPtr, CloudNPtr>;
81
82
}
// namespace reusex::geometry
reusex::geometry
Definition
visual_observer.hpp:33
reusex::geometry::segment_planes_impl
auto segment_planes_impl(CloudConstPtr cloud, CloudNConstPtr normals, const SegmentPlanesOptions &options) -> std::tuple< CloudLPtr, CloudLocPtr, CloudNPtr >
reusex::geometry::segment_planes
auto segment_planes(CloudConstPtr cloud, CloudNConstPtr normals, const SegmentPlanesOptions &options=SegmentPlanesOptions{}) -> std::tuple< CloudLPtr, CloudLocPtr, CloudNPtr >
reusex::IndicesConstPtr
pcl::IndicesConstPtr IndicesConstPtr
Definition
point_types.hpp:25
reusex::CloudConstPtr
typename Cloud::ConstPtr CloudConstPtr
Definition
point_types.hpp:29
reusex::CloudNConstPtr
typename CloudN::ConstPtr CloudNConstPtr
Definition
point_types.hpp:33
reusex::geometry::SegmentPlanesOptions
Definition
segment_planes.hpp:23
reusex::geometry::SegmentPlanesOptions::noise_seed
unsigned noise_seed
Deterministic seed for the noise estimator (STANDARDS ยง6).
Definition
segment_planes.hpp:48
reusex::geometry::SegmentPlanesOptions::plane_dist_threshold
float plane_dist_threshold
Definition
segment_planes.hpp:34
reusex::geometry::SegmentPlanesOptions::warn_labeled_fraction
float warn_labeled_fraction
Warn when the labeled point fraction falls below this (under-coverage).
Definition
segment_planes.hpp:66
reusex::geometry::SegmentPlanesOptions::min_inliers_override
std::optional< int > min_inliers_override
Explicit min-inliers override; bypasses adaptivity when set.
Definition
segment_planes.hpp:46
reusex::geometry::SegmentPlanesOptions::warn_plane_count
int warn_plane_count
Warn when the detected plane count exceeds this (over-fragmentation).
Definition
segment_planes.hpp:64
reusex::geometry::SegmentPlanesOptions::interval_0
float interval_0
Definition
segment_planes.hpp:38
reusex::geometry::SegmentPlanesOptions::dist_max
float dist_max
upper clamp for adaptive distance threshold [m]
Definition
segment_planes.hpp:55
reusex::geometry::SegmentPlanesOptions::min_surface_area
float min_surface_area
Target minimum planar surface area [m^2] used to scale min_inliers by the measured point density (poi...
Definition
segment_planes.hpp:58
reusex::geometry::SegmentPlanesOptions::adaptive
bool adaptive
Enable noise-adaptive threshold derivation (default ON, issue #214).
Definition
segment_planes.hpp:42
reusex::geometry::SegmentPlanesOptions::filter
IndicesConstPtr filter
Definition
segment_planes.hpp:24
reusex::geometry::SegmentPlanesOptions::radius
float radius
Definition
segment_planes.hpp:37
reusex::geometry::SegmentPlanesOptions::plane_dist_threshold_override
std::optional< float > plane_dist_threshold_override
Explicit distance-threshold override [m]; bypasses adaptivity when set.
Definition
segment_planes.hpp:44
reusex::geometry::SegmentPlanesOptions::dist_sigma_factor
float dist_sigma_factor
plane_dist_threshold = clamp(dist_sigma_factor * sigma, dist_min,dist_max)
Definition
segment_planes.hpp:53
reusex::geometry::SegmentPlanesOptions::interval_factor
float interval_factor
Definition
segment_planes.hpp:39
reusex::geometry::SegmentPlanesOptions::min_inliers_ceiling
int min_inliers_ceiling
upper clamp for adaptive min_inliers
Definition
segment_planes.hpp:60
reusex::geometry::SegmentPlanesOptions::min_inliers
int min_inliers
Definition
segment_planes.hpp:35
reusex::geometry::SegmentPlanesOptions::cancel_token
const std::atomic_bool * cancel_token
Definition
segment_planes.hpp:70
reusex::geometry::SegmentPlanesOptions::angle_threshold
float angle_threshold
Definition
segment_planes.hpp:26
reusex::geometry::SegmentPlanesOptions::min_inliers_floor
int min_inliers_floor
lower clamp for adaptive min_inliers
Definition
segment_planes.hpp:59
reusex::geometry::SegmentPlanesOptions::dist_min
float dist_min
lower clamp for adaptive distance threshold [m]
Definition
segment_planes.hpp:54
libs
reusex
include
segmentation
segment_planes.hpp
Generated by
1.17.0