pcod-common v1.0.0
Shared preprocessing and postprocessing for point-cloud object detection
Loading...
Searching...
No Matches
test_readme_example.cpp File Reference
#include "pcod_common/pbod_postprocess.hpp"
#include "pcod_common/pillar_grid.hpp"
#include "pcod_common/point_preprocess.hpp"
#include <cassert>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Run the README example as an executable regression check.

Definition at line 12 of file test_readme_example.cpp.

12 {
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}
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.

References pcod_common::BuildPillarGrid(), pcod_common::PbodOutputsView::class_logits, pcod_common::PbodPostprocessConfig::class_names, pcod_common::DecodePbod(), pcod_common::PbodOutputsView::focal_logits, pcod_common::PointPreprocessor::IsPointValid(), pcod_common::kValueThreshold, pcod_common::PointPreprocessConfig::normalization_type, pcod_common::PbodOutputsView::num_classes, pcod_common::PbodOutputsView::num_pillars, pcod_common::PbodOutputsView::reg_dim, pcod_common::PbodOutputsView::reg_logits, pcod_common::PbodPostprocessConfig::score_thresholds, pcod_common::PbodOutputsView::size_posterior, pcod_common::PointPreprocessConfig::value_threshold, pcod_common::PointPreprocessConfig::x_max, pcod_common::PointPreprocessConfig::x_min, pcod_common::PointPreprocessConfig::y_max, pcod_common::PointPreprocessConfig::y_min, pcod_common::PointPreprocessConfig::z_max, and pcod_common::PointPreprocessConfig::z_min.