31 int downsample_factor) {
32 if (downsample_factor <= 0) {
35 for (
size_t i = 0; i < cloud_ptr->size(); ++i) {
36 int32_t beam_id = cloud_ptr->points_beam_id(i);
37 if (beam_id % downsample_factor == 0) {
39 double timestamp = cloud_ptr->points_timestamp(i);
40 float height = cloud_ptr->points_height(i);
41 uint8_t label = cloud_ptr->points_label(i);
42 out_cloud_ptr->push_back(point, timestamp, height, beam_id, label);
94 const int& min_num_points,
const bool& verbose) {
95 if (pc.
size() <=
static_cast<size_t>(min_num_points)) {
98 std::vector<cv::Point2f> pts;
99 float min_z = std::numeric_limits<float>::max();
100 float max_z = -std::numeric_limits<float>::max();
101 for (
size_t i = 0; i < pc.
size(); ++i) {
102 pts.push_back(cv::Point2f(pc[i].x, pc[i].y));
103 min_z = std::min(min_z, pc[i].z);
104 max_z = std::max(max_z, pc[i].z);
107 cv::RotatedRect mar = cv::minAreaRect(pts);
109 if (mar.size.width < mar.size.height) {
111 float tmp = mar.size.width;
112 mar.size.width = mar.size.height;
113 mar.size.height = tmp;
116 AINFO <<
"center = " << mar.center.x <<
" " << mar.center.y << std::endl;
117 AINFO <<
"size = " << mar.size.height <<
" " << mar.size.width << std::endl;
118 AINFO <<
"yaw = " << mar.angle << std::endl;
119 AINFO <<
"height = " << max_z - min_z << std::endl;
121 box->
x = mar.center.x;
122 box->
y = mar.center.y;
123 box->
z =
static_cast<float>((min_z + max_z) / 2.0);
124 box->
length = mar.size.width;
125 box->
width = mar.size.height;
126 box->
height = max_z - min_z;
127 box->
yaw =
static_cast<float>((M_PI * (mar.angle + 180)) / 180);