code: def solve_scale(joints_world, cap, plane_model):
      cam_center = cap.cam_pose.camera_center_in_world
      a, b, c, d = plane_model
      scales = []
      for j in joints_world:
          jx, jy, jz = j
          # from open3d plane model is: a*x + b*y + c*z + d = 0
          # and a^2 + b^2 + c^2 = 1
          # We can convert the scale problem into a ray-plane intersection problem:
          # reference: https://education.siggraph.org/static/HyperGraph/raytrace/rayplane_intersection.htm
          # Shoting a ray from camera center, (c_x, c_y, c_z), passing through joint, (j_x, j_y, j_z), and
          # Intersecting the plane, a*x + b*y + c*z + d = 0, at some point (x, y, z)
          # Let R0 = (c_x, c_y, c_z)
          #     Rd = (j_x-c_x, j_y-c_y, j_z-c_z)
          # The ray can be written as: R(s) = R0 + s * Rd
          # with the plane equation:
          # a*(c_x + s*(j_x-c_x)) + b*(c_y + s*(j_y-c_y)) + c*(c_z + s*(j_z-c_z)) + d = 0
          # s = -(a*c_x + b*c_y + c*c_z + d) / (a*(j_x-c_x) + b*(j_y-c_y) + c*(j_z-c_z))
          # let right = -(a*c_x + b*c_y + c*c_z + d)
          #       coe = a*(j_x-c_x) + b*(j_y-c_y) + c*(j_z-c_z)
          right = -(
              a * cam_center[0]
              + b * cam_center[1]
              + c * cam_center[2]
              + d
          )
          coe = (
              a * (jx - cam_center[0])
              + b * (jy - cam_center[1])
              + c * (jz - cam_center[2])
          )
          s = right / coe
          if s > 0:
              scales.append(s)
      return min(scales)
  
imports: import sys
  import argparse
  import os
  import copy
  import torch
  import joblib
  import numpy
  import open3d
  import cv2
  from tqdm import tqdm
  from data_io import colmap_helper
  from utils import debug_utils, ray_utils
  from cameras import camera_pose
  from geometry.basics import Translation, Rotation
  from geometry import transformations
label_desc: Use image node_id 5 for calling a global function with example usage: solve_scale(joints_world, cap, plane_model) and returns: min