code: def mot_topdown_unite_predict_video(
      mot_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))
      frame_id = 0
      timer_mot, timer_kp, timer_mot_kp = (
          FPSTimer(),
          FPSTimer(),
          FPSTimer(),
      )
  
      num_classes = mot_detector.num_classes
      assert (
          num_classes == 1
      ), "Only one category mot model supported for uniting keypoint deploy."
      data_type = "mot"
  
      while 1:
          ret, frame = capture.read()
          if not ret:
              break
          if frame_id % 10 == 0:
              print("Tracking frame: %d" % (frame_id))
          frame_id += 1
          timer_mot_kp.tic()
  
          # mot model
          timer_mot.tic()
  
          frame2 = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
  
          mot_results = mot_detector.predict_image(
              [frame2], visual=False
          )
          timer_mot.toc()
          online_tlwhs, online_scores, online_ids = mot_results[0]
          results = convert_mot_to_det(
              online_tlwhs[0], online_scores[0]
          )  # only support single class for mot + pose
          if results["boxes_num"] == 0:
              continue
  
          # keypoint model
          timer_kp.tic()
          keypoint_res = predict_with_given_det(
              frame2,
              results,
              topdown_keypoint_detector,
              keypoint_batch_size,
              FLAGS.run_benchmark,
          )
          timer_kp.toc()
          timer_mot_kp.toc()
  
          kp_fps = 1.0 / timer_kp.duration
          mot_kp_fps = 1.0 / timer_mot_kp.duration
  
          im = visualize_pose(
              frame,
              keypoint_res,
              visual_thresh=FLAGS.keypoint_threshold,
              returnimg=True,
              ids=online_ids[0],
          )
  
          im = plot_tracking_dict(
              im,
              num_classes,
              online_tlwhs,
              online_ids,
              online_scores,
              frame_id=frame_id,
              fps=mot_kp_fps,
          )
  
          writer.write(im)
          if camera_id != -1:
              cv2.imshow("Tracking and keypoint results", im)
              if cv2.waitKey(1) & 0xFF == ord("q"):
                  break
  
      writer.release()
      print("output_video saved to: {}".format(out_path))
  
imports: import os
  import json
  import cv2
  import math
  import numpy
  import paddle
  import yaml
  import copy
  from collections import defaultdict
  from mot_keypoint_unite_utils import argsparser
  from preprocess import decode_image
  from infer import print_arguments, get_test_images, bench_log
  from mot_sde_infer import SDE_Detector
  from mot_jde_infer import JDE_Detector, MOT_JDE_SUPPORT_MODELS
  from keypoint_infer import KeyPointDetector, KEYPOINT_SUPPORT_MODELS
  from det_keypoint_unite_infer import predict_with_given_det
  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
  import sys
  from pptracking.python.mot.visualize import plot_tracking, plot_tracking_dict
  from pptracking.python.mot.utils import MOTTimer
label_desc: Use image node_id 3 for calling a global function with example usage: mot_topdown_unite_predict_video(mot_detector, topdown_keypoint_detector, camera_id, keypoint_batch_size, save_res) without return types