docstr: Prepare ._gts and ._dts for evaluation based on params
  :return: None
docstr_tok: ["Prepare","._gts","and","._dts","for","evaluation","based","on","params",":","return",":","None"]
code: def _prepare(self):
      """
      Prepare ._gts and ._dts for evaluation based on params
      :return: None
      """
  
      def _toMask(anns, coco):
          # modify ann['segmentation'] by reference
          for ann in anns:
              rle = coco.annToRLE(ann)
              ann["segmentation"] = rle
  
      def _getIgnoreRegion(iid, coco):
          img = coco.imgs[iid]
  
          if not "ignore_regions_x" in img.keys():
              return None
  
          if len(img["ignore_regions_x"]) == 0:
              return None
  
          rgns_merged = []
          for region_x, region_y in zip(
              img["ignore_regions_x"], img["ignore_regions_y"]
          ):
              rgns = [iter(region_x), iter(region_y)]
              rgns_merged.append(
                  list(it.next() for it in itertools.cycle(rgns))
              )
          rles = maskUtils.frPyObjects(
              rgns_merged, img["height"], img["width"]
          )
          rle = maskUtils.merge(rles)
  
          return maskUtils.decode(rle)
  
      def _checkIgnore(dt, iregion):
          if iregion is None:
              return True
  
          bb = np.array(dt["bbox"]).astype(np.int)
          x1, y1, x2, y2 = bb[0], bb[1], bb[0] + bb[2], bb[1] + bb[3]
          x2 = min([x2, iregion.shape[1]])
          y2 = min([y2, iregion.shape[0]])
  
          if bb[2] * bb[3] == 0:
              return False
  
          crop_iregion = iregion[y1:y2, x1:x2]
  
          if crop_iregion.sum() == 0:
              return True
  
          if not "uv" in dt.keys():  # filtering boxes
              return (
                  crop_iregion.sum() / bb[2] / bb[3] < self.ignoreThrBB
              )
  
          # filtering UVs
          ignoremask = np.require(crop_iregion, requirements=["F"])
          uvmask = np.require(
              np.asarray(dt["uv"][0] > 0),
              dtype=np.uint8,
              requirements=["F"],
          )
          uvmask_ = maskUtils.encode(uvmask)
          ignoremask_ = maskUtils.encode(ignoremask)
          uviou = maskUtils.iou([uvmask_], [ignoremask_], [1])[0]
          return uviou < self.ignoreThrUV
  
      p = self.params
  
      if p.useCats:
          gts = self.cocoGt.loadAnns(
              self.cocoGt.getAnnIds(imgIds=p.imgIds, catIds=p.catIds)
          )
          dts = self.cocoDt.loadAnns(
              self.cocoDt.getAnnIds(imgIds=p.imgIds, catIds=p.catIds)
          )
      else:
          gts = self.cocoGt.loadAnns(
              self.cocoGt.getAnnIds(imgIds=p.imgIds)
          )
          dts = self.cocoDt.loadAnns(
              self.cocoDt.getAnnIds(imgIds=p.imgIds)
          )
  
      imns = self.cocoGt.loadImgs(p.imgIds)
      self.size_mapping = {}
      for im in imns:
          self.size_mapping[im["id"]] = [im["height"], im["width"]]
  
      # if iouType == 'uv', add point gt annotations
      if p.iouType == "uv":
          self._loadGEval()
  
      # convert ground truth to mask if iouType == 'segm'
      if p.iouType == "segm":
          _toMask(gts, self.cocoGt)
          _toMask(dts, self.cocoDt)
  
      # set ignore flag
      for gt in gts:
          gt["ignore"] = gt["ignore"] if "ignore" in gt else 0
          gt["ignore"] = "iscrowd" in gt and gt["iscrowd"]
          if p.iouType == "keypoints":
              gt["ignore"] = (gt["num_keypoints"] == 0) or gt["ignore"]
          if p.iouType == "uv":
              gt["ignore"] = ("dp_x" in gt) == 0
  
      self._gts = defaultdict(list)  # gt for evaluation
      self._dts = defaultdict(list)  # dt for evaluation
      self._igrgns = defaultdict(list)
  
      for gt in gts:
          iid = gt["image_id"]
          if not iid in self._igrgns.keys():
              self._igrgns[iid] = _getIgnoreRegion(iid, self.cocoGt)
          if _checkIgnore(gt, self._igrgns[iid]):
              self._gts[iid, gt["category_id"]].append(gt)
      for dt in dts:
          if _checkIgnore(dt, self._igrgns[dt["image_id"]]):
              self._decodeUvData(dt)
              self._dts[dt["image_id"], dt["category_id"]].append(dt)
  
      self.evalImgs = defaultdict(
          list
      )  # per-image per-category evaluation results
      self.eval = {}
  
imports: import numpy
  import datetime
  import time
  from collections import defaultdict
  from pycocotools import mask
  import copy
  import h5py
  import pickle
  from scipy.io import loadmat
  import scipy.spatial.distance
  import os
  import itertools
  from scipy.optimize import linear_sum_assignment
  import numpy.ma
  import cv2
label_desc: Use image node_id 4 for calling the denseposeCOCOeval obj's underlying member method code with example usage: obj._prepare() and returns: maskUtils, unknown, None, None, True, False, True, unknown