code: def topdown_unite_predict_video(
      detector,
      topdown_keypoint_detector,
      camera_id,
      keypoint_batch_size=1,
      save_res=False,
  ):
      video_name = "output.mp4"
      if camera_id != -1:
          capture = cv2.VideoCapture(camera_id)
      else:
          capture = cv2.VideoCapture(FLAGS.video_file)
          video_name = os.path.split(FLAGS.video_file)[-1]
      # Get Video info : resolution, fps, frame count
      width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
      height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
      fps = int(capture.get(cv2.CAP_PROP_FPS))
      frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
      print("fps: %d, frame_count: %d" % (fps, frame_count))
  
      if not os.path.exists(FLAGS.output_dir):
          os.makedirs(FLAGS.output_dir)
      out_path = os.path.join(FLAGS.output_dir, video_name)
      fourcc = cv2.VideoWriter_fourcc(*"mp4v")
      writer = cv2.VideoWriter(out_path, fourcc, fps, (width, height))
      index = 0
      store_res = []
      keypoint_smoothing = KeypointSmoothing(
          width, height, filter_type=FLAGS.filter_type, beta=0.05
      )
  
      while 1:
          ret, frame = capture.read()
          if not ret:
              break
          index += 1
          print("detect frame: %d" % (index))
  
          frame2 = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
  
          results = detector.predict_image([frame2], visual=False)
          results = detector.filter_box(results, FLAGS.det_threshold)
          if results["boxes_num"] == 0:
              writer.write(frame)
              continue
  
          keypoint_res = predict_with_given_det(
              frame2,
              results,
              topdown_keypoint_detector,
              keypoint_batch_size,
              FLAGS.run_benchmark,
          )
  
          if FLAGS.smooth and len(keypoint_res["keypoint"][0]) == 1:
              current_keypoints = np.array(
                  keypoint_res["keypoint"][0][0]
              )
              smooth_keypoints = keypoint_smoothing.smooth_process(
                  current_keypoints
              )
  
              keypoint_res["keypoint"][0][0] = smooth_keypoints.tolist()
  
          im = visualize_pose(
              frame,
              keypoint_res,
              visual_thresh=FLAGS.keypoint_threshold,
              returnimg=True,
          )
  
          if save_res:
              store_res.append(
                  [
                      index,
                      keypoint_res["bbox"],
                      [
                          keypoint_res["keypoint"][0],
                          keypoint_res["keypoint"][1],
                      ],
                  ]
              )
  
          writer.write(im)
          if camera_id != -1:
              cv2.imshow("Mask Detection", im)
              if cv2.waitKey(1) & 0xFF == ord("q"):
                  break
      writer.release()
      print("output_video saved to: {}".format(out_path))
      if save_res:
          """
          1) store_res: a list of frame_data
          2) frame_data: [frameid, rects, [keypoints, scores]]
          3) rects: list of rect [xmin, ymin, xmax, ymax]
          4) keypoints: 17(joint numbers)*[x, y, conf], total 51 data in list
          5) scores: mean of all joint conf
          """
          with open("det_keypoint_unite_video_results.json", "w") as wf:
              json.dump(store_res, wf, indent=4)
  
imports: import os
  import json
  import cv2
  import math
  import numpy
  import paddle
  import yaml
  from det_keypoint_unite_utils import argsparser
  from preprocess import decode_image
  from infer import Detector, DetectorPicoDet, PredictConfig, print_arguments, get_test_images, bench_log
  from keypoint_infer import KeyPointDetector, PredictConfig_KeyPoint
  from visualize import visualize_pose
  from benchmark_utils import PaddleInferBenchmark
  from utils import get_current_memory_mb
  from keypoint_postprocess import translate_to_ori_images
label_desc: Use image node_id 3 for calling a global function with example usage: topdown_unite_predict_video(detector, topdown_keypoint_detector, camera_id, keypoint_batch_size, save_res) without return types