namespace
SushiAI::Detect
- Declared in
include/SushiAI/detect/anchors.hpp
Contains
Variables
constexpr float K_GRID_CELL_OFFSET = 0.5fHolds the distance from a cell's index to its centre, in grid units.
constexpr std::size_t K_BOX_VALUES = 4Holds the number of values in one box.
constexpr float K_IOU_EPS = 1e-7fHolds the term that keeps the IoU divisions away from zero.
Functions
std::int64_t count_anchors(SushiRuntime::span< const FeatureLevel > levels)Returns the number of anchors over levels, one per cell.
See also
include/SushiAI/detect/README.md
void make_anchors(SushiRuntime::span< const FeatureLevel > levels, SushiRuntime::span< float > points, SushiRuntime::span< float > strides)Writes each anchor's cell centre in grid units and its stride.
Parameters
pointsReceives
[A, 2]as x then y, levels in order, row-major in a level.stridesReceives
[A].
See also
include/SushiAI/detect/README.md
void scale_points(SushiRuntime::span< const float > points, SushiRuntime::span< const float > strides, SushiRuntime::span< float > scaled)Multiplies each anchor point by its stride, which gives the point in pixels.
Parameters
points[A, 2]in grid units.strides[A].scaledReceives
[A, 2]; may bepoints.
void decode_xyxy(SushiRuntime::span< const float > distances, SushiRuntime::span< const float > anchor_points, SushiRuntime::span< float > boxes)Decodes [B, A, 4] distances about [A, 2] anchor points into x1 y1 x2 y2.
Parameters
boxesReceives
[B, A, 4]in the units ofanchor_points; may bedistances.
See also
include/SushiAI/detect/README.md
void decode_xywh(SushiRuntime::span< const float > distances, SushiRuntime::span< const float > anchor_points, SushiRuntime::span< float > boxes)Decodes [B, A, 4] distances about [A, 2] anchor points into centre and size.
Parameters
boxesReceives
[B, A, 4]in the units ofanchor_points; may bedistances.
See also
include/SushiAI/detect/README.md
void encode_distances(SushiRuntime::span< const float > anchor_points, SushiRuntime::span< const float > boxes, SushiRuntime::span< float > distances)Encodes [B, A, 4] x1 y1 x2 y2 boxes as distances about [A, 2] anchor points.
Parameters
distancesReceives
[B, A, 4], not clamped; may beboxes.
See also
include/SushiAI/detect/README.md
void scale_boxes(SushiRuntime::span< const float > boxes, SushiRuntime::span< const float > strides, SushiRuntime::span< float > scaled)Multiplies [B, A, 4] boxes by the [A] stride of their anchor.
Parameters
scaledReceives
[B, A, 4]; may beboxes.
See also
include/SushiAI/detect/README.md
void xyxy_to_xywh(SushiRuntime::span< const float > boxes, SushiRuntime::span< float > converted)Converts [N, 4] boxes from x1 y1 x2 y2 to centre x, centre y, width, height.
Parameters
convertedReceives
[N, 4]; may beboxes.
See also
include/SushiAI/detect/README.md
void xywh_to_xyxy(SushiRuntime::span< const float > boxes, SushiRuntime::span< float > converted)Converts [N, 4] boxes from centre x, centre y, width, height to x1 y1 x2 y2.
Parameters
convertedReceives
[N, 4]; may beboxes.
See also
include/SushiAI/detect/README.md
float intersection_over_union(SushiRuntime::span< const float > box1, SushiRuntime::span< const float > box2) noexceptReturns the IoU of two boxes.
Precondition
Each span holds the four values of one box.
See also
include/SushiAI/detect/README.md
float complete_iou(SushiRuntime::span< const float > box1, SushiRuntime::span< const float > box2) noexceptReturns the complete IoU of two boxes, which is at most their IoU.
Precondition
Each span holds the four values of one box.
See also
include/SushiAI/detect/README.md
void elementwise_iou(SushiRuntime::span< const float > boxes1, SushiRuntime::span< const float > boxes2, SushiRuntime::span< float > ious)Writes the IoU of row i of boxes1 with row i of boxes2.
Parameters
iousReceives
[N]for two[N, 4]inputs.
void elementwise_complete_iou(SushiRuntime::span< const float > boxes1, SushiRuntime::span< const float > boxes2, SushiRuntime::span< float > ious)Writes the complete IoU of row i of boxes1 with row i of boxes2.
Parameters
iousReceives
[N]for two[N, 4]inputs.
void pairwise_iou(SushiRuntime::span< const float > boxes1, SushiRuntime::span< const float > boxes2, SushiRuntime::span< float > ious)Writes the IoU of every row of boxes1 with every row of boxes2.
Parameters
iousReceives
[N, M]for[N, 4]and[M, 4]inputs.
See also
include/SushiAI/detect/README.md
void join_level(SushiRuntime::span< const float > level, const LevelPlacement &placement, SushiRuntime::span< float > joined)Copies one level's [B, n, C] rows into their place in a [B, A, C] array.
Parameters
level[B, H, W, C]read as[B, n, C].joined[B, A, C]; only the level's rows are written.
See also
include/SushiAI/detect/README.md
void split_level(SushiRuntime::span< const float > joined, const LevelPlacement &placement, SushiRuntime::span< float > level)Copies one level's rows out of a [B, A, C] array into [B, n, C].
Parameters
joined[B, A, C].levelReceives
[B, n, C], which is[B, H, W, C]in row-major order.
See also
include/SushiAI/detect/README.md

