docstr: Convert annotation which can be polygons, uncompressed RLE to RLE.
  :return: binary mask (numpy 2D array)
docstr_tok: ["Convert","annotation","which","can","be","polygons",",","uncompressed","RLE","to","RLE",".",":","return",":","binary","mask","(","numpy","2D","array",")"]
code: def annToRLE(self, ann):
      """
      Convert annotation which can be polygons, uncompressed RLE to RLE.
      :return: binary mask (numpy 2D array)
      """
      t = self.imgs[ann["image_id"]]
      h, w = t["height"], t["width"]
      segm = ann["segmentation"]
      if type(segm) == list:
          # polygon -- a single object might consist of multiple parts
          # we merge all parts into one mask rle code
          rles = maskUtils.frPyObjects(segm, h, w)
          rle = maskUtils.merge(rles)
      elif type(segm["counts"]) == list:
          # uncompressed RLE
          rle = maskUtils.frPyObjects(segm, h, w)
      else:
          # rle
          rle = ann["segmentation"]
      return rle
  
imports: import json
  import time
  import matplotlib.pyplot
  from matplotlib.collections import PatchCollection
  from matplotlib.patches import Polygon
  import numpy
  import copy
  import itertools
  from pycocotools import mask
  import os
  from collections import defaultdict
  import sys
label_desc: Use image node_id 14 for calling the COCO obj's underlying member method code with example usage: obj.annToRLE(ann) and returns: rle