dataset#

Base dataset#

class pointrix.dataset.base_data.BaseDataset(cfg: Config, split: str)#

Bases: Dataset

Basic dataset used in Datapipeline.

class Config(data_path: str = 'data', data_set: str = 'BaseImageDataset', observed_data_dirs_dict: ~typing.Dict[str, str] = <factory>, cached_observed_data: bool = True, white_bg: bool = False, enable_camera_training: bool = False, scale: float = 1.0, device: str = 'cuda')#

Bases: object

Parameters:
  • data_path (str) – The path to the data

  • data_set (str) – The dataset used in the pipeline, indexed in DATA_SET_REGISTRY

  • observed_data_dirs_dict (Dict[str, str]) – The observed data directories, e.g., {“image”: “images”}, which means the variable image is stored in “images” directory

  • cached_observed_data (bool) – Whether the observed data is cached

  • white_bg (bool) – Whether the background is white

  • enable_camera_training (bool) – Whether the camera is trainable

  • scale (float) – The image scale of the dataset

  • device (str) – The device used in the pipeline

abstract load_camera_prior(split: str) List[CameraPrior]#

The function for loading the camera typically requires user customization.

Parameters:

split (The split of the data.) –

load_data_list(split: str) Tuple[List[CameraPrior], Dict[str, Any], PointsPrior]#

The foundational function for formating the data

Parameters:

split (The split of the data.) –

Returns:

  • camera (List[CameraPrior]) – The list of cameras prior

  • observed_data (Dict[str, Any]) – The observed data

  • pointcloud (PointsPrior) – The pointcloud for the gaussian model.

load_observed_data(split: str) Dict[str, Any]#

The function for loading the observed_data, such as image, depth, normal, etc.

Parameters:

split (The split of the data) –

Returns:

observed_data – The observed data for the dataset.

Return type:

Dict[str, Any]

load_pointcloud_prior() PointsPrior#

The function for loading the Pointcloud for initialization of gaussian model.

abstract transform_observed_data(observed_data: Dict, split: str)#

The function for transforming the observed_data.

Parameters:

observed_data (Dict[str, Any]) – The observed_data for the dataset.

Returns:

observed_data – The transformed observed_data.

Return type:

Dict[str, Any]

Data Prior#

class pointrix.dataset.utils.dataprior.CameraPrior(idx: int, image_width: int, image_height: int, R: Float[Tensor, '3 3'] | ndarray[Any, dtype[_ScalarType_co]], T: Float[Tensor, '3 1'] | ndarray[Any, dtype[_ScalarType_co]], fx: float | None = None, fy: float | None = None, cx: float | None = None, cy: float | None = None, rgb_file_name: str | None = None, rgb_file_path: str | None = None, scene_scale: float = 1.0, device: str = 'cuda')#

Bases: object

Camera prior info used in data Pipeline

Parameters:
  • idx (int) – The index of the camera.

  • width (int) – The width of the image.

  • height (int) – The height of the image.

  • R (Float[Tensor, "3 3"]) – The rotation matrix of the camera.

  • T (Float[Tensor, "3 1"]) – The translation vector of the camera.

  • fx (float) – The focal length of the camera in x direction.

  • fy (float) – The focal length of the camera in y direction.

  • cx (float) – The center of the image in x direction.

  • cy (float) – The center of the image in y direction.

  • rgb_file_name (str) – The path of the image.

  • scene_scale (float) – The scale of the scene.

Notes

fx, fy, cx, cy and fovX, fovY are mutually exclusive. If fx, fy, cx, cy are provided, fovX, fovY will be calculated from them. If fovX, fovY are provided, fx, fy, cx, cy will be calculated from them.

Examples

>>> idx = 1
>>> width = 800
>>> height = 600
>>> R = np.eye(3)
>>> T = np.zeros(3)
>>> focal_length_x = 800
>>> focal_length_y = 800
>>> camera = Camera_Prior(idx=idx, R=R, T=T, width=width, height=height, rgb_file_name='1_rgb.png',
                    fx=focal_length_x, fy=focal_length_y, cx=width/2, cy=height/2, scene_scale=1.0)
class pointrix.dataset.utils.dataprior.CamerasPrior(camera_list: List[CameraPrior])#

Bases: object

Cameras class used in Pointrix, which are used to generate camera paths.

Parameters:

camera_list (List[CameraPrior]) – The list of the CameraPrior.

Examples

>>> width = 800
>>> height = 600
>>> R = np.eye(3)
>>> T = np.zeros(3)
>>> focal_length_x = 800
>>> focal_length_y = 800
>>> camera1 = CameraPrior(idx=1, R=R, T=T, width=width, height=height, rgb_file_name='1_rgb.png',
                    fx=focal_length_x, fy=focal_length_y, cx=width/2, cy=height/2, scene_scale=1.0)
>>> camera2 = CameraPrior(idx=2, R=R, T=T, width=width, height=height, rgb_file_name='1_rgb.png',
                    fx=focal_length_x, fy=focal_length_y, cx=width/2, cy=height/2, scene_scale=1.0)
>>> cameras = CamerasPrior([camera1, camera2])
generate_camera_path(num_frames: int, mode: str = 'Dolly') List[CameraPrior]#

Generate the camera path.

Parameters:
  • num_frames (int) – The number of frames of the camera path.

  • mode (str) – The mode of the camera path.

Returns:

camera_path – The camera path.

Return type:

List[CameraPrior]

get_radius() Float#

Get the path radius of the cameras.

Returns:

camera_radius – The radius of the cameras.

Return type:

float

class pointrix.dataset.utils.dataprior.PointsPrior(positions: Float[Tensor, 'N 3'] | ndarray[Any, dtype[_ScalarType_co]] | None = None, colors: Float[Tensor, 'N 3'] | ndarray[Any, dtype[_ScalarType_co]] | None = None, normals: Float[Tensor, 'N 3'] | ndarray[Any, dtype[_ScalarType_co]] | None = None)#

Bases: object

Point cloud initialization used in data Pipeline

Parameters:
  • positions (Union[Float[Tensor, "N 3"], NDArray, None]) – The positions of the points.

  • colors (Union[Float[Tensor, "N 3"], NDArray, None]) – The colors of the points.

  • normals (Union[Float[Tensor, "N 3"], NDArray, None]) – The normals of the points.

read_ply(path: str) None#

Read the point cloud from a ply file.

Parameters:

path (str) – The path to the ply file.

save_ply(path: str) None#

Save the point cloud to a ply file.

Parameters:

path (str) – The path to save the ply file.

Return type:

None