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)
| 23 | |
| 24 | |
| 25 | def 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 | |
| 45 | def poly_union(poly_det, poly_gt): |
no outgoing calls
no test coverage detected