I am trying to get the intersection of 2 rectangles. What happens if the 2 rectangles do not intersect at all ? Will it give me an error ? Because the output below is what I am getting. The limits are (0,0,1242,375). I don't know the rectangles I am passing in. I just want to keep those that intersect and to retain the intersection.
[1170 x 232 from (72, 0)]
[1242 x 375 from (0, 0)]
[1242 x 375 from (0, 0)]
[967 x 211 from (275, 0)]
[1242 x 375 from (0, 0)]
[1242 x 375 from (0, 0)]
[1242 x 375 from (0, 0)]
[2147449647 x 375 from (2147483647, 0)]
[1242 x 375 from (0, 0)]
I am using this temporary fix after the intersection operator to remove all erroneous rectangles
if (rect.tl().x < 0 || rect.tl().y < 0 || rect.br().x >= image.cols || rect.br().y >= image.rows
|| rect.area() >= image.cols * image.rows || rect.area() == 0)
↧