提交 99e20d21 编写于 作者: K kechxu 提交者: Jiangtao Hu

Perception: add convex_hull_2d_test

上级 7d00fae1
......@@ -414,6 +414,10 @@ class AttributePointCloud : public PointCloud<PointT> {
std::vector<double>* mutable_points_timestamp() { return &points_timestamp_; }
const std::vector<float>& points_height() const { return points_height_; }
float points_height(size_t i) const { return points_height_[i]; }
void SetPointHeight(size_t i, size_t j, float height) {
points_height_[i * width_ + j] = height;
}
std::vector<float>* mutable_points_height() { return &points_height_; }
const std::vector<int32_t>& points_beam_id() const { return points_beam_id_; }
......
......@@ -101,4 +101,17 @@ cc_test(
],
)
cc_test(
name = "convex_hull_2d_test",
size = "small",
srcs = [
"convex_hull_2d_test.cc",
],
deps = [
":convex_hull_2d",
"//modules/perception/base:point_cloud",
"@gtest//:main",
],
)
cpplint()
......@@ -17,16 +17,19 @@
#include <cfloat>
#include <limits>
#include <memory>
#include "gtest/gtest.h"
#include "modules/perception/base/point.h"
#include "modules/perception/base/point_cloud.h"
namespace apollo {
namespace perception {
namespace common {
using PointF = apollo::perception::base::PointXYZIT<float>;
using PointFCloud = apollo::perception::base::PointCloud<PointF>;
using apollo::perception::base::PointF;
using PointFCloud = apollo::perception::base::AttributePointCloud<PointF>;
using PointFCloudPtr = std::shared_ptr<PointFCloud>;
TEST(ConvexHull2DTest, convex_hull_2d) {
ConvexHull2D<PointFCloud, PointFCloud> convex_hull_2d;
......@@ -34,10 +37,9 @@ TEST(ConvexHull2DTest, convex_hull_2d) {
bool flag = true;
flag = convex_hull_2d.GetConvexHull(pointcloud_in, &pointcloud_out);
EXPECT_FALSE(flag);
// float heigh = 0.0f;
PointF pt;
for (size_t i = 0; i < 10; i++) {
for (size_t j = 0; j < 10; j++) {
PointF pt;
pt.x = i;
pt.y = j;
pt.z = 0.0;
......@@ -100,15 +102,14 @@ TEST(ConvexHull2DTest1, convex_hull_2d1) {
PointFCloudPtr(new PointFCloud(128, 128, PointF()));
PointFCloud pointcloud_out;
PointF tmp_pt;
// float heigh = 0.0f;
float height = 0.0f;
for (size_t i = 0; i < 128; i++) {
for (size_t j = 0; j < 128; j++) {
tmp_pt.x = 1.f * i;
tmp_pt.y = 1.f * j;
tmp_pt.z = 1.f * i;
float heigh = i * 1.0f;
*(pointcloud_in_ptr->at(i, j)) = tmp_pt;
*(pointcloud_in_ptr->points_height(i, j)) = heigh;
pointcloud_in_ptr->SetPointHeight(i, j, height);
}
}
bool flag = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册