parameters: (img, box, anchor_width=16, draw_img_gt=None)
return_statement: return result, draw_img_gt
docstring: calsulate ground truth fine-scale box
      :param img: input image
      :param box: ground truth box (4 point)
      :param anchor_width:
      :return: tuple (position, h, cy)
docstring_summary: calsulate ground truth fine-scale box
      :param img: input image
      :param box: ground truth box (4 point)
      :param anchor_width:
      :return: tuple (position, h, cy)
docstring_tokens: calsulate ground truth fine - scale box : param img : input image : param box : ground truth box ( 4 point ) : param anchor_width : : return : tuple ( position h cy )
function: def generate_gt_anchor(img, box, anchor_width=16, draw_img_gt=None):
      """
      calsulate ground truth fine-scale box
      :param img: input image
      :param box: ground truth box (4 point)
      :param anchor_width:
      :return: tuple (position, h, cy)
      """
      if not isinstance(box[0], float):
          box = [float(box[i]) for i in range(len(box))]
  
      result = []
      left_anchor_num = int(math.floor(max(min(box[0], box[6]), 0) / anchor_width))  # the left side anchor of the text box, downwards
      right_anchor_num = int(math.ceil(min(max(box[2], box[4]), img.shape[1]) / anchor_width))  # the right side anchor of the text box, upwards
  
      # handle extreme case, the right side anchor may exceed the image width
      if right_anchor_num * 16 + 15 > img.shape[1]:
          right_anchor_num -= 1
  
      # combine the left-side and the right-side x_coordinate of a text anchor into one pair
      position_pair = [(i * anchor_width, (i + 1) * anchor_width - 1) for i in range(left_anchor_num, right_anchor_num)]
      y_top, y_bottom = cal_y_top_and_bottom(img, position_pair, box)
  
      #print("image shape: %s, pair_num: %s, top_num:%s, bot_num:%s" % (img.shape, len(position_pair), len(y_top), len(y_bottom)))
  
      for i in range(len(position_pair)):
          position = int(position_pair[i][0] / anchor_width)  # the index of anchor box
          h = y_bottom[i] - y_top[i] + 1  # the height of anchor box
          cy = (float(y_bottom[i]) + float(y_top[i])) / 2.0  # the center point of anchor box
          result.append((position, cy, h))
          draw_img_gt = draw_image.draw_box_h_and_c(draw_img_gt, position, cy, h)
      draw_img_gt = draw_image.draw_box_4pt(draw_img_gt, box, color=(0, 0, 255), thickness=1)
      return result, draw_img_gt
function_tokens: def generate_gt_anchor ( img , box , anchor_width = 16 , draw_img_gt = None ) : if not isinstance ( box [ 0 ] , float ) : box = [ float ( box [ i ] ) for i in range ( len ( box ) ) ] result = [ ] left_anchor_num = int ( math . floor ( max ( min ( box [ 0 ] , box [ 6 ] ) , 0 ) / anchor_width ) ) # the left side anchor of the text box, downwards right_anchor_num = int ( math . ceil ( min ( max ( box [ 2 ] , box [ 4 ] ) , img . shape [ 1 ] ) / anchor_width ) ) # the right side anchor of the text box, upwards # handle extreme case, the right side anchor may exceed the image width if right_anchor_num * 16 + 15 > img . shape [ 1 ] : right_anchor_num -= 1 # combine the left-side and the right-side x_coordinate of a text anchor into one pair position_pair = [ ( i * anchor_width , ( i + 1 ) * anchor_width - 1 ) for i in range ( left_anchor_num , right_anchor_num ) ] y_top , y_bottom = cal_y_top_and_bottom ( img , position_pair , box ) #print("image shape: %s, pair_num: %s, top_num:%s, bot_num:%s" % (img.shape, len(position_pair), len(y_top), len(y_bottom))) for i in range ( len ( position_pair ) ) : position = int ( position_pair [ i ] [ 0 ] / anchor_width ) # the index of anchor box h = y_bottom [ i ] - y_top [ i ] + 1 # the height of anchor box cy = ( float ( y_bottom [ i ] ) + float ( y_top [ i ] ) ) / 2.0 # the center point of anchor box result . append ( ( position , cy , h ) ) draw_img_gt = draw_image . draw_box_h_and_c ( draw_img_gt , position , cy , h ) draw_img_gt = draw_image . draw_box_4pt ( draw_img_gt , box , color = ( 0 , 0 , 255 ) , thickness = 1 ) return result , draw_img_gt