pcod-common v1.0.0
Shared preprocessing and postprocessing for point-cloud object detection
Loading...
Searching...
No Matches
test_bounding_box.cpp File Reference
#include "pcod_common/bounding_box.hpp"
#include <cassert>
#include <cmath>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Run bounding-box geometry regression checks.

Definition at line 31 of file test_bounding_box.cpp.

31 {
32 const pcod_common::BoundingBox base = MakeBox(0.0f, 0.0f, 4.0f, 2.0f, 0.0f);
33
34 {
35 const pcod_common::BoundingBox same = MakeBox(0.0f, 0.0f, 4.0f, 2.0f, 0.0f);
36 const float area_a = base.intersection_area(same);
37 const float area_b = same.intersection_area(base);
38 assert(std::abs(area_a - area_b) < 1e-6f);
39 assert(std::abs(area_a - (base.length * base.width)) < 1e-6f);
40 assert(base.overlaps(same, 0.99f));
41 }
42
43 {
44 const pcod_common::BoundingBox far = MakeBox(100.0f, 100.0f, 4.0f, 2.0f, 0.0f);
45 assert(base.intersection_area(far) == 0.0f);
46 assert(!base.overlaps(far, 0.0f));
47 }
48
49 {
50 const pcod_common::BoundingBox shifted = MakeBox(1.0f, 0.0f, 4.0f, 2.0f, 0.0f);
51 const float area_forward = base.intersection_area(shifted);
52 const float area_reverse = shifted.intersection_area(base);
53 assert(area_forward > 0.0f);
54 assert(std::abs(area_forward - area_reverse) < 1e-6f);
55 }
56
57 {
58 const pcod_common::BoundingBox rotated = MakeBox(0.0f, 0.0f, 4.0f, 2.0f, 1.57079632679f);
59 const float area = base.intersection_area(rotated);
60 assert(area > 0.0f);
61 assert(area < base.length * base.width);
62 }
63
64 return 0;
65}
float length
Length along the local X axis.
float intersection_area(const BoundingBox &other) const
float width
Width along the local Y axis.
bool overlaps(const BoundingBox &other, float iou_threshold) const

References pcod_common::BoundingBox::intersection_area(), pcod_common::BoundingBox::length, pcod_common::BoundingBox::overlaps(), and pcod_common::BoundingBox::width.