Opencv 检查两个CvRect*变量之间是否存在重叠
我想检查两个CvRect*变量之间是否有任何部分重叠。Opencv 检查两个CvRect*变量之间是否存在重叠,opencv,overlapping,drawrectangle,Opencv,Overlapping,Drawrectangle,我想检查两个CvRect*变量之间是否有任何部分重叠。 是否有内置的opencv函数来执行此检查。我用的是opencv的c版本。opencv没有用于此的c API。C++方式简单地是代码> R1& R2< /代码>。&=的OpenCV源代码是 template<typename _Tp> static inline Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp&g
是否有内置的opencv函数来执行此检查。我用的是opencv的c版本。opencv没有用于此的c API。C++方式简单地是代码> R1& R2< /代码>。
&=
的OpenCV源代码是
template<typename _Tp> static inline Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
{
_Tp x1 = std::max(a.x, b.x), y1 = std::max(a.y, b.y);
a.width = std::min(a.x + a.width, b.x + b.width) - x1;
a.height = std::min(a.y + a.height, b.y + b.height) - y1;
a.x = x1; a.y = y1;
if( a.width <= 0 || a.height <= 0 )
a = Rect();
return a;
}
template静态内联Rect\u&运算符&=(Rect\u&a,const Rect\u&b)
{
_Tp-x1=std::max(a.x,b.x),y1=std::max(a.y,b.y);
a、 宽度=标准::最小(a.x+a.width,b.x+b.width)-x1;
a、 高度=标准::最小(a.y+a.height,b.y+b.height)-y1;
a、 x=x1;a.y=y1;
如果(a.宽度b.y)?a.y:b.y;
r、 宽度=(a.x+a.width 如果(R.Wield opencv)没有C API,C++方式简单地是代码> R1& R2< /代码>。
template<typename _Tp> static inline Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
{
_Tp x1 = std::max(a.x, b.x), y1 = std::max(a.y, b.y);
a.width = std::min(a.x + a.width, b.x + b.width) - x1;
a.height = std::min(a.y + a.height, b.y + b.height) - y1;
a.x = x1; a.y = y1;
if( a.width <= 0 || a.height <= 0 )
a = Rect();
return a;
}
template静态内联Rect\u&运算符&=(Rect\u&a,const Rect\u&b)
{
_Tp-x1=std::max(a.x,b.x),y1=std::max(a.y,b.y);
a、 宽度=标准::最小(a.x+a.width,b.x+b.width)-x1;
a、 高度=标准::最小(a.y+a.height,b.y+b.height)-y1;
a、 x=x1;a.y=y1;
如果(a.宽度b.y)?a.y:b.y;
r、 宽度=(a.x+a.width