code: def main():
      args = parse_args()
      assert args.out or args.show, (
          "Please specify at least one operation (save/show the "
          'video) with the argument "--out" or "--show"'
      )
  
      # build the model from a config file and a checkpoint file
      model = init_detector(
          args.config, args.checkpoint, device=args.device
      )
  
      # build test pipeline
      model.cfg.test_dataloader.dataset.pipeline[
          0
      ].type = "mmdet.LoadImageFromNDArray"
      test_pipeline = Compose(
          model.cfg.test_dataloader.dataset.pipeline
      )
  
      # init visualizer
      visualizer = VISUALIZERS.build(model.cfg.visualizer)
      # the dataset_meta is loaded from the checkpoint and
      # then pass to the model in init_detector
      visualizer.dataset_meta = model.dataset_meta
  
      video_reader = mmcv.VideoReader(args.video)
      video_writer = None
      if args.out:
          fourcc = cv2.VideoWriter_fourcc(*"mp4v")
          video_writer = cv2.VideoWriter(
              args.out,
              fourcc,
              video_reader.fps,
              (video_reader.width, video_reader.height),
          )
  
      for frame in track_iter_progress(video_reader):
          result = inference_detector(
              model, frame, test_pipeline=test_pipeline
          )
          visualizer.add_datasample(
              name="video",
              image=frame,
              data_sample=result,
              draw_gt=False,
              show=False,
              pred_score_thr=args.score_thr,
          )
          frame = visualizer.get_image()
  
          if args.show:
              cv2.namedWindow("video", 0)
              mmcv.imshow(frame, "video", args.wait_time)
          if args.out:
              video_writer.write(frame)
  
      if video_writer:
          video_writer.release()
      cv2.destroyAllWindows()
  
file_path: mmdetection/demo/video_demo.py
imports: import argparse
  import cv2
  import mmcv
  from mmcv.transforms import Compose
  from mmengine.utils import track_iter_progress
  from mmdet.apis import inference_detector, init_detector
  from mmdet.registry import VISUALIZERS
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types