OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 29 Jan 2018 03:05:37 -0600how to know the area of the overlapping rectangles?http://answers.opencv.org/question/183324/how-to-know-the-area-of-the-overlapping-rectangles/ As a start i have the coordinates x1,y1 and x2,y2 of a rectangle, on the other hand i have a list of other coordinates for other rectangles.
What i want to do is compare the value of the one i already have over an image to the other ones and see if any overlap with it, and in case any do i want to check if the overlap area is equal to 50% of the original rectangle, this is all just part of the work that came before and shall come after but it's been difficult for me to work on even tho i checked numerous resources like https://codereview.stackexchange.com/questions/151309/check-if-two-rectangles-overlap https://codereview.stackexchange.com/questions/31352/overlapping-rectangles, any guidance do fulfill the described issue would be helpful.Sat, 27 Jan 2018 10:15:47 -0600http://answers.opencv.org/question/183324/how-to-know-the-area-of-the-overlapping-rectangles/Answer by VxW for <p>As a start i have the coordinates x1,y1 and x2,y2 of a rectangle, on the other hand i have a list of other coordinates for other rectangles.</p>
<p>What i want to do is compare the value of the one i already have over an image to the other ones and see if any overlap with it, and in case any do i want to check if the overlap area is equal to 50% of the original rectangle, this is all just part of the work that came before and shall come after but it's been difficult for me to work on even tho i checked numerous resources like <a href="https://codereview.stackexchange.com/questions/151309/check-if-two-rectangles-overlap">https://codereview.stackexchange.com/...</a> <a href="https://codereview.stackexchange.com/questions/31352/overlapping-rectangles">https://codereview.stackexchange.com/...</a>, any guidance do fulfill the described issue would be helpful.</p>
http://answers.opencv.org/question/183324/how-to-know-the-area-of-the-overlapping-rectangles/?answer=183419#post-id-183419"The formula for intersection will be
SI= Max(0, Min(XA2, XB2) - Max(XA1, XB1)) * Max(0, Min(YA2, YB2) - Max(YA1, YB1))
then the union will be S=SA+SB-SI
And finally, the ratio will be SI / S."
found in this blog: https://stackoverflow.com/questions/9324339/how-much-do-two-rectangles-overlap
Mon, 29 Jan 2018 03:05:37 -0600http://answers.opencv.org/question/183324/how-to-know-the-area-of-the-overlapping-rectangles/?answer=183419#post-id-183419