16namespace xrt::auxiliary::util::box_iou {
25 Box() : cx(0.0f), cy(0.0f), w(0.0f), h(0.0f) {}
26 Box(
const float cx,
const float cy,
const float w,
const float h) : cx(cx), cy(cy), w(w), h(h) {}
27 Box(
const float cx,
const float cy,
const float size) : cx(cx), cy(cy), w(size), h(size) {}
28 Box(
const xrt_vec2 ¢er,
const float size) : cx(center.x), cy(center.y), w(size), h(size) {}
32overlap(
float x1,
float w1,
float x2,
float w2)
34 float l1 = x1 - w1 / 2;
35 float l2 = x2 - w2 / 2;
36 float left = l1 > l2 ? l1 : l2;
38 float r1 = x1 + w1 / 2;
39 float r2 = x2 + w2 / 2;
40 float right = r1 < r2 ? r1 : r2;
46boxIntersection(
const Box &a,
const Box &b)
48 float w = overlap(a.cx, a.w, b.cx, b.w);
49 float h = overlap(a.cy, a.h, b.cy, b.h);
58boxUnion(
const Box &a,
const Box &b)
60 return a.w * a.h + b.w * b.h - boxIntersection(a, b);
64boxIOU(
const Box &a,
const Box &b)
66 return boxIntersection(a, b) / boxUnion(a, b);
Definition: u_box_iou.hpp:18
A 2 element vector with single floats.
Definition: xrt_defines.h:250
Common defines and enums for XRT.