Skip to content

Commit 6342ff2

Browse files
authored
[Fix] Use poly_intersection instead of poly.intersection to avoid supurious warnings (#1811)
1 parent 4b88767 commit 6342ff2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mmocr/utils/polygon_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ def crop_polygon(polygon: ArrayLike,
156156
"""
157157
poly = poly_make_valid(poly2shapely(polygon))
158158
crop_poly = poly_make_valid(poly2shapely(bbox2poly(crop_box)))
159-
poly_cropped = poly.intersection(crop_poly)
160-
if poly_cropped.area == 0. or not isinstance(
159+
area, poly_cropped = poly_intersection(poly, crop_poly, return_poly=True)
160+
if area == 0 or area is None or not isinstance(
161161
poly_cropped, shapely.geometry.polygon.Polygon):
162-
# If polygon is outside crop_box region or the intersection is not a
163-
# polygon, return None.
164162
return None
165163
else:
166164
poly_cropped = poly_make_valid(poly_cropped)

0 commit comments

Comments
 (0)