Shortcuts

mmedit.models.editors.eg3d.camera

Module Contents

Classes

BaseCamera

Base camera class. Sample camera position on sphere with specific

GaussianCamera

Pre-defined camera class. Sample camera position in gaussian

UniformCamera

Pre-defined camera class. Sample camera position in uniform

Functions

create_cam2world_matrix(→ torch.Tensor)

Calculate camera-to-world matrix from camera's forward vector, world

Attributes

DeviceType

VectorType

mmedit.models.editors.eg3d.camera.DeviceType[源代码]
mmedit.models.editors.eg3d.camera.VectorType[源代码]
class mmedit.models.editors.eg3d.camera.BaseCamera(horizontal_mean: Optional[float] = None, vertical_mean: Optional[float] = None, horizontal_std: Optional[float] = 0, vertical_std: Optional[float] = 0, look_at: VectorType = [0, 0, 0], fov: Optional[float] = None, focal: Optional[float] = None, up: VectorType = [0, 1, 0], radius: Optional[float] = 1, sampling_strategy: str = 'uniform')[源代码]

Bases: object

Base camera class. Sample camera position on sphere with specific distribution (e.g., Gaussian, Uniform) and return camera-to-world matrix and intrinsics matrix.

参数
  • horizontal_mean (Optional[float]) – Mean of the horizontal range in radian. Defaults to None.

  • vertical_mean (Optional[float]) – Mean of the vertical range in radian. Defaults to None.

  • horizontal_std (Optional[float]) – Standard deviation of the horizontal range in radian. Defaults to None.

  • vertical_std (Optional[float]) – Standard deviation of the vertical range in radian. Defaults to None.

  • look_at (Optional[List, torch.Tensor]) – The look at position of the camera. Defaults to None.

  • fov (Optional[float]) – The FOV (field-of-view) in degree. Defaults to None.

  • up (Optional[List, torch.Tensor]) – The up direction of the world coordinate. Defaults to None.

  • radius (Optional[float]) – Radius of the sphere. Defaults to None.

  • sampling_strategy (Optional[str]) – The sampling strategy (distribution) of the camera. Support ‘Uniform’ and ‘Gaussian’. Defaults to ‘Uniform’.

_sample_in_range(mean: float, std: float, batch_size: int) torch.Tensor[源代码]

Sample value with specific mean and std.

参数
  • mean (float) – Mean of the sampled value.

  • std (float) – Standard deviation of the sampled value.

  • batch_size (int) – The batch size of the sampled result.

返回

Sampled results.

返回类型

torch.Tensor

sample_intrinsic(fov: Optional[float] = None, focal: Optional[float] = None, device: Optional[DeviceType] = None, batch_size: int = 1) torch.Tensor[源代码]

Sample intrinsic matrix.

参数
  • fov (Optional[float], optional) – FOV (field of view) in degree. If not passed, self.fov will be used. Defaults to None.

  • focal (Optional[float], optional) – Focal in pixel. If not passed, self.focal will be used. Defaults to None.

  • batch_size (int) – The batch size of the output. Defaults to 1.

  • device (DeviceType, optional) – Device to put the intrinstic matrix. If not passed, self.device will be used. Defaults to None.

返回

Intrinsic matrix.

返回类型

torch.Tensor

fov_to_intrinsic(fov: Optional[float] = None, device: DeviceType = None) torch.Tensor[源代码]

Calculate intrinsic matrix from FOV (field of view).

参数
  • fov (Optional[float], optional) – FOV (field of view) in degree. If not passed, self.fov will be used. Defaults to None.

  • device (DeviceType, optional) – Device to put the intrinstic matrix. If not passed, self.device will be used. Defaults to None.

返回

Intrinsic matrix.

返回类型

torch.Tensor

focal_to_instrinsic(focal: Optional[float] = None, device: DeviceType = None) torch.Tensor[源代码]

Calculate intrinsic matrix from focal.

参数
  • focal (Optional[float], optional) – Focal in degree. If not passed, self.focal will be used. Defaults to None.

  • device (DeviceType, optional) – Device to put the intrinsic matrix. If not passed, self.device will be used. Defaults to None.

返回

Intrinsic matrix.

返回类型

torch.Tensor

sample_theta(mean: float, std: float, batch_size: int) torch.Tensor[源代码]

Sampling the theta (yaw).

参数
  • mean (float) – Mean of theta.

  • std (float) – Standard deviation of theta.

  • batch_size (int) – Target batch size of theta.

返回

Sampled theta.

返回类型

torch.Tensor

sample_phi(mean: float, std: float, batch_size: int) torch.Tensor[源代码]

Sampling the phi (pitch). Unlike sampling theta, we uniformly sample phi on cosine space to release a spherical uniform sampling.

参数
  • mean (float) – Mean of phi.

  • std (float) – Standard deviation of phi.

  • batch_size (int) – Target batch size of phi.

返回

Sampled phi.

返回类型

torch.Tensor

sample_camera2world(h_mean: Optional[float] = None, v_mean: Optional[float] = None, h_std: Optional[float] = None, v_std: Optional[float] = None, look_at: VectorType = None, up: VectorType = None, radius: Optional[float] = None, batch_size: int = 1, device: Optional[str] = None) torch.Tensor[源代码]

Sample camera-to-world matrix with the passed condition.

参数
  • h_mean (Optional[float], optional) – Mean of horizontal range in radian. Defaults to None.

  • v_mean (Optional[float], optional) – Mean of vertical range in radian. Defaults to None.

  • h_std (Optional[float], optional) – Standard deviation of horizontal in radian. Defaults to None.

  • v_std (Optional[float], optional) – Standard deviation of horizontal in radian. Defaults to None.

  • look_at (Optional[Tuple[list, torch.Tensor]], optional) – Look-at position. Defaults to None.

  • up (Optional[Tuple[list, torch.Tensor]], optional) – Up direction of the world coordinate. Defaults to None.

  • radius (Optional[float]) – Radius of the sphere. Defaults to None.

  • batch_size (int, optional) – Batch size of the results. Defaults to 1.

  • device (Optional[str], optional) – The target device of the results. Defaults to None.

返回

Sampled camera-to-world matrix.

返回类型

torch.Tensor

interpolation_cam2world(num_images: int, h_mean: Optional[float] = None, v_mean: Optional[float] = None, h_std: Optional[float] = None, v_std: Optional[float] = None, look_at: VectorType = None, up: VectorType = None, radius: Optional[float] = None, batch_size: int = 1, device: Optional[str] = None) List[torch.Tensor][源代码]

Interpolation camera original in spherical trajectory and return a list of camera-to-world matrix.

参数
  • num_images (int) – The number of images in interpolation.

  • h_mean (Optional[float], optional) – Mean of horizontal range in radian. Defaults to None.

  • v_mean (Optional[float], optional) – Mean of vertical range in radian. Defaults to None.

  • h_std (Optional[float], optional) – Standard deviation of horizontal in radian. Defaults to None.

  • v_std (Optional[float], optional) – Standard deviation of horizontal in radian. Defaults to None.

  • look_at (Optional[Tuple[list, torch.Tensor]], optional) – Look-at position. Defaults to None.

  • up (Optional[Tuple[list, torch.Tensor]], optional) – Up direction of the world coordinate. Defaults to None.

  • radius (Optional[float]) – Radius of the sphere. Defaults to None.

  • batch_size (int, optional) – Batch size of the results. Defaults to 1.

  • device (Optional[str], optional) – The target device of the results. Defaults to None.

返回

List of sampled camera-to-world matrix.

返回类型

List[torch.Tensor]

__repr__()[源代码]

Return repr(self).

class mmedit.models.editors.eg3d.camera.GaussianCamera(horizontal_mean: Optional[float] = None, vertical_mean: Optional[float] = None, horizontal_std: Optional[float] = 0, vertical_std: Optional[float] = 0, look_at: List = [0, 0, 0], fov: Optional[float] = None, focal: Optional[float] = None, up: VectorType = [0, 1, 0], radius: Optional[float] = 1)[源代码]

Bases: BaseCamera

Pre-defined camera class. Sample camera position in gaussian distribution.

参数
  • horizontal_mean (Optional[float]) – Mean of the horizontal range in radian. Defaults to None.

  • vertical_mean (Optional[float]) – Mean of the vertical range in radian. Defaults to None.

  • horizontal_std (Optional[float]) – Standard deviation of the horizontal range in radian. Defaults to None.

  • vertical_std (Optional[float]) – Standard deviation of the vertical range in radian. Defaults to None.

  • look_at (Optional[List, torch.Tensor]) – The look at position of the camera. Defaults to None.

  • up (Optional[List, torch.Tensor]) – The up direction of the world coordinate. Defaults to None.

  • radius (Optional[float]) – Radius of the sphere. Defaults to None.

class mmedit.models.editors.eg3d.camera.UniformCamera(horizontal_mean: Optional[float] = None, vertical_mean: Optional[float] = None, horizontal_std: Optional[float] = 0, vertical_std: Optional[float] = 0, look_at: List = [0, 0, 0], fov: Optional[float] = None, focal: Optional[float] = None, up: VectorType = [0, 1, 0], radius: Optional[float] = 1)[源代码]

Bases: BaseCamera

Pre-defined camera class. Sample camera position in uniform distribution.

参数
  • horizontal_mean (Optional[float]) – Mean of the horizontal range in radian. Defaults to None.

  • vertical_mean (Optional[float]) – Mean of the vertical range in radian. Defaults to None.

  • horizontal_std (Optional[float]) – Standard deviation of the horizontal range in radian. Defaults to None.

  • vertical_std (Optional[float]) – Standard deviation of the vertical range in radian. Defaults to None.

  • look_at (Optional[List, torch.Tensor]) – The look at position of the camera. Defaults to None.

  • up (Optional[List, torch.Tensor]) – The up direction of the world coordinate. Defaults to None.

  • radius (Optional[float]) – Radius of the sphere. Defaults to None.

mmedit.models.editors.eg3d.camera.create_cam2world_matrix(forward_vector: torch.Tensor, origin: torch.Tensor, up: torch.Tensor) torch.Tensor[源代码]

Calculate camera-to-world matrix from camera’s forward vector, world origin and world up direction. The calculation is performed in right-hand coordinate system and the returned matrix is in homogeneous coordinates (shape like (bz, 4, 4)).

参数
  • forward_vector (torch.Tensor) – The forward vector of the camera.

  • origin (torch.Tensor) – The origin of the world coordinate.

  • up (torch.Tensor) – The up direction of the world coordinate.

返回

Camera-to-world matrix.

返回类型

torch.Tensor

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.