docstr: _bitmap: single map with shape (H, W),
      whose values are binarized as {0, 1}
docstr_tok: ["_bitmap",":","single","map","with","shape","(","H",",","W",")",",","whose","values","are","binarized","as","{","0",",","1","}"]
code: def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
      """
      _bitmap: single map with shape (H, W),
          whose values are binarized as {0, 1}
      """
  
      assert len(_bitmap.shape) == 2
      bitmap = _bitmap  # The first channel
      height, width = bitmap.shape
      contours, _ = cv2.findContours(
          (bitmap * 255).astype(np.uint8),
          cv2.RETR_LIST,
          cv2.CHAIN_APPROX_SIMPLE,
      )
      num_contours = min(len(contours), self.max_candidates)
      boxes = np.zeros((num_contours, 4, 2), dtype=np.int16)
      scores = np.zeros((num_contours,), dtype=np.float32)
  
      for index in range(num_contours):
          contour = contours[index].squeeze(1)
          points, sside = self.get_mini_boxes(contour)
          if sside < self.min_size:
              continue
          points = np.array(points)
          score = self.box_score_fast(pred, contour)
          if self.box_thresh > score:
              continue
  
          box = self.unclip(
              points, unclip_ratio=self.unclip_ratio
          ).reshape(-1, 1, 2)
          box, sside = self.get_mini_boxes(box)
          if sside < self.min_size + 2:
              continue
          box = np.array(box)
          if not isinstance(dest_width, int):
              dest_width = dest_width.item()
              dest_height = dest_height.item()
  
          box[:, 0] = np.clip(
              np.round(box[:, 0] / width * dest_width), 0, dest_width
          )
          box[:, 1] = np.clip(
              np.round(box[:, 1] / height * dest_height), 0, dest_height
          )
          boxes[index, :, :] = box.astype(np.int16)
          scores[index] = score
      return boxes, scores
  
file_path: PaddleOCR/benchmark/PaddleOCR_DBNet/post_processing/seg_detector_representer.py
imports: import cv2
  import numpy
  import pyclipper
  import paddle
  from shapely.geometry import Polygon
label_desc: Use image node_id 5 for calling the SegDetectorRepresenter obj's underlying member method code with example usage: obj.boxes_from_bitmap(pred, _bitmap, dest_width, dest_height) and returns: boxes,  scores