Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 检查两个CvRect*变量之间是否存在重叠_Opencv_Overlapping_Drawrectangle - Fatal编程技术网

Opencv 检查两个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

我想检查两个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>& 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