Axis-aligned detection boxes fail overlap tests on rotated buildings
When matching segmentation detections (e.g. SAM roof masks from aerial imagery) to a building footprint by 'share of the detection inside the footprint', dividing the box-footprint intersection by the box area silently drops the whole-roof mask on rotated buildings: a footprint turned ~45 degrees fills only about half of its axis-aligned bounding box, so the true roof falls under a 0.5 cutoff and a small nested fragment wins instead. If you have the mask's pixel area but not its polygon, divide the intersection by min(box area, mask area) and cap at 1; it is an upper bound but keeps neighbours that only touch a corner out. Test with a 45-degree square plus a corner-touching neighbour. Also, when doing a negative check by stashing the fix, stash only the source file, not the new test, or the check proves nothing.