docstr: Generate text component attributes.
  
  Args:
      center_lines (list[ndarray]): The list of text center lines .
      text_mask (ndarray): The text region mask.
      center_region_mask (ndarray): The text center region mask.
      top_height_map (ndarray): The map on which the distance from points
          to top side lines will be drawn for each pixel in text center
          regions.
      bot_height_map (ndarray): The map on which the distance from points
          to bottom side lines will be drawn for each pixel in text
          center regions.
      sin_map (ndarray): The sin(theta) map where theta is the angle
          between vector (top point - bottom point) and vector (1, 0).
      cos_map (ndarray): The cos(theta) map where theta is the angle
          between vector (top point - bottom point) and vector (1, 0).
  
  Returns:
      pad_comp_attribs (ndarray): The padded text component attributes
          of a fixed size.
docstr_tok: ["Generate","text","component","attributes",".","Args",":","center_lines","(","list","[","ndarray","]",")",":","The","list","of","text","center","lines",".","text_mask","(","ndarray",")",":","The","text","region","mask",".","center_region_mask","(","ndarray",")",":","The","text","center","region","mask",".","top_height_map","(","ndarray",")",":","The","map","on","which","the","distance","from","points","to","top","side","lines","will","be","drawn","for","each","pixel","in","text","center","regions",".","bot_height_map","(","ndarray",")",":","The","map","on","which","the","distance","from","points","to","bottom","side","lines","will","be","drawn","for","each","pixel","in","text","center","regions",".","sin_map","(","ndarray",")",":","The","sin","(","theta",")","map","where","theta","is","the","angle","between","vector","(","top","point","-","bottom","point",")","and","vector","(","1",",","0",")",".","cos_map","(","ndarray",")",":","The","cos","(","theta",")","map","where","theta","is","the","angle","between","vector","(","top","point","-","bottom","point",")","and","vector","(","1",",","0",")",".","Returns",":","pad_comp_attribs","(","ndarray",")",":","The","padded","text","component","attributes","of","a","fixed","size","."]
code: def generate_comp_attribs(
      self,
      center_lines,
      text_mask,
      center_region_mask,
      top_height_map,
      bot_height_map,
      sin_map,
      cos_map,
  ):
      """Generate text component attributes.
  
      Args:
          center_lines (list[ndarray]): The list of text center lines .
          text_mask (ndarray): The text region mask.
          center_region_mask (ndarray): The text center region mask.
          top_height_map (ndarray): The map on which the distance from points
              to top side lines will be drawn for each pixel in text center
              regions.
          bot_height_map (ndarray): The map on which the distance from points
              to bottom side lines will be drawn for each pixel in text
              center regions.
          sin_map (ndarray): The sin(theta) map where theta is the angle
              between vector (top point - bottom point) and vector (1, 0).
          cos_map (ndarray): The cos(theta) map where theta is the angle
              between vector (top point - bottom point) and vector (1, 0).
  
      Returns:
          pad_comp_attribs (ndarray): The padded text component attributes
              of a fixed size.
      """
  
      assert isinstance(center_lines, list)
      assert (
          text_mask.shape
          == center_region_mask.shape
          == top_height_map.shape
          == bot_height_map.shape
          == sin_map.shape
          == cos_map.shape
      )
  
      center_lines_mask = np.zeros_like(center_region_mask)
      cv2.polylines(center_lines_mask, center_lines, 0, 1, 1)
      center_lines_mask = center_lines_mask * center_region_mask
      comp_centers = np.argwhere(center_lines_mask > 0)
  
      y = comp_centers[:, 0]
      x = comp_centers[:, 1]
  
      top_height = (
          top_height_map[y, x].reshape((-1, 1)) * self.comp_shrink_ratio
      )
      bot_height = (
          bot_height_map[y, x].reshape((-1, 1)) * self.comp_shrink_ratio
      )
      sin = sin_map[y, x].reshape((-1, 1))
      cos = cos_map[y, x].reshape((-1, 1))
  
      top_mid_points = comp_centers + np.hstack(
          [top_height * sin, top_height * cos]
      )
      bot_mid_points = comp_centers - np.hstack(
          [bot_height * sin, bot_height * cos]
      )
  
      width = (top_height + bot_height) * self.comp_w_h_ratio
      width = np.clip(width, self.min_width, self.max_width)
      r = width / 2
  
      tl = top_mid_points[:, ::-1] - np.hstack([-r * sin, r * cos])
      tr = top_mid_points[:, ::-1] + np.hstack([-r * sin, r * cos])
      br = bot_mid_points[:, ::-1] + np.hstack([-r * sin, r * cos])
      bl = bot_mid_points[:, ::-1] - np.hstack([-r * sin, r * cos])
      text_comps = np.hstack([tl, tr, br, bl]).astype(np.float32)
  
      score = np.ones((text_comps.shape[0], 1), dtype=np.float32)
      text_comps = np.hstack([text_comps, score])
      check_install("lanms", "lanms-neo")
      from lanms import merge_quadrangle_n9 as la_nms
  
      text_comps = la_nms(text_comps, self.text_comp_nms_thr)
  
      if text_comps.shape[0] >= 1:
          img_h, img_w = center_region_mask.shape
          text_comps[:, 0:8:2] = np.clip(
              text_comps[:, 0:8:2], 0, img_w - 1
          )
          text_comps[:, 1:8:2] = np.clip(
              text_comps[:, 1:8:2], 0, img_h - 1
          )
  
          comp_centers = np.mean(
              text_comps[:, 0:8].reshape((-1, 4, 2)), axis=1
          ).astype(np.int32)
          x = comp_centers[:, 0]
          y = comp_centers[:, 1]
  
          height = (
              top_height_map[y, x] + bot_height_map[y, x]
          ).reshape((-1, 1))
          width = np.clip(
              height * self.comp_w_h_ratio,
              self.min_width,
              self.max_width,
          )
  
          cos = cos_map[y, x].reshape((-1, 1))
          sin = sin_map[y, x].reshape((-1, 1))
  
          _, comp_label_mask = cv2.connectedComponents(
              center_region_mask, connectivity=8
          )
          comp_labels = (
              comp_label_mask[y, x].reshape((-1, 1)).astype(np.float32)
          )
  
          x = x.reshape((-1, 1)).astype(np.float32)
          y = y.reshape((-1, 1)).astype(np.float32)
          comp_attribs = np.hstack(
              [x, y, height, width, cos, sin, comp_labels]
          )
          comp_attribs = self.jitter_comp_attribs(
              comp_attribs, self.jitter_level
          )
  
          if comp_attribs.shape[0] < self.num_min_comps:
              num_rand_comps = (
                  self.num_min_comps - comp_attribs.shape[0]
              )
              rand_comp_attribs = self.generate_rand_comp_attribs(
                  num_rand_comps, 1 - text_mask
              )
              comp_attribs = np.vstack(
                  [comp_attribs, rand_comp_attribs]
              )
      else:
          comp_attribs = self.generate_rand_comp_attribs(
              self.num_min_comps, 1 - text_mask
          )
  
      num_comps = (
          np.ones((comp_attribs.shape[0], 1), dtype=np.float32)
          * comp_attribs.shape[0]
      )
      comp_attribs = np.hstack([num_comps, comp_attribs])
  
      if comp_attribs.shape[0] > self.num_max_comps:
          comp_attribs = comp_attribs[: self.num_max_comps, :]
          comp_attribs[:, 0] = self.num_max_comps
  
      pad_comp_attribs = np.zeros(
          (self.num_max_comps, comp_attribs.shape[1]), dtype=np.float32
      )
      pad_comp_attribs[: comp_attribs.shape[0], :] = comp_attribs
  
      return pad_comp_attribs
  
imports: import cv2
  import numpy
  from ppocr.utils.utility import check_install
  from numpy.linalg import norm
label_desc: Use image node_id 16 for calling the DRRGTargets obj's underlying member method code with example usage: obj.generate_comp_attribs(center_lines, text_mask, center_region_mask, top_height_map, bot_height_map, sin_map, cos_map) and returns: pad_comp_attribs