Some tips for this file: class method definition must be in a single line for correct doc generation.
Wis3D
- Wis3D.__init__(out_folder: str, sequence_name: str, xyz_pattern=None, auto_increase=True, auto_remove=True, enable: bool = True)
Initialize Wis3D
- Parameters:
out_folder – the folder to store the output files.
sequence_name – a subfolder of out_folder holding files of the sequence.
xyz_pattern – mapping of the three.js coordinate to the target coordinate. Take opencv camera coordinate as an example:
three.js: opencv: (up: y, right: x, backward:z) (down: y, right: x, forward:z) y z | / o -- x --> o -- x / | z y three.js: x y z | | | xyz_pattern = ['x', '-y', '-z'] | | | opencv: x -y -z
- Parameters:
auto_increase – In one program run, whether to increase the scene id automatically for Wis3D instances with the same sequence names.
auto_remove – On program launch, whether to automatically remove the output folder if it exists.
enable – Whether to enable Wis3D. Since Wis3D can be time-consuming, this flag is useful for you to keep the Wis3D code unchanged and enable/disable it at debug time/running time.
set_scene_id
- Wis3D.set_scene_id(self, scene_id: int) None
Set scene ID.
Use it to create the new scene and add content to different scenes
- Parameters:
scene_id – scene ID to be set
add_point_cloud
- Wis3D.add_point_cloud(self, path: str, *, name: str = None) None
Add a point cloud by file path. Support importing point clouds from STL, OBJ, PLY, etc.
- Parameters:
path - path to the point cloud file
name - output name of the point cloud
- Wis3D.add_point_cloud(self, vertices: np.ndarray | torch.Tensor, colors: np.ndarray | torch.Tensor = None, *, name: str = None) None
Add a point cloud by point cloud definition.
- Parameters:
vertices - points constituting the point cloud, shape: (n, 3)
colors - colors of the points, shape: (n, 3), range [0, 255] dtype: np.uint8 or torch.byte
name - output name of the point cloud
- Wis3D.add_point_cloud(self, pcd: trimesh.PointCloud, name: str = None) None
Add a point cloud loaded by trimesh.
- Parameters:
pcd - point cloud loaded by trimesh
name - output name of the point cloud
add_mesh
- Wis3D.add_mesh(self, path: str, *, name: str = None) None
Add a mesh by file path.
Support importing meshes from STL, OBJ, PLY, etc.
- Parameters:
path - path to the mesh file
name - output name of the mesh
- Wis3D.add_mesh(self, vertices: np.ndarray | torch.Tensor, faces: np.ndarray | torch.Tensor, vertex_colors: np.ndarray | torch.Tensor, *, name: str = None) None
Add a mesh loaded by mesh definition
- Parameters:
vertices - vertices of the mesh, shape: (n, 3)
faces - faces of the mesh, shape: (m, 3)
vertex_colors - vertex colors of the mesh, shape: (n, 3), range [0, 255] dtype: np.uint8 or torch.byte
name - output name of the mesh
- Wis3D.add_mesh(self, mesh: trimesh.Trimesh, *, name: str = None) None
Add a mesh loaded by trimesh
- Parameters:
mesh - mesh loaded by trimesh
name - output name of the mesh
add_image
- Wis3D.add_image(self, path: str, *, name: str = None) None
Add an image by file path
- Parameters:
path - path to the image file
name - output name of the image
- Wis3D.add_image(self, data: np.ndarray | torch.Tensor, *, name: str = None) None
Add an image by image definition
- Parameters:
data - data of the image
name - output name of the image
- Wis3D.add_image(self, image: Image.Image, *, name: str = None) None
Add an image by PIL.Image.Image
- Parameters:
image - image loaded by PIL.Image.open
name - output name of the image
add_boxes
- Wis3D.add_boxes(self, corners: np.ndarray | torch.Tensor, *, order: Iterable[int] = (0, 1, 2, 3, 4, 5, 6, 7), labels: Iterable[str] = None, name: str = None) None
Add boxes by corners
- Parameters:
corners - eight corners of the boxes, shape: (n, 8, 3) or (8, 3)
order - order of the corners, the default indices are defined as
4 --- 5 y /| / | | 7 --- 6 | | | 0--|- 1 o —— —— x | / | / / 3 --- 2 z
labels - label for each box
name - output name for these boxes
- Wis3D.add_boxes(self, positions: np.ndarray | torch.Tensor, eulers: np.ndarray | torch.Tensor, extents: np.ndarray | torch.Tensor, *, labels: Iterable[str] = None, name: str = None) None
Add boxes by definition
- Parameters:
positions - position for each box, shape: (n, 3) or (3,)
eulers - euler angles, shape: (n, 3) or (3,)
extents - extents of the boxes, shape: (n, 3) or (3,)
labels - label for each box, shape: (n,) or str
name - output name for these boxes
add_lines
- Wis3D.add_lines(self, start_points: np.ndarray | torch.Tensor, end_points: np.ndarray | torch.Tensor, colors: np.ndarray | torch.Tensor = None, *, name: str = None) None
Add lines by points
- Parameters:
start_points – start point of each line, shape: (n, 3) or (3,)
end_points – end point of each line, shape: (n, 3) or (3,)
colors – colors of the lines, shape: (n, 3), range [0, 255] dtype: np.uint8 or torch.byte
name – output name for these lines
add_voxel
- Wis3D.add_voxel(self, path: str, *, name: str = None) None
Add voxels by binvox/vox file
@param path: path to the BINVOX or VOX file
@param name: output name for these lines
- Wis3D.add_voxel(self, voxel_centers: np.ndarray | torch.Tensor, voxel_size: float, colors: np.ndarray | torch.Tensor = None, *, name: str = None) None
Add voxels by boxes
- Parameters:
voxel_centers - center for each box, shape: (n, 3) or (3,)
voxel_size - size of all boxes
colors - colors of each box, shape: (n, 3), range [0, 255] dtype: np.uint8 or torch.byte
name - output name for the voxel
add_spheres
- Wis3D.add_spheres(self, centers: np.ndarray | torch.Tensor, radius: float | np.ndarray | torch.Tensor, colors=None, scales=None, quaternions=None, *, name=None) None
Add spheres
- Parameters:
centers – center of each sphere, shape: (n, 3) or (3,)
radius – radius of each sphere, either float or shape of (n,) or (1,)
scales – scales of each sphere, shape: (n, 3) or (3,), if None, use [1, 1, 1]. Useful when you want to make the spheres ellipsoids
quaternions – rotations of each sphere, format wxyz, shape: (n, 4) or (4,), if None, use [1, 0, 0, 0]. Useful when you want to rotate the spheres
colors – colors of each box, shape: (n, 3), range [0, 255] dtype: np.uint8 or torch.byte
name – output name for the spheres
add_camera_trajectory
- Wis3D.add_camera_trajectory(self, poses: np.ndarray | torch.Tensor, is_opencv=None, *, name: str = None) None
Add a camera trajectory
- Parameters:
poses – transformation matrices of shape (n, 4, 4)
name – output name of the camera trajectory
add_keypoint_correspondences
- Wis3D.add_keypoint_correspondences(self, img0, img1, kpts0: np.ndarray | torch.Tensor, kpts1, *, unmatched_kpts0=None, unmatched_kpts1=None, metrics: Dict[str, Iterable[int]] = None, booleans: Dict[str, Iterable[bool]] = None, meta: Dict[str, Any] = None, name: str = None) None
Add keypoint correspondences
- Parameters:
img0 – path to the image or a PIL.Image.Image instance or a numpy.ndarray
img1 – path to the image or a PIL.Image.Image instance or a numpy.ndarray
kpts0 – keypoints of shape (n, 2)
kpts1 – keypoints of shape (n, 2)
unmatched_kpts0 – unmatched keypoints of shape (m, 2)
unmatched_kpts1 – unmatched keypoints of shape (l, 2)
metrics – a dictionary of metrics, each with the shape of (n, )
booleans – a dictionary of booleans, each with the shape of (n, )
meta – a dictionary of meta information of correspondences
name – outputname of the file
increase_scene_id
- Wis3D.increase_scene_id(self)
Increase scene ID by 1 :return:
add_box_by_6border
- Wis3D.add_box_by_6border(self, xmin, ymin, zmin, xmax, ymax, zmax, name=None)
Add a box by 6 borders
- Parameters:
xmin – float
ymin – float
zmin – float
xmax – float
ymax – float
zmax – float
name – float
- Returns:
add_camera_pose
- Wis3D.add_camera_pose(self, pose: np.ndarray | torch.Tensor, *, name: str = None) None
Add a camera pose (w2c). We use OpenCV convention for camera pose.
- Parameters:
pose – transformation matrices of shape (4, 4). Definition:
pt_world=matmul(pose,pt_camera)
- Parameters:
name – output name of the camera pose
add_rays
- Wis3D.add_rays(self, rays_o, rays_d, max=10.0, min=0.0, sample=1.0, name=None)
add rays to the scene, useful for debugging NeRF
- Parameters:
rays_o – (np.ndarray or torch.Tensor): [n, 3]
rays_d – (np.ndarray or torch.Tensor): [n,3]
max – (float, optional): Maximum norm of the ray. Defaults to 10.
min – (float, optional): Minimum norm of the ray. Defaults to 0.
sample – (float, optional): Sample ratio of the rays. Defaults to 1.0. If sample < 1.0, ratio of the rays will be sampled. If sample > 1.0, number of the rays will be sampled.
name – (str, optional): Name of the rays. Defaults to None.