mirror of
https://github.com/opencv/opencv.git
synced 2025-06-18 16:11:50 +08:00
Merge pull request #13214 from 1over:fix_rect
This commit is contained in:
commit
60b13d50c9
@ -1884,8 +1884,11 @@ Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b )
|
|||||||
template<typename _Tp> static inline
|
template<typename _Tp> static inline
|
||||||
Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b )
|
Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b )
|
||||||
{
|
{
|
||||||
a.width -= b.width;
|
const _Tp width = a.width - b.width;
|
||||||
a.height -= b.height;
|
const _Tp height = a.height - b.height;
|
||||||
|
CV_DbgAssert(width >= 0 && height >= 0);
|
||||||
|
a.width = width;
|
||||||
|
a.height = height;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1950,6 +1953,15 @@ Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b)
|
|||||||
return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height );
|
return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename _Tp> static inline
|
||||||
|
Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Size_<_Tp>& b)
|
||||||
|
{
|
||||||
|
const _Tp width = a.width - b.width;
|
||||||
|
const _Tp height = a.height - b.height;
|
||||||
|
CV_DbgAssert(width >= 0 && height >= 0);
|
||||||
|
return Rect_<_Tp>( a.x, a.y, width, height );
|
||||||
|
}
|
||||||
|
|
||||||
template<typename _Tp> static inline
|
template<typename _Tp> static inline
|
||||||
Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
|
Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
|
||||||
{
|
{
|
||||||
|
@ -972,6 +972,13 @@ bool CV_OperationsTest::operations1()
|
|||||||
if (sz.width != 10 || sz.height != 20) throw test_excep();
|
if (sz.width != 10 || sz.height != 20) throw test_excep();
|
||||||
if (cvSize(sz).width != 10 || cvSize(sz).height != 20) throw test_excep();
|
if (cvSize(sz).width != 10 || cvSize(sz).height != 20) throw test_excep();
|
||||||
|
|
||||||
|
Rect r1(0, 0, 10, 20);
|
||||||
|
Size sz1(5, 10);
|
||||||
|
r1 -= sz1;
|
||||||
|
if (r1.size().width != 5 || r1.size().height != 10) throw test_excep();
|
||||||
|
Rect r2 = r1 - sz1;
|
||||||
|
if (r2.size().width != 0 || r2.size().height != 0) throw test_excep();
|
||||||
|
|
||||||
Vec<double, 5> v5d(1, 1, 1, 1, 1);
|
Vec<double, 5> v5d(1, 1, 1, 1, 1);
|
||||||
Vec<double, 6> v6d(1, 1, 1, 1, 1, 1);
|
Vec<double, 6> v6d(1, 1, 1, 1, 1, 1);
|
||||||
Vec<double, 7> v7d(1, 1, 1, 1, 1, 1, 1);
|
Vec<double, 7> v7d(1, 1, 1, 1, 1, 1, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user