cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
loam_feature_extractor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cpp-toolbox/cpp-toolbox_export.hpp>
8
9namespace toolbox::pcl
10{
11
20template<typename DataType,
21 typename KNN = kdtree_generic_t<point_t<DataType>, toolbox::metrics::L2Metric<DataType>>>
22class CPP_TOOLBOX_EXPORT loam_feature_extractor_t
23 : public base_keypoint_extractor_t<loam_feature_extractor_t<DataType, KNN>,
24 DataType,
25 KNN>
26{
27public:
29 DataType,
30 KNN>;
32 using knn_type = typename base_type::knn_type;
36
37 // Feature type labels
38 enum class feature_label : uint8_t {
39 none = 0, // Neither edge nor planar
40 edge = 1, // Edge/corner point
41 planar = 2 // Planar point
42 };
43
44 // Result structure containing both point cloud and labels
45 struct loam_result {
47 std::vector<uint8_t> labels; // feature_label for each point
48 };
49
51
52 // Implementation methods for CRTP
53 std::size_t set_input_impl(const point_cloud& cloud);
54 std::size_t set_input_impl(const point_cloud_ptr& cloud);
55 std::size_t set_knn_impl(const knn_type& knn);
56 std::size_t set_search_radius_impl(data_type radius);
57 void enable_parallel_impl(bool enable);
58
59 indices_vector extract_impl();
60 void extract_impl(indices_vector& keypoint_indices);
61 point_cloud extract_keypoints_impl();
62 void extract_keypoints_impl(point_cloud_ptr output);
63
64 // Extended interface for LOAM
65 loam_result extract_labeled_cloud();
66
67 // LOAM-specific parameters
68 void set_edge_threshold(data_type threshold) { m_edge_threshold = threshold; }
69 void set_planar_threshold(data_type threshold) { m_planar_threshold = threshold; }
70 void set_curvature_threshold(data_type threshold) { m_curvature_threshold = threshold; }
71 void set_num_scan_neighbors(std::size_t num) { m_num_scan_neighbors = num; }
72
73 [[nodiscard]] data_type get_edge_threshold() const { return m_edge_threshold; }
74 [[nodiscard]] data_type get_planar_threshold() const { return m_planar_threshold; }
75 [[nodiscard]] data_type get_curvature_threshold() const { return m_curvature_threshold; }
76 [[nodiscard]] std::size_t get_num_scan_neighbors() const { return m_num_scan_neighbors; }
77
78 // Utility methods for extracting specific feature types
79 static point_cloud extract_edge_points(const loam_result& result);
80 static point_cloud extract_planar_points(const loam_result& result);
81 static point_cloud extract_non_feature_points(const loam_result& result);
82
83 // Get indices only
84 static indices_vector extract_edge_indices(const std::vector<uint8_t>& labels);
85 static indices_vector extract_planar_indices(const std::vector<uint8_t>& labels);
86
87private:
88 struct CurvatureInfo
89 {
90 data_type curvature;
91 bool is_valid;
92 };
93
94 // Core computation methods
95 std::vector<CurvatureInfo> compute_curvatures();
96 CurvatureInfo compute_point_curvature(std::size_t point_idx);
97 void compute_curvatures_range(std::vector<CurvatureInfo>& curvatures,
98 std::size_t start_idx,
99 std::size_t end_idx);
100 std::vector<uint8_t> classify_features(const std::vector<CurvatureInfo>& curvatures);
101
102 // Member variables
103 bool m_enable_parallel = false;
104 data_type m_edge_threshold = static_cast<data_type>(0.2); // High curvature threshold
105 data_type m_planar_threshold = static_cast<data_type>(0.1); // Low curvature threshold
106 data_type m_curvature_threshold = static_cast<data_type>(0.001); // Minimum curvature
107 std::size_t m_num_scan_neighbors = 10; // Number of neighbors for curvature computation
108
109 point_cloud_ptr m_cloud;
110 knn_type* m_knn = nullptr;
111
112 // Parallel processing threshold
113 static constexpr std::size_t k_parallel_threshold = 1000;
114}; // class loam_feature_extractor_t
115
116} // namespace toolbox::pcl
117
Definition vector_metrics.hpp:18
关键点提取器的基类,使用CRTP模式实现静态多态 / Base class for keypoint extractors using CRTP pattern for static polymorph...
Definition base_feature_extractor.hpp:44
DataType data_type
Definition base_feature_extractor.hpp:46
KNN knn_type
Definition base_feature_extractor.hpp:47
std::vector< std::size_t > indices_vector
Definition base_feature_extractor.hpp:50
std::shared_ptr< toolbox::types::point_cloud_t< data_type > > point_cloud_ptr
Definition base_feature_extractor.hpp:49
LOAM (Lidar Odometry and Mapping) 特征提取器 / LOAM (Lidar Odometry and Mapping) feature extractor.
Definition loam_feature_extractor.hpp:26
std::size_t get_num_scan_neighbors() const
Definition loam_feature_extractor.hpp:76
typename base_type::knn_type knn_type
Definition loam_feature_extractor.hpp:32
data_type get_edge_threshold() const
Definition loam_feature_extractor.hpp:73
typename base_type::data_type data_type
Definition loam_feature_extractor.hpp:31
typename base_type::indices_vector indices_vector
Definition loam_feature_extractor.hpp:35
void set_curvature_threshold(data_type threshold)
Definition loam_feature_extractor.hpp:70
void set_planar_threshold(data_type threshold)
Definition loam_feature_extractor.hpp:69
data_type get_curvature_threshold() const
Definition loam_feature_extractor.hpp:75
typename base_type::point_cloud point_cloud
Definition loam_feature_extractor.hpp:33
data_type get_planar_threshold() const
Definition loam_feature_extractor.hpp:74
typename base_type::point_cloud_ptr point_cloud_ptr
Definition loam_feature_extractor.hpp:34
void set_num_scan_neighbors(std::size_t num)
Definition loam_feature_extractor.hpp:71
void set_edge_threshold(data_type threshold)
Definition loam_feature_extractor.hpp:68
feature_label
Definition loam_feature_extractor.hpp:38
包含点和相关数据的点云类 / A point cloud class containing points and associated data
Definition point.hpp:268
Definition base_correspondence_generator.hpp:18
Definition loam_feature_extractor.hpp:45
point_cloud cloud
Definition loam_feature_extractor.hpp:46
std::vector< uint8_t > labels
Definition loam_feature_extractor.hpp:47