17namespace xrt::auxiliary::util::box_iou {
28 Box() : cx(0.0f), cy(0.0f), w(0.0f), h(0.0f) {}
29 Box(
float cx,
float cy,
float w,
float h) : cx(cx), cy(cy), w(w), h(h) {}
30 Box(
float cx,
float cy,
float size) : cx(cx), cy(cy), w(size), h(size) {}
31 Box(
const xrt_vec2 ¢er,
const float size) : cx(center.x), cy(center.y), w(size), h(size) {}
35overlap(
float x1,
float w1,
float x2,
float w2)
38 float l1 = x1 - w1 / 2;
39 float l2 = x2 - w2 / 2;
40 float left = std::max(l1, l2);
44 float r1 = x1 + w1 / 2;
45 float r2 = x2 + w2 / 2;
46 float right = std::min(r1, r2);
52boxIntersection(
const Box &a,
const Box &b)
54 float w = overlap(a.cx, a.w, b.cx, b.w);
55 float h = overlap(a.cy, a.h, b.cy, b.h);
64boxUnion(
const Box &a,
const Box &b)
66 return a.w * a.h + b.w * b.h - boxIntersection(a, b);
73 return boxIntersection(a, b) / boxUnion(a, b);
2D Box defined by center and size (width and height)
Definition u_box_iou.hpp:21
A 2 element vector with single floats.
Definition xrt_defines.h:279
static float boxIOU(const Box &a, const Box &b)
Ratio of box intersection area vs box union area (Intersection Over Union)
Definition u_box_iou.hpp:71
Common defines and enums for XRT.