class_docstr: VideoManager object for getting frames from video source for inference.
class_docstr_tok: ["VideoManager","object","for","getting","frames","from","video","source","for","inference","."]
docstr: Args:
      cfg (CfgNode): configs. Details can be found in
      slowfast/config/defaults.py
docstr_tok: ["Args",":","cfg","(","CfgNode",")",":","configs",".","Details","can","be","found","in","slowfast\/config\/defaults.py"]
code: def __init__(self, cfg):
      """
      Args:
          cfg (CfgNode): configs. Details can be found in
          slowfast/config/defaults.py
      """
      assert (
          cfg.DEMO.WEBCAM > -1 or cfg.DEMO.INPUT_VIDEO != ""
      ), "Must specify a data source as input."
  
      self.source = (
          cfg.DEMO.WEBCAM
          if cfg.DEMO.WEBCAM > -1
          else cfg.DEMO.INPUT_VIDEO
      )
  
      self.display_width = cfg.DEMO.DISPLAY_WIDTH
      self.display_height = cfg.DEMO.DISPLAY_HEIGHT
  
      self.cap = cv2.VideoCapture(self.source)
  
      if self.display_width > 0 and self.display_height > 0:
          self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, self.display_width)
          self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, self.display_height)
      else:
          self.display_width = int(
              self.cap.get(cv2.CAP_PROP_FRAME_WIDTH)
          )
          self.display_height = int(
              self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
          )
  
      if not self.cap.isOpened():
          raise IOError("Video {} cannot be opened".format(self.source))
  
      self.output_file = None
      if cfg.DEMO.OUTPUT_FPS == -1:
          self.output_fps = self.cap.get(cv2.CAP_PROP_FPS)
      else:
          self.output_fps = cfg.DEMO.OUTPUT_FPS
      if cfg.DEMO.OUTPUT_FILE != "":
          self.output_file = self.get_output_file(
              cfg.DEMO.OUTPUT_FILE, fps=self.output_fps
          )
      self.id = -1
      self.buffer = []
      self.buffer_size = cfg.DEMO.BUFFER_SIZE
      self.seq_length = cfg.DATA.NUM_FRAMES * cfg.DATA.SAMPLING_RATE
      self.test_crop_size = cfg.DATA.TEST_CROP_SIZE
      self.clip_vis_size = cfg.DEMO.CLIP_VIS_SIZE
  
imports: import atexit
  import copy
  import queue
  import threading
  import time
  import cv2
  import slowfast.utils.logging
  from slowfast.visualization.utils import TaskInfo
label_desc: Use image node_id 1 to create a new VideoManager object  with example: obj = VideoManager(cfg)