3D utilities.
Class |
|
Class for storing metadata about orthographic projections. |
Function | compute |
Computes the IoU between the given ground truth and predicted cuboids. |
Function | compute |
Generates an orthographic projection image for the given PCD file onto the specified plane (default xy plane). |
Function | compute |
Computes orthographic projection images for the point clouds in the given collection. |
Function | get |
Extracts all asset paths for the specified 3D scenes. |
Function | pcd |
Converts the point cloud samples in the given dataset to 3D samples. |
Constant | DEFAULT |
Undocumented |
Variable | logger |
Undocumented |
Variable | o3d |
Undocumented |
Class | _ |
No class docstring; 0/6 instance variable, 2/5 methods documented |
Function | _clamp |
Discretize by mapping each continuous value in arr to the closest value in discrete. |
Function | _classify |
Classify position of a point w.r.t the given plane. |
Function | _clip |
Clips the polygon with the plane using the Sutherland-Hodgman algorithm. |
Function | _compute |
Computes the intersection of two boxes. |
Function | _contains |
Undocumented |
Function | _fill |
Undocumented |
Function | _get |
Undocumented |
Function | _get |
Undocumented |
Function | _get |
Undocumented |
Function | _get |
Return Tuple of scene paths to use and whether all are local This function is a no-op here but could be different in a repo fork. |
Function | _inside |
Checks whether a given point is on a 2D plane. |
Function | _intersect |
Computes the intersection of a line with an axis-aligned plane. |
Function | _intersect |
Clips the polygon against the faces of the axis-aligned box. |
Function | _make |
Undocumented |
Function | _parse |
Undocumented |
Function | _parse |
Undocumented |
Function | _pcd |
Undocumented |
Function | _pcd |
Undocumented |
Constant | _EDGES |
Undocumented |
Constant | _FACES |
Undocumented |
Constant | _FRONT |
Undocumented |
Constant | _NUM |
Undocumented |
Constant | _PLANE |
Undocumented |
Constant | _POINT |
Undocumented |
Constant | _POINT |
Undocumented |
Constant | _POINT |
Undocumented |
Constant | _TOP |
Undocumented |
Constant | _UNIT |
Undocumented |
Computes the IoU between the given ground truth and predicted cuboids.
Parameters | |
gt | a fiftyone.core.labels.Detection |
pred | a fiftyone.core.labels.Detection |
gtFalse | whether the ground truth cuboid is a crowd |
Returns | |
the IoU, in [0, 1] |
Generates an orthographic projection image for the given PCD file onto the specified plane (default xy plane).
The returned image is a three-channel array encoding the intensity, height, and density of the point cloud.
Parameters | |
filepath | the path to the .pcd file |
size | the desired (width, height) for the generated maps. Either dimension can be None or negative, in which case the appropriate aspect-preserving value is used |
shadingNone | an optional shading algorithm for the points. Supported values are ("intensity", "rgb", or "height"). The "intensity" and "rgb" options are only valid if the PCD's header contains the "rgb" flag. By default, all points are shaded white |
colormap:None | an optional colormap to use when shading gradients, formatted as either:
|
subsamplingNone | an unsigned int that, if defined, defines a uniform subsampling rate. The selected point indices are [0, k, 2k, ...], where k = subsampling_rate |
projectionNone | the normal vector of the plane onto which to perform the projection. By default, (0, 0, 1) is used |
bounds:None | an optional ((xmin, ymin, zmin), (xmax, ymax, zmax)) tuple defining the field of view for which to generate each map in the projected plane. Either element of the tuple or any/all of its values can be None, in which case a tight crop of the point cloud along the missing dimension(s) are used |
padding:None | a relative padding(s) in [0, 1]] to apply to the field of view bounds prior to projection. Can either be a single value to apply in all directions or a [padx, pady, padz]. For example, pass padding=0.25 with no bounds to project onto a tight crop of the point cloud with 25% padding around it |
Returns | |
a tuple of
|
Computes orthographic projection images for the point clouds in the given collection.
This operation will populate OrthographicProjectionMetadata
instances for each projection in the metadata_field of each sample.
Examples:
import fiftyone as fo import fiftyone.utils.utils3d as fou3d import fiftyone.zoo as foz dataset = foz.load_zoo_dataset("quickstart-groups") view = dataset.select_group_slices("pcd") fou3d.compute_orthographic_projection_images(view, (-1, 512), "/tmp/proj") session = fo.launch_app(view)
Parameters | |
samples | a fiftyone.core.collections.SampleCollection |
size | the desired (width, height) for the generated maps. Either dimension can be None or negative, in which case the appropriate aspect-preserving value is used |
output | an output directory in which to store the images/maps |
relNone | an optional relative directory to strip from each input filepath to generate a unique identifier that is joined with output_dir to generate an output path for each image. This argument allows for populating nested subdirectories in output_dir that match the shape of the input paths |
inNone | the name of the group slice containing the point cloud data. Only applicable if samples is a grouped collection. If samples is a grouped collection and this parameter is not provided, the first point cloud slice will be used |
outNone | the name of a group slice to which to add new samples containing the feature images/maps. Only applicable if samples is a grouped collection |
metadata | the name of the
field in which to store OrthographicProjectionMetadata
instances for each projection |
shadingNone | an optional shading algorithm for the points. Supported values are ("intensity", "rgb", or "height"). The "intensity" and "rgb" options are only valid if the PCD's header contains the "rgb" flag. By default, all points are shaded white |
colormap:None | an optional colormap to use when shading gradients, formatted as either:
|
subsamplingNone | an optional unsigned int that, if provided, defines a uniform subsampling rate. The selected point indices are [0, k, 2k, ...], where k = subsampling_rate |
projectionNone | the normal vector of the plane onto which to perform the projection. By default, (0, 0, 1) is used |
bounds:None | an optional ((xmin, ymin, zmin), (xmax, ymax, zmax)) tuple defining the field of view in the projected plane for which to generate each map. Either element of the tuple or any/all of its values can be None, in which case a tight crop of the point cloud along the missing dimension(s) are used |
padding:None | a relative padding(s) in [0, 1]] to apply to the field of view bounds prior to projection. Can either be a single value to apply in all directions or a [padx, pady, padz]. For example, pass padding=0.25 with no bounds to project onto a tight crop of each point cloud with 25% padding around it |
overwrite:False | whether to overwrite existing images |
skipFalse | whether to gracefully continue without raising an error if a projection fails |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Extracts all asset paths for the specified 3D scenes.
Parameters | |
scene | an iterable of .fo3d paths |
absFalse | whether to return absolute paths |
skipTrue | whether to gracefully continue without raising an error if metadata cannot be computed for a file |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Returns | |
a dict mapping scene paths to lists of asset paths |
Converts the point cloud samples in the given dataset to 3D samples.
Parameters | |
dataset | a fiftyone.core.dataset.Dataset containing point
clouds |
slices:None | point cloud slice(s) to convert. Only applicable when the dataset is grouped, in which case you can provide:
|
outputNone | an optional output directory for the .fo3d files |
assetsNone | an optional directory to copy the .pcd files into. Can be either an absolute directory, a subdirectory of output_dir, or None if you do not wish to copy point clouds |
relNone | an optional relative directory to strip from each point
cloud path to generate a unique identifier for each scene, which is
joined with output_dir to generate an output path for each
.fo3d file. This argument allows for populating nested
subdirectories that match the shape of the input paths. The path is
converted to an absolute path (if necessary) via
fiftyone.core.storage.normalize_path |
absFalse | whether to store absolute paths to the point cloud files in the exported .fo3d files |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Undocumented
Value |
|
Classify position of a point w.r.t the given plane.
See Real-Time Collision Detection, by Christer Ericson, page 364.
Parameters | |
point | 3x1 vector indicating the point |
plane | 3x1 vector indicating a point on the plane |
normal | scalar (+1, or -1) indicating the normal to the vector |
axis | scalar (0, 1, or 2) indicating the xyz axis |
Returns | |
which side of the plane the point is located |
Clips the polygon with the plane using the Sutherland-Hodgman algorithm.
See https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm for an overview of the Sutherland-Hodgman algorithm. Here we adopted a robust implementation from "Real-Time Collision Detection", by Christer Ericson, page 370.
Parameters | |
poly | list of 3D vertices defining the polygon |
plane | the 3D vertices of the (2D) axis-aligned plane |
normal | normal |
axis | a tuple defining a 2D axis |
Returns | |
the list of 3D vertices of the clipped polygon |
Return Tuple of scene paths to use and whether all are local This function is a no-op here but could be different in a repo fork.
Computes the intersection of a line with an axis-aligned plane.
Parameters | |
plane | formulated as two 3D points on the plane |
prev | the point on the edge of the line |
current | the other end of the line |
axis | a tuple defining a 2D axis |
Returns | |
A 3D point intersection of the poly edge with the plane |
Undocumented
Undocumented
Undocumented