mmocr.utils.poly_union¶
- mmocr.utils.poly_union(poly_a, poly_b, invalid_ret=None, return_poly=False)[source]¶
Calculate the union area between two polygons.
- Parameters
poly_a (Polygon) – Polygon a.
poly_b (Polygon) – Polygon b.
invalid_ret (float or int, optional) – The return value when the invalid polygon exists. If it is not specified, the function allows the computation to proceed with invalid polygons by cleaning the their self-touching or self-crossing parts. Defaults to False.
return_poly (bool) – Whether to return the polygon of the union. Defaults to False.
- Returns
Returns a tuple
(area, Optional[poly_obj])
, where the area is the union between two polygons and poly_obj is the Polygon or MultiPolygon object of the union of the inputs. The type of object depends on whether they intersect or not. Set as None if the input is invalid. poly_obj will be returned only if return_poly is True.- Return type