code: def iou_rotate(box_a, box_b, method="union"):
      rect_a = cv2.minAreaRect(box_a)
      rect_b = cv2.minAreaRect(box_b)
      r1 = cv2.rotatedRectangleIntersection(rect_a, rect_b)
      if r1[0] == 0:
          return 0
      else:
          inter_area = cv2.contourArea(r1[1])
          area_a = cv2.contourArea(box_a)
          area_b = cv2.contourArea(box_b)
          union_area = area_a + area_b - inter_area
          if union_area == 0 or inter_area == 0:
              return 0
          if method == "union":
              iou = inter_area / union_area
          elif method == "intersection":
              iou = inter_area / min(area_a, area_b)
          else:
              raise NotImplementedError
          return iou
  
file_path: PaddleOCR/benchmark/PaddleOCR_DBNet/utils/ocr_metric/icdar2015/detection/iou.py
imports: from collections import namedtuple
  import numpy
  from shapely.geometry import Polygon
  import cv2
label_desc: Use image node_id 1 for calling a global function with example usage: iou_rotate(box_a, box_b, method) and returns: int, iou, int