docstr: Decodes the image using OpenCV.
docstr_tok: ["Decodes","the","image","using","OpenCV","."]
code: def decode(self, unischema_field, value):
      """Decodes the image using OpenCV."""
  
      # cv returns a BGR or grayscale image. Convert to RGB (unless a grayscale image).
      image_bgr_or_gray = cv2.imdecode(
          np.frombuffer(value, dtype=np.uint8), cv2.IMREAD_UNCHANGED
      )
      if len(image_bgr_or_gray.shape) == 2:
          # Greyscale image
          return image_bgr_or_gray
      elif (
          len(image_bgr_or_gray.shape) == 3
          and image_bgr_or_gray.shape[2] == 3
      ):
          # Convert BGR to RGB (opencv assumes BGR)
          image_rgb = image_bgr_or_gray[:, :, (2, 1, 0)]
          return image_rgb
      else:
          raise ValueError(
              "Unexpected image dimensions. Supported dimensions are (H, W) or (H, W, 3). "
              "Got {}".format(image_bgr_or_gray.shape)
          )
  
imports: from abc import abstractmethod
  from io import BytesIO
  import numpy
label_desc: Use image node_id 4 for calling the CompressedImageCodec obj's underlying member method code with example usage: obj.decode(unischema_field, value) and returns: image_bgr_or_gray, image_rgb