mirror of
https://github.com/opencv/opencv.git
synced 2026-11-18 15:28:14 -06:00
Rect_::operator&= computed width - (Rx_max.x - Rx_min.x) before knowing whether
the rectangles actually overlap. For unsigned _Tp the subtraction wraps when the
rectangles are disjoint, so the result was a bogus non-empty rectangle instead of
an empty one:
Rect_<unsigned>(0, 0, 1, 1) & Rect_<unsigned>(2, 2, 1, 1) // was [1 x 1 from (2, 2)]
Return an empty rectangle once the coordinate gap exceeds the corresponding
width/height, before the subtraction can underflow.