code: def draw_ocr(
      image,
      boxes,
      txts,
      scores,
      font_file,
      draw_txt=True,
      drop_score=0.5,
  ):
      """
      Visualize the results of OCR detection and recognition
      args:
          image(Image|array): RGB image
          boxes(list): boxes with shape(N, 4, 2)
          txts(list): the texts
          scores(list): txxs corresponding scores
          draw_txt(bool): whether draw text or not
          drop_score(float): only scores greater than drop_threshold will be visualized
      return(array):
          the visualized img
      """
      if scores is None:
          scores = [1] * len(boxes)
      for box, score in zip(boxes, scores):
          if score < drop_score or math.isnan(score):
              continue
          box = np.reshape(np.array(box), [-1, 1, 2]).astype(np.int64)
          image = cv2.polylines(
              np.array(image), [box], True, (255, 0, 0), 2
          )
  
      if draw_txt:
          img = np.array(resize_img(image, input_size=600))
          txt_img = text_visual(
              txts,
              scores,
              font_file,
              img_h=img.shape[0],
              img_w=600,
              threshold=drop_score,
          )
          img = np.concatenate(
              [np.array(img), np.array(txt_img)], axis=1
          )
          return img
      return image
  
file_path: PaddleHub/modules/image/text_recognition/chinese_ocr_db_crnn_mobile/utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import base64
  import math
  from io import BytesIO
  import cv2
  import numpy
  from PIL import Image
  from PIL import ImageDraw
  from PIL import ImageFont
label_desc: Use image node_id 1 for calling a global function with example usage: draw_ocr(image, boxes, txts, scores, font_file, draw_txt, drop_score) and returns: image, img