code: def draw_border_map(self, polygon, canvas, mask):
      polygon = np.array(polygon)
      assert polygon.ndim == 2
      assert polygon.shape[1] == 2
  
      polygon_shape = Polygon(polygon)
      if polygon_shape.area <= 0:
          return
      distance = (
          polygon_shape.area
          * (1 - np.power(self.shrink_ratio, 2))
          / polygon_shape.length
      )
      subject = [tuple(l) for l in polygon]
      padding = pyclipper.PyclipperOffset()
      padding.AddPath(
          subject, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON
      )
  
      padded_polygon = np.array(padding.Execute(distance)[0])
      cv2.fillPoly(mask, [padded_polygon.astype(np.int32)], 1.0)
  
      xmin = padded_polygon[:, 0].min()
      xmax = padded_polygon[:, 0].max()
      ymin = padded_polygon[:, 1].min()
      ymax = padded_polygon[:, 1].max()
      width = xmax - xmin + 1
      height = ymax - ymin + 1
  
      polygon[:, 0] = polygon[:, 0] - xmin
      polygon[:, 1] = polygon[:, 1] - ymin
  
      xs = np.broadcast_to(
          np.linspace(0, width - 1, num=width).reshape(1, width),
          (height, width),
      )
      ys = np.broadcast_to(
          np.linspace(0, height - 1, num=height).reshape(height, 1),
          (height, width),
      )
  
      distance_map = np.zeros(
          (polygon.shape[0], height, width), dtype=np.float32
      )
      for i in range(polygon.shape[0]):
          j = (i + 1) % polygon.shape[0]
          absolute_distance = self._distance(
              xs, ys, polygon[i], polygon[j]
          )
          distance_map[i] = np.clip(absolute_distance / distance, 0, 1)
      distance_map = distance_map.min(axis=0)
  
      xmin_valid = min(max(0, xmin), canvas.shape[1] - 1)
      xmax_valid = min(max(0, xmax), canvas.shape[1] - 1)
      ymin_valid = min(max(0, ymin), canvas.shape[0] - 1)
      ymax_valid = min(max(0, ymax), canvas.shape[0] - 1)
      canvas[
          ymin_valid : ymax_valid + 1, xmin_valid : xmax_valid + 1
      ] = np.fmax(
          1
          - distance_map[
              ymin_valid - ymin : ymax_valid - ymax + height,
              xmin_valid - xmin : xmax_valid - xmax + width,
          ],
          canvas[
              ymin_valid : ymax_valid + 1, xmin_valid : xmax_valid + 1
          ],
      )
  
file_path: PaddleOCR/ppocr/data/imaug/make_border_map.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import numpy
  import cv2
  import pyclipper
  from shapely.geometry import Polygon
  import sys
  import warnings
label_desc: Use image node_id 3 for calling the MakeBorderMap obj's underlying member method code with example usage: obj.draw_border_map(polygon, canvas, mask) without return types