code: def saveImage(
      imagename,
      vis_dir,
      image,
      bboxes,
      affi_bboxes,
      region_scores,
      affinity_scores,
      confidence_mask,
  ):
      output_image = np.uint8(image.copy())
      output_image = cv2.cvtColor(output_image, cv2.COLOR_RGB2BGR)
      if len(bboxes) > 0:
          for i in range(len(bboxes)):
              _bboxes = np.int32(bboxes[i])
              for j in range(_bboxes.shape[0]):
                  cv2.polylines(
                      output_image,
                      [np.reshape(_bboxes[j], (-1, 1, 2))],
                      True,
                      (0, 0, 255),
                  )
  
          for i in range(len(affi_bboxes)):
              cv2.polylines(
                  output_image,
                  [
                      np.reshape(
                          affi_bboxes[i].astype(np.int32), (-1, 1, 2)
                      )
                  ],
                  True,
                  (255, 0, 0),
              )
  
      target_gaussian_heatmap_color = imgproc.cvt2HeatmapImg(
          region_scores
      )
      target_gaussian_affinity_heatmap_color = imgproc.cvt2HeatmapImg(
          affinity_scores
      )
      confidence_mask_gray = imgproc.cvt2HeatmapImg(confidence_mask)
  
      # overlay
      height, width, channel = image.shape
      overlay_region = cv2.resize(
          target_gaussian_heatmap_color, (width, height)
      )
      overlay_aff = cv2.resize(
          target_gaussian_affinity_heatmap_color, (width, height)
      )
  
      overlay_region = cv2.addWeighted(
          image.copy(), 0.4, overlay_region, 0.6, 5
      )
      overlay_aff = cv2.addWeighted(
          image.copy(), 0.4, overlay_aff, 0.6, 5
      )
  
      heat_map = np.concatenate([overlay_region, overlay_aff], axis=1)
  
      # synthtext
      if type(imagename) is not str:
          imagename = imagename[0].split("/")[-1][:-4]
  
      output = np.concatenate(
          [output_image, heat_map, confidence_mask_gray], axis=1
      )
      outpath = vis_dir + f"/{imagename}.jpg"
      if not os.path.exists(os.path.dirname(outpath)):
          os.makedirs(os.path.dirname(outpath), exist_ok=True)
  
      cv2.imwrite(outpath, output)
  
file_path: EasyOCR/trainer/craft/utils/util.py
imports: from collections import OrderedDict
  import os
  import cv2
  import numpy
  from data import imgproc
  from utils import craft_utils
label_desc: Use image node_id 3 for calling a global function with example usage: saveImage(imagename, vis_dir, image, bboxes, affi_bboxes, region_scores, affinity_scores, confidence_mask) without return types