code: def update(self):
      final_result = []
      norm_type = self.cfg.LOSS.get("NORM_TYPE", None)
      hm_size = self.cfg.DATA_PRESET.HEATMAP_SIZE
      if self.save_video:
          # initialize the file video stream, adapt ouput video resolution to original video
          stream = cv2.VideoWriter(
              *[
                  self.video_save_opt[k]
                  for k in ["savepath", "fourcc", "fps", "frameSize"]
              ]
          )
          if not stream.isOpened():
              print("Try to use other video encoders...")
              ext = self.video_save_opt["savepath"].split(".")[-1]
              fourcc, _ext = self.recognize_video_ext(ext)
              self.video_save_opt["fourcc"] = fourcc
              self.video_save_opt["savepath"] = (
                  self.video_save_opt["savepath"][:-4] + _ext
              )
              stream = cv2.VideoWriter(
                  *[
                      self.video_save_opt[k]
                      for k in [
                          "savepath",
                          "fourcc",
                          "fps",
                          "frameSize",
                      ]
                  ]
              )
          assert stream.isOpened(), "Cannot open video for writing"
      # keep looping infinitelyd
      while True:
          # ensure the queue is not empty and get item
          (
              boxes,
              scores,
              ids,
              hm_data,
              cropped_boxes,
              orig_img,
              im_name,
          ) = self.wait_and_get(self.result_queue)
          if orig_img is None:
              # if the thread indicator variable is set (img is None), stop the thread
              if self.save_video:
                  stream.release()
              write_json(
                  final_result,
                  self.opt.outputpath,
                  form=self.opt.format,
                  for_eval=self.opt.eval,
              )
              print("Results have been written to json.")
              return
          # image channel RGB->BGR
          orig_img = np.array(orig_img, dtype=np.uint8)[:, :, ::-1]
          if boxes is None or len(boxes) == 0:
              if self.opt.save_img or self.save_video or self.opt.vis:
                  self.write_image(
                      orig_img,
                      im_name,
                      stream=stream if self.save_video else None,
                  )
          else:
              # location prediction (n, kp, 2) | score prediction (n, kp, 1)
              assert hm_data.dim() == 4
  
              face_hand_num = 110
              if hm_data.size()[1] == 136:
                  self.eval_joints = [*range(0, 136)]
              elif hm_data.size()[1] == 26:
                  self.eval_joints = [*range(0, 26)]
              elif hm_data.size()[1] == 133:
                  self.eval_joints = [*range(0, 133)]
              elif hm_data.size()[1] == 68:
                  face_hand_num = 42
                  self.eval_joints = [*range(0, 68)]
              elif hm_data.size()[1] == 21:
                  self.eval_joints = [*range(0, 21)]
              pose_coords = []
              pose_scores = []
              for i in range(hm_data.shape[0]):
                  bbox = cropped_boxes[i].tolist()
                  if isinstance(self.heatmap_to_coord, list):
                      (
                          pose_coords_body_foot,
                          pose_scores_body_foot,
                      ) = self.heatmap_to_coord[0](
                          hm_data[i][self.eval_joints[:-face_hand_num]],
                          bbox,
                          hm_shape=hm_size,
                          norm_type=norm_type,
                      )
                      (
                          pose_coords_face_hand,
                          pose_scores_face_hand,
                      ) = self.heatmap_to_coord[1](
                          hm_data[i][self.eval_joints[-face_hand_num:]],
                          bbox,
                          hm_shape=hm_size,
                          norm_type=norm_type,
                      )
                      pose_coord = np.concatenate(
                          (
                              pose_coords_body_foot,
                              pose_coords_face_hand,
                          ),
                          axis=0,
                      )
                      pose_score = np.concatenate(
                          (
                              pose_scores_body_foot,
                              pose_scores_face_hand,
                          ),
                          axis=0,
                      )
                  else:
                      pose_coord, pose_score = self.heatmap_to_coord(
                          hm_data[i][self.eval_joints],
                          bbox,
                          hm_shape=hm_size,
                          norm_type=norm_type,
                      )
                  pose_coords.append(
                      torch.from_numpy(pose_coord).unsqueeze(0)
                  )
                  pose_scores.append(
                      torch.from_numpy(pose_score).unsqueeze(0)
                  )
              preds_img = torch.cat(pose_coords)
              preds_scores = torch.cat(pose_scores)
              if not self.opt.pose_track:
                  (
                      boxes,
                      scores,
                      ids,
                      preds_img,
                      preds_scores,
                      pick_ids,
                  ) = pose_nms(
                      boxes,
                      scores,
                      ids,
                      preds_img,
                      preds_scores,
                      self.opt.min_box_area,
                      use_heatmap_loss=self.use_heatmap_loss,
                  )
  
              _result = []
              for k in range(len(scores)):
                  _result.append(
                      {
                          "keypoints": preds_img[k],
                          "kp_score": preds_scores[k],
                          "proposal_score": torch.mean(preds_scores[k])
                          + scores[k]
                          + 1.25 * max(preds_scores[k]),
                          "idx": ids[k],
                          "box": [
                              boxes[k][0],
                              boxes[k][1],
                              boxes[k][2] - boxes[k][0],
                              boxes[k][3] - boxes[k][1],
                          ],
                      }
                  )
  
              result = {"imgname": im_name, "result": _result}
  
              if self.opt.pose_flow:
                  poseflow_result = self.pose_flow_wrapper.step(
                      orig_img, result
                  )
                  for i in range(len(poseflow_result)):
                      result["result"][i]["idx"] = poseflow_result[i][
                          "idx"
                      ]
  
              final_result.append(result)
              if self.opt.save_img or self.save_video or self.opt.vis:
                  img = orig_img.copy()
                  global keypoint_dist_threshold
                  keypoint_dist_threshold = img.shape[0] / 30
                  detections = [
                      norfair.Detection(
                          p["keypoints"].numpy(),
                          scores=p["kp_score"].squeeze().numpy(),
                      )
                      for p in result["result"]
                  ]
                  tracked_objects = self.tracker.update(
                      detections=detections
                  )
                  norfair.draw_tracked_objects(img, tracked_objects)
  
                  if hm_data.size()[1] == 49:
                      from alphapose.utils.vis import (
                          vis_frame_dense as vis_frame,
                      )
                  elif self.opt.vis_fast:
                      from alphapose.utils.vis import (
                          vis_frame_fast as vis_frame,
                      )
                  else:
                      from alphapose.utils.vis import vis_frame
  
                  self.write_image(
                      img,
                      im_name,
                      stream=stream if self.save_video else None,
                  )
  
imports: import os
  import time
  from queue import Queue
  from threading import Thread
  import cv2
  import numpy
  import torch
  import torch.multiprocessing
  from alphapose.utils.pPose_nms import pose_nms, write_json
  from alphapose.utils.transforms import get_func_heatmap_to_coord
  import norfair
label_desc: Use image node_id 4 for calling the DataWriter obj's underlying member method code with example usage: obj.update() without return types