提交 917606b4 编写于 作者: z37757's avatar z37757

modify poly_intersection

上级 d8dfdc92
...@@ -133,7 +133,7 @@ class RandomCropFlip: ...@@ -133,7 +133,7 @@ class RandomCropFlip:
fail_flag = False fail_flag = False
for polygon, ignore_tag in zip(polygons, ignore_tags): for polygon, ignore_tag in zip(polygons, ignore_tags):
ppi = Polygon(polygon.reshape(-1, 2)) 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 \ if np.abs(ppiou - float(ppi.area)) > self.epsilon and \
np.abs(ppiou) > self.epsilon: np.abs(ppiou) > self.epsilon:
fail_flag = True fail_flag = True
......
...@@ -36,7 +36,7 @@ def points2polygon(points): ...@@ -36,7 +36,7 @@ def points2polygon(points):
return Polygon(point_mat) 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. """Calculate the intersection area between two polygon.
Args: Args:
...@@ -49,7 +49,10 @@ def poly_intersection(poly_det, poly_gt): ...@@ -49,7 +49,10 @@ def poly_intersection(poly_det, poly_gt):
assert isinstance(poly_det, Polygon) assert isinstance(poly_det, Polygon)
assert isinstance(poly_gt, 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 return poly_inter.area, poly_inter
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册