Implement match_anchors(anchors, gt_boxes, pos_threshold=0.5, neg_threshold=0.4), the anchor-to-ground-truth matcher used by one-stage detectors.
anchors: (N, 4) and gt_boxes: (M, 4), xyxy format [x1, y1, x2, y2]; lists or NumPy arrays.Procedure:
(N, M): ; an empty intersection or a zero-area union gives 0.pos_threshold → 1 with matched_gt = argmax GT; IoU neg_threshold → 0; otherwise ignore, -1. Non-positive anchors get matched_gt = -1.j in order, its highest-IoU anchor becomes 1 with matched_gt = j, even below pos_threshold; a later j overrides an earlier one on the same anchor.Edge cases: M = 0 → all anchors 0 with matched_gt = -1; N = 0 → two empty int arrays of shape (0,).
Return (labels, matched_gt): integer np.ndarrays of shape (N,); labels take values in {1, 0, -1}.