最简单的编码方法如下:
cv::Rect BoundingBox;
int IntersectionArea = 0;
//insert Min-Max X,Y to create the BoundingBox
for (every y inside boundingbox)
for (every x inside boundingbox)
if (PointPolygonTest(x,y,Contour1) && PointPolygonTest(x,y,Contour2))
IntersectionArea++;
Run Code Online (Sandbox Code Playgroud)