class_docstr: All about an annotation such as Mask, Category, BoundingBox.
class_docstr_tok: ["All","about","an","annotation","such","as","Mask",",","Category",",","BoundingBox","."]
docstr: Args:
      bbox: List
          [minx, miny, maxx, maxy]
      bool_mask: np.ndarray with bool elements
          2D mask of object, should have a shape of height*width
      category_id: int
          ID of the object category
      category_name: str
          Name of the object category
      shift_amount: List
          To shift the box and mask predictions from sliced image
          to full sized image, should be in the form of [shift_x, shift_y]
      full_shape: List
          Size of the full image after shifting, should be in
          the form of [height, width]
docstr_tok: ["Args",":","bbox",":","List","[","minx",",","miny",",","maxx",",","maxy","]","bool_mask",":","np.ndarray","with","bool","elements","2D","mask","of","object",",","should","have","a","shape","of","height","*","width","category_id",":","int","ID","of","the","object","category","category_name",":","str","Name","of","the","object","category","shift_amount",":","List","To","shift","the","box","and","mask","predictions","from","sliced","image","to","full","sized","image",",","should","be","in","the","form","of","[","shift_x",",","shift_y","]","full_shape",":","List","Size","of","the","full","image","after","shifting",",","should","be","in","the","form","of","[","height",",","width","]"]
code: def __init__(
      self,
      bbox: Optional[List[int]] = None,
      bool_mask: Optional[np.ndarray] = None,
      category_id: Optional[int] = None,
      category_name: Optional[str] = None,
      shift_amount: Optional[List[int]] = [0, 0],
      full_shape: Optional[List[int]] = None,
  ):
      """
      Args:
          bbox: List
              [minx, miny, maxx, maxy]
          bool_mask: np.ndarray with bool elements
              2D mask of object, should have a shape of height*width
          category_id: int
              ID of the object category
          category_name: str
              Name of the object category
          shift_amount: List
              To shift the box and mask predictions from sliced image
              to full sized image, should be in the form of [shift_x, shift_y]
          full_shape: List
              Size of the full image after shifting, should be in
              the form of [height, width]
      """
      if not isinstance(category_id, int):
          raise ValueError("category_id must be an integer")
      if (bbox is None) and (bool_mask is None):
          raise ValueError("you must provide a bbox or bool_mask")
  
      if bool_mask is not None:
          self.mask = Mask(
              bool_mask=bool_mask,
              shift_amount=shift_amount,
              full_shape=full_shape,
          )
          bbox_from_bool_mask = get_bbox_from_bool_mask(bool_mask)
          # https://github.com/obss/sahi/issues/235
          if bbox_from_bool_mask is not None:
              bbox = bbox_from_bool_mask
          else:
              raise ValueError("Invalid boolean mask.")
      else:
          self.mask = None
  
      # if bbox is a numpy object, convert it to python List[float]
      if type(bbox).__module__ == "numpy":
          bbox = copy.deepcopy(bbox).tolist()
  
      # make sure bbox coords lie inside [0, image_size]
      xmin = max(bbox[0], 0)
      ymin = max(bbox[1], 0)
      if full_shape:
          xmax = min(bbox[2], full_shape[1])
          ymax = min(bbox[3], full_shape[0])
      else:
          xmax = bbox[2]
          ymax = bbox[3]
      bbox = [xmin, ymin, xmax, ymax]
      # set bbox
      self.bbox = BoundingBox(bbox, shift_amount)
  
      category_name = (
          category_name if category_name else str(category_id)
      )
      self.category = Category(
          id=category_id,
          name=category_name,
      )
  
      self.merged = None
  
imports: import copy
  from typing import Dict, List, Optional
  import numpy
  from sahi.utils.coco import CocoAnnotation, CocoPrediction
  from sahi.utils.cv import get_bbox_from_bool_mask, get_bool_mask_from_coco_segmentation, get_coco_segmentation_from_bool_mask
  from sahi.utils.shapely import ShapelyAnnotation
label_desc: Use image node_id 7 to create a new ObjectAnnotation object  with example: obj = ObjectAnnotation(bbox, bool_mask, category_id, category_name, shift_amount, full_shape)