Reputation: 561
I have two rectangles, each identified by a set of four coordinates. I've read up on how to see whether they intersect, but how can I calculate the area of the intersection? The rectangles are not axis-aligned.
Is there an OpenCV function for this? I was told there was, but I fail to find it.
Upvotes: 8
Views: 2707
Reputation: 275
You can easily convert the Qt libraries code for that in order to be used with OpenCV.
Look for this function:
QRect QRect::operator&(const QRect &r) const
In qrect.cpp.
Upvotes: 1
Reputation: 500157
Treat your rectangles as general polygons, and decompose the problem into two steps:
There's plenty of literature on the Web for both problems.
I don't know anything about OpenCV so can't give any advice there.
Upvotes: 2