Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLEFF Dataloader #38

Closed
Skyy93 opened this issue Feb 10, 2023 · 2 comments
Closed

BLEFF Dataloader #38

Skyy93 opened this issue Feb 10, 2023 · 2 comments

Comments

@Skyy93
Copy link

Skyy93 commented Feb 10, 2023

Hello @ziruiw-dev,

could you please provide the BLEFF dataloader?

Thank you very much
BR

@ziruiw-dev
Copy link
Collaborator

ziruiw-dev commented Feb 14, 2023

Hi @Skyy93,

I should be able to upload a full file in early April. If you are in a hurry, here are some basic functions and it should be fairly easy to load BLEFF camera parameters.

def load_blender_gt_meta(gt_json):
    with open(gt_json, 'r') as json_f:
        gt_json = json.load(json_f)
        fov_x = gt_json['cam_angle_x']  # fov in rad
        fov_y = gt_json['cam_angle_y']  # fov in rad
        c2ws = np.array(gt_json['c2ws']).astype(np.float32)  # (N, 4, 4)

    # centre poses
    c2ws, pose_avg = center_poses(c2ws[:, :3])  # (N, 3, 4)
    c2ws = convert3x4_4x4(c2ws)  # (N, 4, 4)

    # scale gt to a unit sphere
    c2ws[:, :3, 3] /= pts_dist_max(c2ws[:, :3, 3])
    c2ws[:, :3, 3] *= 2.0

    results = {
        'fov_x': fov_x,
        'fov_y': fov_y,
        'c2ws': c2ws  # (N_gt, 4, 4)
    }

    return results


def fov2focal_pix(fov, hw):
    """
    :param fov: float or double
    :param hw:  float or double
    :return:    float or double
    """
    focal_pix = 0.5 * hw / np.tan(fov / 2.0)
    return focal_pix

and you can get data by

gt_meta = load_blender_gt_meta(os.path.join(scene_dir, 'gt_metas.json'))
gt_c2ws_all = gt_meta['c2ws']  # (N_gt, 4, 4)
gt_fx = fov2focal_pix(gt_meta['fov_x'], W)
gt_fy = fov2focal_pix(gt_meta['fov_y'], H)

@Skyy93
Copy link
Author

Skyy93 commented Feb 14, 2023

Thank you, that helps very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants