Skip to content

BLEFF Dataloader #38

Description

@Skyy93

Hello @ziruiw-dev,

could you please provide the BLEFF dataloader?

Thank you very much
BR

Activity

  1. ziruiw-dev commented on Feb 14, 2023

    @ziruiw-dev
    Collaborator

    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)
  2. Skyy93 commented on Feb 14, 2023

    @Skyy93
    Author

    Thank you, that helps very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions