File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
modules/core/include/opencv2/core Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -1803,12 +1803,17 @@ Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
1803
1803
template <typename _Tp> static inline
1804
1804
Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
1805
1805
{
1806
- _Tp x1 = std::min (a.x , b.x );
1807
- _Tp y1 = std::min (a.y , b.y );
1808
- a.width = std::max (a.x + a.width , b.x + b.width ) - x1;
1809
- a.height = std::max (a.y + a.height , b.y + b.height ) - y1;
1810
- a.x = x1;
1811
- a.y = y1;
1806
+ if (!a.area ()) {
1807
+ a = b;
1808
+ }
1809
+ else if (b.area ()) {
1810
+ _Tp x1 = std::min (a.x , b.x );
1811
+ _Tp y1 = std::min (a.y , b.y );
1812
+ a.width = std::max (a.x + a.width , b.x + b.width ) - x1;
1813
+ a.height = std::max (a.y + a.height , b.y + b.height ) - y1;
1814
+ a.x = x1;
1815
+ a.y = y1;
1816
+ }
1812
1817
return a;
1813
1818
}
1814
1819
You can’t perform that action at this time.
0 commit comments