Apollo 11.0
自动驾驶开放平台
apollo::perception::lidar::NCut类 参考

#include <ncut.h>

apollo::perception::lidar::NCut 的协作图:

Public 成员函数

 NCut ()
 
 ~NCut ()
 
bool Init (const NCutParam &param)
 Init Ncut according to parameters
 
int NumSegments () const
 Get segmentation number
 
std::string GetSegmentLabel (int sid) const
 Get the segment label
 
void GetSegmentSize (int sid, float *length, float *width, float *height) const
 Get the segment size
 
base::PointFCloudPtr GetSegmentPointCloud (int sid) const
 Get the segment point cloud
 
void Segment (base::PointFCloudConstPtr cloud)
 Segmen main entrance
 
std::string GetPcRoughLabel (const base::PointFCloudPtr &cloud, bool only_check_pedestrian)
 Get the label of point cloud
 
void GetSegmentRoughSize (const base::PointFCloudPtr &cloud, float *length, float *width, float *height)
 Get the segment size
 

详细描述

在文件 ncut.h 第 41 行定义.

构造及析构函数说明

◆ NCut()

apollo::perception::lidar::NCut::NCut ( )

在文件 ncut.cc 第 48 行定义.

48{}

◆ ~NCut()

apollo::perception::lidar::NCut::~NCut ( )

在文件 ncut.cc 第 49 行定义.

49 {
50 ADEBUG << "NCut destructor done";
51}
#define ADEBUG
Definition log.h:41

成员函数说明

◆ GetPcRoughLabel()

std::string apollo::perception::lidar::NCut::GetPcRoughLabel ( const base::PointFCloudPtr &  cloud,
bool  only_check_pedestrian 
)

Get the label of point cloud

参数
cloudcluster of point cloud
only_check_pedestrian
返回
std::string

在文件 ncut.cc 第 749 行定义.

749 {
750 if (cloud->size() < OBSTACLE_MINIMUM_NUM_POINTS) {
751 return "unknown";
752 }
753 float x_max = -std::numeric_limits<float>::max();
754 float y_max = -std::numeric_limits<float>::max();
755 float x_min = std::numeric_limits<float>::max();
756 float y_min = std::numeric_limits<float>::max();
757 for (size_t i = 0; i < cloud->size(); ++i) {
758 base::PointF pt = (*cloud)[i];
759 x_min = std::min(x_min, pt.x);
760 x_max = std::max(x_max, pt.x);
761 y_min = std::min(y_min, pt.y);
762 y_max = std::max(y_max, pt.y);
763 }
764 float dummy_length = x_max - x_min;
765 float dummy_width = y_max - y_min;
766 float length = std::max(dummy_length, dummy_width);
767 float width = std::min(dummy_length, dummy_width);
768 std::string label = "unknown";
769 bool is_candidate = false;
770 if (only_check_pedestrian) {
771 if (IsPotentialPedestrianSize(length, width) || IsPotentialBicyclistSize(length, width)) {
772 is_candidate = true;
773 }
774 } else {
775 if (IsPotentialPedestrianSize(length, width) || IsPotentialBicyclistSize(length, width)
776 || IsPotentialCarSize(length, width)) {
777 is_candidate = true;
778 }
779 }
780 if (is_candidate) {
781 label = GetPcLabel(cloud);
782 }
783 return label;
784}
uint32_t width
Width of point cloud
Point< float > PointF
Definition point.h:56

◆ GetSegmentLabel()

std::string apollo::perception::lidar::NCut::GetSegmentLabel ( int  sid) const
inline

Get the segment label

参数
sidsegment index
返回
std::string

在文件 ncut.h 第 67 行定义.

67 {
68 return _segment_labels[sid];
69 }

◆ GetSegmentPointCloud()

base::PointFCloudPtr apollo::perception::lidar::NCut::GetSegmentPointCloud ( int  sid) const
inline

Get the segment point cloud

参数
sidsegment index
返回
base::PointFCloudPtr

在文件 ncut.h 第 90 行定义.

90 {
91 base::PointFCloudPtr pc = base::PointFCloudPtr(new base::PointFCloud(*_cloud_obstacles, _segment_pids[sid]));
92 return pc;
93 }
AttributePointCloud< PointF > PointFCloud
std::shared_ptr< PointFCloud > PointFCloudPtr

◆ GetSegmentRoughSize()

void apollo::perception::lidar::NCut::GetSegmentRoughSize ( const base::PointFCloudPtr &  cloud,
float *  length,
float *  width,
float *  height 
)

Get the segment size

参数
cloudsegment of pointcloud
lengthobject length
widthobject width
heightobject height

在文件 ncut.cc 第 786 行定义.

786 {
787 float x_max = -std::numeric_limits<float>::max();
788 float y_max = -std::numeric_limits<float>::max();
789 float z_max = -std::numeric_limits<float>::max();
790 float x_min = std::numeric_limits<float>::max();
791 float y_min = std::numeric_limits<float>::max();
792 float z_min = std::numeric_limits<float>::max();
793 for (size_t i = 0; i < cloud->size(); ++i) {
794 base::PointF pt = (*cloud)[i];
795 x_min = std::min(x_min, pt.x);
796 x_max = std::max(x_max, pt.x);
797 y_min = std::min(y_min, pt.y);
798 y_max = std::max(y_max, pt.y);
799 z_min = std::min(z_min, pt.z);
800 z_max = std::max(z_max, pt.z);
801 }
802 *length = (x_max - x_min);
803 *width = (y_max - y_min);
804 *height = (z_max - z_min);
805}
uint32_t height
Height of point cloud

◆ GetSegmentSize()

void apollo::perception::lidar::NCut::GetSegmentSize ( int  sid,
float *  length,
float *  width,
float *  height 
) const
inline

Get the segment size

参数
sidsegment index
lengthbox length
widthbox width
heightbox height

在文件 ncut.h 第 78 行定义.

78 {
79 NcutBoundingBox box = _segment_bbox[sid];
80 *length = std::get<1>(box) - std::get<0>(box);
81 *width = std::get<3>(box) - std::get<2>(box);
82 *height = std::get<5>(box) - std::get<4>(box);
83 }

◆ Init()

bool apollo::perception::lidar::NCut::Init ( const NCutParam &  param)

Init Ncut according to parameters

参数
param
返回
true
false

在文件 ncut.cc 第 53 行定义.

53 {
54 if (!Configure(param)) {
55 AERROR << "failed to load ncut config.";
56 return false;
57 }
58
59 _classifier.reset(new LRClassifier);
60 if (!_classifier->init()) {
61 AERROR << "failed to init FrameClassifierPipeline.";
62 return false;
63 }
64 return true;
65}
#define AERROR
Definition log.h:44

◆ NumSegments()

int apollo::perception::lidar::NCut::NumSegments ( ) const
inline

Get segmentation number

返回
int

在文件 ncut.h 第 58 行定义.

58 {
59 return static_cast<int>(_segment_pids.size());
60 }

◆ Segment()

void apollo::perception::lidar::NCut::Segment ( base::PointFCloudConstPtr  cloud)

Segmen main entrance

参数
cloud

在文件 ncut.cc 第 87 行定义.

87 {
88#ifdef DEBUG_NCUT
89 double start_t = omp_get_wtime();
90#endif
91 // .0 clear everything
92 _segment_pids.clear();
93 _segment_labels.clear();
94 _segment_bbox.clear();
95 _outlier_pids.clear();
96 _cluster_points.clear();
97 _cluster_bounding_box.clear();
98 _cluster_skeleton_points.clear();
99 _cluster_skeleton_features.clear();
100 std::vector<int> pids(cloud->size());
101 for (size_t i = 0; i < cloud->size(); ++i) {
102 pids[i] = static_cast<int>(i);
103 }
104 _cloud_obstacles = base::PointFCloudPtr(new base::PointFCloud(*cloud, pids));
105 AINFO << "cloud obstacle size in ncut segment is " << _cloud_obstacles->size();
106#ifdef DEBUG_NCUT
107 ADEBUG << "segment enter ... input cloud size " << cloud->size();
108// visualize_points(pids);
109#endif
110 // .1 super pixels
111 // super_pixels_felzenszwalb(cloud, _grid_radius, _super_pixel_cell_size,
112 // _cluster_points);
113 SuperPixelsFloodFill(cloud, _grid_radius, _super_pixel_cell_size, &_cluster_points);
114#ifdef DEBUG_NCUT
115 // visualize_segments_from_points(_cluster_points);
116 ADEBUG << "super pixels " << _cluster_points.size();
117 AINFO << "super pixels done " << omp_get_wtime() - start_t;
118 start_t = omp_get_wtime();
119#endif
120
121 // .2 precompute skeleton and bbox
122 PrecomputeAllSkeletonAndBbox();
123#ifdef DEBUG_NCUT
124 AINFO << "precompute skeleton and bbox done " << omp_get_wtime() - start_t;
125 start_t = omp_get_wtime();
126#endif
127 // .3 grach cut
128 std::vector<std::vector<int>> segment_clusters;
129 std::vector<std::string> segment_labels;
130 NormalizedCut(_ncuts_stop_threshold, true, &segment_clusters, &segment_labels);
131#ifdef DEBUG_NCUT
132 AINFO << "normalized_cut done, #segments " << segment_clusters.size() << ", time: " << omp_get_wtime() - start_t;
133 start_t = omp_get_wtime();
134#endif
135 // .4 _segment_pids;
136 for (size_t i = 0; i < segment_clusters.size(); ++i) {
137 std::vector<int> pids;
138 GetClustersPids(segment_clusters[i], &pids);
139 if (pids.size() > 0) {
140 _segment_pids.push_back(pids);
141 _segment_labels.push_back(segment_labels[i]);
142 NcutBoundingBox box;
143 GetComponentBoundingBox(segment_clusters[i], &box);
144 _segment_bbox.push_back(box);
145 }
146 }
147}
#define AINFO
Definition log.h:42

该类的文档由以下文件生成: