pcod-common v1.0.0
Shared preprocessing and postprocessing for point-cloud object detection
Loading...
Searching...
No Matches
test_pillar_grid.cpp
Go to the documentation of this file.
1// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
2// SPDX-License-Identifier: Apache-2.0
3
5
6#include <cassert>
7#include <cmath>
8
10int main() {
11 {
12 auto grid = pcod_common::BuildPillarGrid({2, 3}, {{{0.0f, 2.0f}, {0.0f, 3.0f}, {-1.0f, 1.0f}}}, 1, 1);
13 assert(grid.grid_x == 2);
14 assert(grid.grid_y == 3);
15
16 const float* center_00 = grid.center_at(0); // ix=0, iy=0
17 assert(std::abs(center_00[0] - 0.5f) < 1e-6f);
18 assert(std::abs(center_00[1] - 0.5f) < 1e-6f);
19
20 const float* center_02 = grid.center_at(2); // ix=0, iy=2
21 assert(std::abs(center_02[0] - 0.5f) < 1e-6f);
22 assert(std::abs(center_02[1] - 2.5f) < 1e-6f);
23
24 const float* center_10 = grid.center_at(3); // ix=1, iy=0
25 assert(std::abs(center_10[0] - 1.5f) < 1e-6f);
26 assert(std::abs(center_10[1] - 0.5f) < 1e-6f);
27
28 const float* center_12 = grid.center_at(5); // ix=1, iy=2
29 assert(std::abs(center_12[0] - 1.5f) < 1e-6f);
30 assert(std::abs(center_12[1] - 2.5f) < 1e-6f);
31 }
32
33 {
34 auto scaled = pcod_common::BuildPillarGrid({4, 4}, {{{0.0f, 4.0f}, {0.0f, 4.0f}, {-1.0f, 1.0f}}}, 1, 2);
35 assert(scaled.grid_x == 2);
36 assert(scaled.grid_y == 2);
37
38 const float* first = scaled.center_at(0);
39 const float* last = scaled.center_at(3);
40 assert(std::abs(first[0] - 1.0f) < 1e-6f);
41 assert(std::abs(first[1] - 1.0f) < 1e-6f);
42 assert(std::abs(last[0] - 3.0f) < 1e-6f);
43 assert(std::abs(last[1] - 3.0f) < 1e-6f);
44 }
45
46 return 0;
47}
PillarGrid BuildPillarGrid(const std::array< int, 2 > &pillar_map_size, const std::array< std::array< float, 2 >, 3 > &pillar_map_range, int first_up_stride, int stride)
int main()