code: def __init__(
      self,
      labelIndex,
      shape,
      delPolygon,
      setDirty,
      insideColor=[255, 0, 0],
      borderColor=[0, 255, 0],
      opacity=0.5,
      cocoIndex=None,
      parent=None,
      is_rect=False,
      hand_rect=False,
  ):
      super(PolygonAnnotation, self).__init__(parent)
      self.points = []
      self.m_items = []
      self.m_lines = []
      self.coco_id = cocoIndex
      self.height, self.width = shape[:2]
      self.delPolygon = delPolygon
      self.setDirty = setDirty
  
      self.labelIndex = labelIndex
      self.item_hovering = False
      self.line_hovering = False
      self.polygon_hovering = False
      self.anning = False  # 是否标注模式
      self.noMove = False
      self.last_focse = False  # 之前是不是焦点在
      self.is_rect = is_rect
      self.hand_rect = hand_rect
  
      self.setZValue(10)
      self.opacity = opacity
      i = insideColor
      self.insideColor = QtGui.QColor(i[0], i[1], i[2])
      self.insideColor.setAlphaF(opacity)
      self.halfInsideColor = QtGui.QColor(i[0], i[1], i[2])
      self.halfInsideColor.setAlphaF(opacity / 2)
      self.setBrush(self.halfInsideColor)
      b = borderColor
      self.borderColor = QtGui.QColor(b[0], b[1], b[2])
      self.borderColor.setAlphaF(0.8)
      self.setPen(QtGui.QPen(self.borderColor))
      self.setAcceptHoverEvents(True)
  
      self.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
      self.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
      self.setFlag(
          QtWidgets.QGraphicsItem.ItemSendsGeometryChanges, True
      )
      self.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, True)
  
      self.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
  
      # persistent this bbox instance and update when needed
      self.bbox = None
      if not self.is_rect:
          self.bbox = BBoxAnnotation(labelIndex, self, cocoIndex, self)
          self.bbox.setParentItem(self)
  
imports: from qtpy import QtWidgets, QtGui, QtCore
  from .None import GripItem, LineItem, BBoxAnnotation
label_desc: Use image node_id 1 to create a new PolygonAnnotation object from inherited base classes: QtWidgets with example: obj = PolygonAnnotation(labelIndex, shape, delPolygon, setDirty, insideColor, borderColor, opacity, cocoIndex, parent, is_rect, hand_rect)