pcod-common v1.0.0
Shared preprocessing and postprocessing for point-cloud object detection
Loading...
Searching...
No Matches
test_readme_example.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
7
8#include <cassert>
9#include <vector>
10
12int main() {
14 pre_cfg.x_min = -1.0f;
15 pre_cfg.x_max = 1.0f;
16 pre_cfg.y_min = -1.0f;
17 pre_cfg.y_max = 1.0f;
18 pre_cfg.z_min = -1.0f;
19 pre_cfg.z_max = 1.0f;
21 pre_cfg.value_threshold = 10.0f;
22
23 pcod_common::PointPreprocessor preprocessor(pre_cfg);
24 assert(preprocessor.IsPointValid(0.5f, 0.1f, 0.0f));
25
26 pcod_common::PillarGrid grid = pcod_common::BuildPillarGrid({2, 2}, {{{0.0f, 2.0f}, {0.0f, 2.0f}, {0.0f, 1.0f}}}, 1, 1);
27
28 const int num_pillars = 4;
29 const int num_classes = 2;
30 float focal_logits[num_pillars] = {2.0f, -2.0f, 2.0f, -2.0f};
31 std::vector<float> size_posterior(static_cast<std::size_t>(num_pillars * num_classes * 3), 1.0f);
32 float class_logits[num_pillars * num_classes] = {0.1f, 0.9f, 0.1f, 0.9f, 0.1f, 0.9f, 0.1f, 0.9f};
33 std::vector<float> reg_logits(static_cast<std::size_t>(num_pillars * num_classes * 7), 0.0f);
34
36 view.focal_logits = focal_logits;
37 view.size_posterior = size_posterior.data();
38 view.class_logits = class_logits;
39 view.reg_logits = reg_logits.data();
40 view.num_pillars = num_pillars;
41 view.num_classes = num_classes;
42 view.reg_dim = 7;
43
45 post_cfg.class_names = {"car", "pedestrian"};
46 post_cfg.score_thresholds = {0.5f};
47
48 auto boxes = pcod_common::DecodePbod(view, grid, post_cfg);
49 const std::size_t expected_boxes = 2;
50 assert(boxes.size() == expected_boxes);
51 return 0;
52}
bool IsPointValid(float x, float y, float z) const
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)
std::vector< BoundingBox > DecodePbod(const PbodOutputsView &outputs, const PillarGrid &grid, const PbodPostprocessConfig &config)
const float * focal_logits
Shape [num_pillars].
int num_classes
Number of semantic classes.
int reg_dim
Regression values per pillar and class.
int num_pillars
Number of spatial pillars.
const float * class_logits
Shape [num_pillars, num_classes].
const float * size_posterior
Shape [num_pillars, num_classes * 3].
const float * reg_logits
Shape [num_pillars, num_classes * reg_dim].
std::vector< float > score_thresholds
Per-class thresholds, or one shared threshold.
std::vector< std::string > class_names
Class name in model-output order.
float x_max
Maximum accepted X coordinate.
float value_threshold
Divisor for value-threshold normalization.
float y_min
Minimum accepted Y coordinate.
float z_min
Minimum accepted Z coordinate.
float x_min
Minimum accepted X coordinate.
float z_max
Maximum accepted Z coordinate.
float y_max
Maximum accepted Y coordinate.
PointFeatureNormalizationType normalization_type
Feature transform.
int main()