Note that a single ground-truth box may assign positive labels to
multiple anchors. Usually the second condition is sufficient to
determine the positive samples; but we still adopt the first condition
for the reason that in some rare cases the second condition may find
no positive sample. We assign a negative label to a non-positive
anchor if its IoU ratio is lower than 0.3 for all ground-truth boxes.
Anchors that are neither positive nor negative do not contribute to
the training objective. (Ren, et al., 2015)
There might be different approaches, but one of the hallmark papers does not shy away from using multiple positives from the same ground truth. Since this behavior will transfer over to inference, people use non-maximum suppression to remove predictions likely to cover the same object. You can tune the threshold used to define true positives and the threshold used to perform non-maximum suppression independently. This technique would not work if the boxes weren't touching. For that reason, let's reformulate the question: how small must our ground truth threshold be for this to occur?
To simplify the problem, let's assume three things.
- The boxes are the same size.
- They overlap diagonally.
- They overlap symmetrically.
For the two outer boxes to be considered ground truth, we need that
$$\mathrm{IoU}(B_1, B_2) = \frac{1 - 2 x + x^2}{1 + 2 x - x^2} \geq t$$ where $x$ denotes the offset between each outer box and the inner box, and $t$ the ground truth threshold. The boxes will stop overlapping when their corners meet in the middle, leading to the additional constraint
$$2x \geq 1$$ that we can use to solve for $t$. We get that $t \leq \frac{1}{7}$ can lead to this scenario, but the threshold is usually set to a greater value. For example, the paper above uses $t \geq \frac{1}{2}$. If use this value instead, we get
$$\mathrm{IoU}(B_1, B_3) = \frac{-4x^2 +4x-1}{4x^2-4x-1} \geq \frac{1}{71} (24 \sqrt{6} - 41) \approx 0.25.$$