Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can do the following checking to detect if there is intersection between the two rectangles or not

BOOL IsOverLap(RECT A, RECT B)
{
    //return true if there is overlapping between the two rectangles
    return ! (A.top > B.bottom || A.bottom < B.top || A.left > B.right || A.right < B.left);
}

you can do the following checking to detect if there is intersection between the two rectangles or not

BOOL IsOverLap(RECT A, RECT B)
{
    //return true if there is overlapping between the two rectangles
    return ! (A.top > B.bottom || A.bottom < B.top || A.left > B.right || A.right < B.left);
}

Edit 26/12/2016

And here it is the implemetation by using cv::Rect

BOOL IsOverLapCV(Rect A, Rect B)
{
    //return true if there is overlapping between the two rectangles
    return ! (A.y > (B.y + B.height) || (A.y + A.height) < B.y || A.x > (B.x + B.width) || (A.x + A.width) < B.x);
}