def get_boundingbox(img_hw, intrinsics, extrinsics, near_fars):
    """
    # get the minimum bounding box of all visual hulls
    :param img_hw:
    :param intrinsics:
    :param extrinsics:
    :param near_fars:
    :return:
    """

    bnds = torch.zeros((3, 2))
    bnds[:, 0] = np.inf
    bnds[:, 1] = -np.inf

    if isinstance(intrinsics, list):
        num = len(intrinsics)
    else:
        num = intrinsics.shape[0]
    # print("num: ", num)
    view_frust_pts_list = []
    for i in range(num):
        if not isinstance(intrinsics[i], torch.Tensor):
            cam_intr = torch.tensor(intrinsics[i])
            w2c = torch.tensor(extrinsics[i])
            c2w = torch.inverse(w2c)
        else:
            cam_intr = intrinsics[i]
            w2c = extrinsics[i]
            c2w = torch.inverse(w2c)
        min_depth, max_depth = near_fars[i][0], near_fars[i][1]
        # todo: check the coresponding points are matched

        view_frust_pts = get_view_frustum(min_depth, max_depth, img_hw, cam_intr, c2w)
        bnds[:, 0] = torch.min(bnds[:, 0], torch.min(view_frust_pts, dim=1)[0])
        bnds[:, 1] = torch.max(bnds[:, 1], torch.max(view_frust_pts, dim=1)[0])
        view_frust_pts_list.append(view_frust_pts)
    all_view_frust_pts = torch.cat(view_frust_pts_list, dim=1)

    # print("all_view_frust_pts: ", all_view_frust_pts.shape)
    # distance = torch.norm(all_view_frust_pts, dim=0)
    # print("distance: ", distance)

    # print("all_view_frust_pts_z: ", all_view_frust_pts[2, :])

    center = torch.tensor(((bnds[0, 1] + bnds[0, 0]) / 2, (bnds[1, 1] + bnds[1, 0]) / 2,
                           (bnds[2, 1] + bnds[2, 0]) / 2))

    lengths = bnds[:, 1] - bnds[:, 0]

    max_length, _ = torch.max(lengths, dim=0)
    radius = max_length / 2

    # print("radius: ", radius)
    return center, radius, bnds

    # get the minimum bounding box of all visual hulls
    :param img_hw:
    :param intrinsics:
    :param extrinsics:
    :param near_fars:
    :return:
    
mv-diffusion/One-2-3-45/reconstruction/data/scene.py