MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / poly_intersection

Function poly_intersection

tools/utils/poly_nms.py:25–42  ·  view source on GitHub ↗

Calculate the intersection area between two polygon. Args: poly_det (Polygon): A polygon predicted by detector. poly_gt (Polygon): A gt polygon. Returns: intersection_area (float): The intersection area between two polygons.

(poly_det, poly_gt, buffer=0.0001)

Source from the content-addressed store, hash-verified

23
24
25def poly_intersection(poly_det, poly_gt, buffer=0.0001):
26 """Calculate the intersection area between two polygon.
27
28 Args:
29 poly_det (Polygon): A polygon predicted by detector.
30 poly_gt (Polygon): A gt polygon.
31
32 Returns:
33 intersection_area (float): The intersection area between two polygons.
34 """
35 assert isinstance(poly_det, Polygon)
36 assert isinstance(poly_gt, Polygon)
37
38 if buffer == 0:
39 poly_inter = poly_det & poly_gt
40 else:
41 poly_inter = poly_det.buffer(buffer) & poly_gt.buffer(buffer)
42 return poly_inter.area, poly_inter
43
44
45def poly_union(poly_det, poly_gt):

Callers 2

poly_unionFunction · 0.85
poly_iouFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected