pcod-common v1.0.0
Shared preprocessing and postprocessing for point-cloud object detection
Loading...
Searching...
No Matches
bounding_box.hpp
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
4#pragma once
5
6#include <array>
7#include <vector>
8
9namespace pcod_common {
10
13 std::size_t class_idx;
14 float score;
15};
16
19 float x;
20 float y;
21
26 BoundingBoxVertex(float x_in = 0.0f, float y_in = 0.0f) : x(x_in), y(y_in) {}
27
29 BoundingBoxVertex operator+(const BoundingBoxVertex& v) const { return {x + v.x, y + v.y}; }
31 BoundingBoxVertex operator-(const BoundingBoxVertex& v) const { return {x - v.x, y - v.y}; }
33 float cross(const BoundingBoxVertex& v) const { return x * v.y - y * v.x; }
34};
35
37struct Line {
38 float a;
39 float b;
40 float c;
41
47 a = v2.y - v1.y;
48 b = v1.x - v2.x;
49 c = v2.cross(v1);
50 }
51
53 float operator()(const BoundingBoxVertex& p) const { return a * p.x + b * p.y + c; }
54
56 BoundingBoxVertex intersection(const Line& other) const {
57 float w = a * other.b - b * other.a;
58 return BoundingBoxVertex((b * other.c - c * other.b) / w, (c * other.a - a * other.c) / w);
59 }
60};
61
64 std::array<float, 2> center;
65 float z = 0.0f;
66 float length = 0.0f;
67 float width = 0.0f;
68 float height = 0.0f;
69 float yaw = 0.0f;
70 float existence_probability = 0.0f;
71 std::vector<ClassificationEntry> classification;
72 bool has_velocity = false;
73 float v_x = 0.0f;
74 float v_y = 0.0f;
75
77 bool overlaps(const BoundingBox& other, float iou_threshold) const;
79 float intersection_area(const BoundingBox& other) const;
81 std::vector<BoundingBoxVertex> rectangle_vertices() const;
82};
83
84} // namespace pcod_common
BoundingBoxVertex operator-(const BoundingBoxVertex &v) const
float cross(const BoundingBoxVertex &v) const
BoundingBoxVertex(float x_in=0.0f, float y_in=0.0f)
BoundingBoxVertex operator+(const BoundingBoxVertex &v) const
float length
Length along the local X axis.
std::vector< BoundingBoxVertex > rectangle_vertices() const
bool has_velocity
Whether velocity components are valid.
float intersection_area(const BoundingBox &other) const
float v_y
Y velocity when has_velocity is true.
std::array< float, 2 > center
XY center in metres.
float height
Height along the Z axis.
float z
Z center in metres.
float width
Width along the local Y axis.
float v_x
X velocity when has_velocity is true.
std::vector< ClassificationEntry > classification
Ranked semantic predictions.
float existence_probability
Detection confidence.
bool overlaps(const BoundingBox &other, float iou_threshold) const
float yaw
Heading in radians.
std::size_t class_idx
Zero-based model class index.
float score
Confidence assigned to the class.
BoundingBoxVertex intersection(const Line &other) const
float operator()(const BoundingBoxVertex &p) const
Line(const BoundingBoxVertex &v1, const BoundingBoxVertex &v2)
float a
X coefficient.
float b
Y coefficient.
float c
Constant term.