class_docstr: Read a video
class_docstr_tok: ["Read","a","video"]
code: def __getitem__(self, idx):
      if idx >= self.frames:
          raise IndexError("The frame {} is read failed.".format(idx))
      self.cap_video.set(cv2.CAP_PROP_POS_FRAMES, idx)
      ret, frame = self.cap_video.retrieve()
      if not ret:
          warnings.warn(
              "the frame {} is read failed. Video reading exit.".format(
                  idx
              )
          )
          raise IndexError("The frame {} is read failed.".format(idx))
  
      data = {"img": frame}
      if self.transforms is not None:
          data = self.transforms(data)
      data["ori_img"] = frame.transpose((2, 0, 1)) / 255.0
  
      return data
  
file_path: PaddleSeg/Matting/ppmatting/utils/video.py
imports: import os
  import warnings
  import cv2
  import paddle
  import numpy
  import ppmatting
  import ppmatting.transforms
label_desc: Use image node_id 3 for calling the VideoReader obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: data