docstr: Match process:
  pre-process : convert end2end and structure master results to xyxy, xywh ndnarray format.
  1. Use pseBbox is inside masterBbox judge rule
  2. Use iou between pseBbox and masterBbox rule
  3. Use min distance of center point rule
  :return:
docstr_tok: ["Match","process",":","pre-process",":","convert","end2end","and","structure","master","results","to","xyxy",",","xywh","ndnarray","format",".","1",".","Use","pseBbox","is","inside","masterBbox","judge","rule","2",".","Use","iou","between","pseBbox","and","masterBbox","rule","3",".","Use","min","distance","of","center","point","rule",":","return",":"]
code: def match(self):
      """
      Match process:
      pre-process : convert end2end and structure master results to xyxy, xywh ndnarray format.
      1. Use pseBbox is inside masterBbox judge rule
      2. Use iou between pseBbox and masterBbox rule
      3. Use min distance of center point rule
      :return:
      """
      match_results = dict()
      for idx, (file_name, end2end_result) in enumerate(
          self.end2end_results.items()
      ):
          match_list = []
          if file_name not in self.structure_master_results:
              continue
          structure_master_result = self.structure_master_results[
              file_name
          ]
          (
              end2end_xyxy_bboxes,
              end2end_xywh_bboxes,
              structure_master_xywh_bboxes,
              structure_master_xyxy_bboxes,
          ) = get_bboxes_list(end2end_result, structure_master_result)
  
          # rule 1: center rule
          center_rule_match_list = center_rule_match(
              end2end_xywh_bboxes, structure_master_xyxy_bboxes
          )
          match_list.extend(center_rule_match_list)
  
          # rule 2: iou rule
          # firstly, find not match index in previous step.
          center_no_match_end2end_indexs = find_no_match(
              match_list, len(end2end_xywh_bboxes), type="end2end"
          )
          if len(center_no_match_end2end_indexs) > 0:
              center_no_match_end2end_xyxy = end2end_xyxy_bboxes[
                  center_no_match_end2end_indexs
              ]
              # secondly, iou rule match
              iou_rule_match_list = iou_rule_match(
                  center_no_match_end2end_xyxy,
                  center_no_match_end2end_indexs,
                  structure_master_xyxy_bboxes,
              )
              match_list.extend(iou_rule_match_list)
  
          # rule 3: distance rule
          # match between no-match end2end bboxes and no-match master bboxes.
          # it will return master_bboxes_nums match-pairs.
          # firstly, find not match index in previous step.
          centerIou_no_match_end2end_indexs = find_no_match(
              match_list, len(end2end_xywh_bboxes), type="end2end"
          )
          centerIou_no_match_master_indexs = find_no_match(
              match_list,
              len(structure_master_xywh_bboxes),
              type="master",
          )
          if (
              len(centerIou_no_match_master_indexs) > 0
              and len(centerIou_no_match_end2end_indexs) > 0
          ):
              centerIou_no_match_end2end_xywh = end2end_xywh_bboxes[
                  centerIou_no_match_end2end_indexs
              ]
              centerIou_no_match_master_xywh = (
                  structure_master_xywh_bboxes[
                      centerIou_no_match_master_indexs
                  ]
              )
              distance_match_list = distance_rule_match(
                  centerIou_no_match_end2end_indexs,
                  centerIou_no_match_end2end_xywh,
                  centerIou_no_match_master_indexs,
                  centerIou_no_match_master_xywh,
              )
              match_list.extend(distance_match_list)
  
          # TODO:
          # The render no-match pseBbox, insert the last
          # After step3 distance rule, a master bbox at least match one end2end bbox.
          # But end2end bbox maybe overmuch, because numbers of master bbox will cut by max length.
          # For these render end2end bboxes, we will make some virtual master bboxes, and get matching.
          # The above extra insert bboxes will be further processed in "formatOutput" function.
          # After this operation, it will increase TEDS score.
          no_match_end2end_indexes = find_no_match(
              match_list, len(end2end_xywh_bboxes), type="end2end"
          )
          if len(no_match_end2end_indexes) > 0:
              no_match_end2end_xywh = end2end_xywh_bboxes[
                  no_match_end2end_indexes
              ]
              # sort the render no-match end2end bbox in row
              (
                  end2end_sorted_indexes_list,
                  end2end_sorted_bboxes_list,
                  sorted_groups,
                  sorted_bboxes_groups,
              ) = sort_bbox(
                  no_match_end2end_xywh, no_match_end2end_indexes
              )
              # make virtual master bboxes, and get matching with the no-match end2end bboxes.
              extra_match_list = extra_match(
                  end2end_sorted_indexes_list,
                  len(structure_master_xywh_bboxes),
              )
              match_list_add_extra_match = copy.deepcopy(match_list)
              match_list_add_extra_match.extend(extra_match_list)
          else:
              # no no-match end2end bboxes
              match_list_add_extra_match = copy.deepcopy(match_list)
              sorted_groups = []
              sorted_bboxes_groups = []
  
          match_result_dict = {
              "match_list": match_list,
              "match_list_add_extra_match": match_list_add_extra_match,
              "sorted_groups": sorted_groups,
              "sorted_bboxes_groups": sorted_bboxes_groups,
          }
  
          # format output
          match_result_dict = self._format(match_result_dict, file_name)
  
          match_results[file_name] = match_result_dict
  
      return match_results
  
imports: import os
  import re
  import cv2
  import glob
  import copy
  import math
  import pickle
  import numpy
  from shapely.geometry import Polygon, MultiPoint
label_desc: Use image node_id 2 for calling the Matcher obj's underlying member method code with example usage: obj.match() and returns: match_results