mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2026-09-24 23:33:08 +08:00
modify poly_intersection
This commit is contained in:
@@ -133,7 +133,7 @@ class RandomCropFlip:
|
||||
fail_flag = False
|
||||
for polygon, ignore_tag in zip(polygons, ignore_tags):
|
||||
ppi = Polygon(polygon.reshape(-1, 2))
|
||||
ppiou, _ = poly_intersection(ppi, pp)
|
||||
ppiou, _ = poly_intersection(ppi, pp, buffer=0)
|
||||
if np.abs(ppiou - float(ppi.area)) > self.epsilon and \
|
||||
np.abs(ppiou) > self.epsilon:
|
||||
fail_flag = True
|
||||
|
||||
@@ -36,7 +36,7 @@ def points2polygon(points):
|
||||
return Polygon(point_mat)
|
||||
|
||||
|
||||
def poly_intersection(poly_det, poly_gt):
|
||||
def poly_intersection(poly_det, poly_gt, buffer=0.0001):
|
||||
"""Calculate the intersection area between two polygon.
|
||||
|
||||
Args:
|
||||
@@ -49,7 +49,10 @@ def poly_intersection(poly_det, poly_gt):
|
||||
assert isinstance(poly_det, Polygon)
|
||||
assert isinstance(poly_gt, Polygon)
|
||||
|
||||
poly_inter = poly_det.buffer(0.001) & poly_gt.buffer(0.001)
|
||||
if buffer == 0:
|
||||
poly_inter = poly_det & poly_gt
|
||||
else:
|
||||
poly_inter = poly_det.buffer(buffer) & poly_gt.buffer(buffer)
|
||||
return poly_inter.area, poly_inter
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user