From 6342ff262c440f64eaae194f2f95ab142896a5b2 Mon Sep 17 00:00:00 2001
From: Tong Gao <gaotongxiao@gmail.com>
Date: Tue, 28 Mar 2023 16:20:50 +0800
Subject: [PATCH] [Fix] Use poly_intersection instead of poly.intersection to
 avoid supurious warnings (#1811)

---
 mmocr/utils/polygon_utils.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/mmocr/utils/polygon_utils.py b/mmocr/utils/polygon_utils.py
index 77b552e9..805404a6 100644
--- a/mmocr/utils/polygon_utils.py
+++ b/mmocr/utils/polygon_utils.py
@@ -156,11 +156,9 @@ def crop_polygon(polygon: ArrayLike,
     """
     poly = poly_make_valid(poly2shapely(polygon))
     crop_poly = poly_make_valid(poly2shapely(bbox2poly(crop_box)))
-    poly_cropped = poly.intersection(crop_poly)
-    if poly_cropped.area == 0. or not isinstance(
+    area, poly_cropped = poly_intersection(poly, crop_poly, return_poly=True)
+    if area == 0 or area is None or not isinstance(
             poly_cropped, shapely.geometry.polygon.Polygon):
-        # If polygon is outside crop_box region or the intersection is not a
-        # polygon, return None.
         return None
     else:
         poly_cropped = poly_make_valid(poly_cropped)