23 min_bound_(core::Tensor::
Zeros({3},
dtype_, device)),
37 device_ = min_bound.GetDevice();
38 dtype_ = min_bound.GetDtype();
47 "max_bound {} of bounding box is smaller than min_bound {} in "
48 "one or more axes. Fix input values to remove this warning.",
86 "Invalid axis-aligned bounding box. Please make sure all "
87 "the elements in min bound are smaller than max bound.");
104 "Invalid axis-aligned bounding box. Please make sure all "
105 "the elements in max bound are larger than min bound.");
117 "The color must be in the range [0, 1], but found in range "
150 center_d = center.
value();
166 "The data-type of the other bounding box is {}, but the "
167 "data-type of this bounding box is {}.",
184 return (x - x_min) / (x_max - x_min);
190 return (y - y_min) / (y_max - y_min);
196 return (z - z_min) / (z_max - z_min);
223 return mask.NonZero().Flatten();
227 return fmt::format(
"AxisAlignedBoundingBox[{} - {}, {}, {}]",
237 if (
points.GetLength() <= 0) {
239 "The number of points is 0 when creating axis-aligned bounding "
285 "Got data-type {}, but the supported data-type of the bounding "
286 "box are Float32 and Float64.",
330 dtype_ = center.GetDtype();
342 "Invalid oriented bounding box. Please make sure the values of "
343 "extent are all positive and the rotation matrix is "
384 "Invalid oriented bounding box. Please make sure the values of "
385 "extent are all positive.");
398 "Invalid oriented bounding box. Please make sure the rotation "
399 "matrix is orthogonal.");
411 "The color must be in the range [0, 1], but found in range "
458 "Invalid rotation matrix. Please make sure the rotation "
459 "matrix is orthogonal.");
469 {core::Float32, core::Float64});
485 Rotate(transformation_d.GetItem({core::TensorKey::Slice(0, 3, 1),
486 core::TensorKey::Slice(0, 3, 1)}));
523 return mask.NonZero().Flatten();
563 "Got data-type {}, but the supported data-type of the bounding "
564 "box are Float32 and Float64.",
590 if (
points.GetShape(0) < 4) {
605 "Invalid method for computing oriented bounding "
606 "box. Supported methods are PCA, MINIMAL_APPROX, "
607 "and MINIMAL_JYLANKI.");
float PointCoordinateType
Type of the coordinates of a (N-D) point.
filament::Texture::InternalFormat format
#define AssertTensorDevice(tensor,...)
#define AssertTensorDtype(tensor,...)
#define AssertTensorDtypes(tensor,...)
#define AssertTensorShape(tensor,...)
Eigen::Vector3d GetColor() const
Gets the bounding box color.
const Vector3Tpl< T > & maxCorner() const
Returns max corner (const)
const Vector3Tpl< T > & minCorner() const
Returns min corner (const)
void SetColor(const Eigen::Vector3d &color)
Sets the bounding box color.
const Eigen::Vector3d & GetExtent() const
const Eigen::Vector3d & GetPosition() const
const Eigen::Matrix3d & GetRotation() const
const Eigen::Vector3d & GetColor() const
Gets the bounding box color.
void SetColor(const Eigen::Vector3d &color)
Sets the bounding box color.
std::string ToString() const
static TensorKey Index(int64_t index)
static TensorKey Slice(utility::optional< int64_t > start, utility::optional< int64_t > stop, utility::optional< int64_t > step)
bool AllClose(const Tensor &other, double rtol=1e-5, double atol=1e-8) const
Tensor Matmul(const Tensor &rhs) const
static Tensor Eye(int64_t n, Dtype dtype, const Device &device)
Create an identity matrix of size n x n.
Tensor Max(const SizeVector &dims, bool keepdim=false) const
Tensor Flatten(int64_t start_dim=0, int64_t end_dim=-1) const
static Tensor Zeros(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with zeros.
Tensor Add(const Tensor &value) const
Adds a tensor and returns the resulting tensor.
Device GetDevice() const override
Tensor Min(const SizeVector &dims, bool keepdim=false) const
Tensor Reshape(const SizeVector &dst_shape) const
Tensor Clone() const
Copy Tensor to the same device.
std::string ToString(bool with_suffix=true, const std::string &indent="") const
static Tensor Ones(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with ones.
Tensor T() const
Expects input to be <= 2-D Tensor by swapping dimension 0 and 1.
Tensor Mul(const Tensor &value) const
Multiplies a tensor and returns the resulting tensor.
Tensor To(Dtype dtype, bool copy=false) const
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
core::Tensor color_
The color of the bounding box in RGB. The default is white.
cloudViewer::geometry::AxisAlignedBoundingBox ToLegacy() const
Convert to a legacy CloudViewer axis-aligned box.
core::Tensor GetMinBound() const
core::Tensor max_bound_
The upper x, y, z bounds of the bounding box.
core::Tensor GetExtent() const
Get the extent/length of the bounding box in x, y, and z dimension.
core::Tensor GetPointIndicesWithinBoundingBox(const core::Tensor &points) const
Indices to points that are within the bounding box.
static AxisAlignedBoundingBox FromLegacy(const cloudViewer::geometry::AxisAlignedBoundingBox &box, const core::Dtype &dtype=core::Float32, const core::Device &device=core::Device("CPU:0"))
void SetColor(const core::Tensor &color)
Set the color of the box. If the data type of the given tensor differs from the data type of the box,...
static AxisAlignedBoundingBox CreateFromPoints(const core::Tensor &points)
core::Tensor GetCenter() const
core::Tensor min_bound_
The lower x, y, z bounds of the bounding box.
core::Device device_
The device to use for the bounding box. The default is CPU:0.
core::Device GetDevice() const override
Returns the device attribute of this AxisAlignedBoundingBox.
double GetXPercentage(double x) const
void SetMinBound(const core::Tensor &min_bound)
Set the min bound of the box. If the data type of the given tensor differs from the data type of the ...
AxisAlignedBoundingBox To(const core::Device &device, bool copy=false) const
Transfer the AxisAlignedBoundingBox to a specified device.
AxisAlignedBoundingBox & operator+=(const AxisAlignedBoundingBox &other)
Add operation for axis-aligned bounding box. The device of other box must be the same as the device o...
AxisAlignedBoundingBox(const core::Device &device=core::Device("CPU:0"))
Construct an empty AxisAlignedBoundingBox on the provided device.
core::Tensor GetMaxBound() const
bool IsEmpty() const override
Returns true iff the geometry is empty.
double GetZPercentage(double z) const
core::Tensor GetColor() const
AxisAlignedBoundingBox & Clear() override
Clear all elements in the geometry.
core::Dtype dtype_
The data type of the bounding box.
double GetYPercentage(double y) const
OrientedBoundingBox GetOrientedBoundingBox() const
Convert to an oriented box.
core::Tensor GetHalfExtent() const
Returns the half extent of the bounding box.
void SetMaxBound(const core::Tensor &max_bound)
Set the max bound of the box. If the data type of the given tensor differs from the data type of the ...
AxisAlignedBoundingBox & Scale(double scale, const utility::optional< core::Tensor > ¢er=utility::nullopt)
Scale the axis-aligned box. If is the min_bound and is the max_bound of the axis aligned bounding b...
core::Tensor GetBoxPoints() const
Returns the eight points that define the bounding box.
std::string ToString() const
Text description.
AxisAlignedBoundingBox & Translate(const core::Tensor &translation, bool relative=true)
Translate the axis-aligned box by the given translation.
core::Dtype GetDtype() const
Returns the data type attribute of this AxisAlignedBoundingBox.
double Volume() const
Returns the volume of the bounding box.
GeometryType
Specifies possible geometry types.
A bounding box oriented along an arbitrary frame of reference.
OrientedBoundingBox(const core::Device &device=core::Device("CPU:0"))
Construct an empty OrientedBoundingBox on the provided device.
OrientedBoundingBox & Rotate(const core::Tensor &rotation, const utility::optional< core::Tensor > ¢er=utility::nullopt)
Rotate the oriented box by the given rotation matrix. If the rotation matrix is not orthogonal,...
AxisAlignedBoundingBox GetAxisAlignedBoundingBox() const
Convert to an axis-aligned box.
OrientedBoundingBox To(const core::Device &device, bool copy=false) const
void SetExtent(const core::Tensor &extent)
Set the extent of the box. If the data type of the given tensor differs from the data type of the box...
cloudViewer::geometry::OrientedBoundingBox ToLegacy() const
Convert to a legacy CloudViewer oriented box.
core::Dtype GetDtype() const
Returns the data type attribute of this OrientedBoundingBox.
core::Tensor GetExtent() const
core::Tensor GetMaxBound() const
OrientedBoundingBox & Scale(double scale, const utility::optional< core::Tensor > ¢er=utility::nullopt)
Scale the axis-aligned box. If is the min_bound and is the max_bound of the axis aligned bounding b...
OrientedBoundingBox & Clear() override
Clear all elements in the geometry.
static OrientedBoundingBox CreateFromPoints(const core::Tensor &points, bool robust=false, MethodOBBCreate method=MethodOBBCreate::MINIMAL_APPROX)
OrientedBoundingBox & Transform(const core::Tensor &transformation)
Transform the oriented box by the given transformation matrix.
OrientedBoundingBox & Translate(const core::Tensor &translation, bool relative=true)
Translate the oriented box by the given translation. If relative is true, the translation is added to...
static OrientedBoundingBox CreateFromAxisAlignedBoundingBox(const AxisAlignedBoundingBox &aabb)
void SetCenter(const core::Tensor ¢er)
Set the center of the box. If the data type of the given tensor differs from the data type of the box...
core::Tensor GetBoxPoints() const
Returns the eight points that define the bounding box.
core::Device GetDevice() const override
Returns the device attribute of this OrientedBoundingBox.
static OrientedBoundingBox FromLegacy(const cloudViewer::geometry::OrientedBoundingBox &box, const core::Dtype &dtype=core::Float32, const core::Device &device=core::Device("CPU:0"))
core::Tensor GetPointIndicesWithinBoundingBox(const core::Tensor &points) const
Indices to points that are within the bounding box.
std::string ToString() const
Text description.
void SetRotation(const core::Tensor &rotation)
Set the rotation matrix of the box. If the data type of the given tensor differs from the data type o...
core::Tensor GetMinBound() const
double Volume() const
Returns the volume of the bounding box.
void SetColor(const core::Tensor &color)
Set the color of the box.
core::Tensor GetColor() const
core::Tensor GetCenter() const
core::Tensor GetRotation() const
constexpr bool has_value() const noexcept
constexpr T const & value() const &
static ecvOrientedBBox CreateFromPoints(const std::vector< Eigen::Vector3d > &points)
core::Tensor EigenMatrixToTensor(const Eigen::MatrixBase< Derived > &matrix)
Converts a eigen matrix of shape (M, N) with alignment A and type T to a tensor.
std::vector< Eigen::Vector3d > TensorToEigenVector3dVector(const core::Tensor &tensor)
Converts a tensor of shape (N, 3) to std::vector<Eigen::Vector3d>. An exception will be thrown if the...
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > TensorToEigenMatrixXd(const core::Tensor &tensor)
Converts a 2D tensor to Eigen::MatrixXd of same shape. Regardless of the tensor dtype,...
Tensor Concatenate(const std::vector< Tensor > &tensors, const utility::optional< int64_t > &axis)
Concatenates the list of tensors in their order, along the given axis into a new tensor....
void Zeros(benchmark::State &state, const Device &device)
Tensor Minimum(const Tensor &input, const Tensor &other)
Computes the element-wise minimum of input and other. The tensors must have same data type and device...
Tensor Maximum(const Tensor &input, const Tensor &other)
Computes the element-wise maximum of input and other. The tensors must have same data type and device...
OrientedBoundingBox ComputeMinimumOBBApprox(const core::Tensor &points, bool robust)
OrientedBoundingBox ComputeMinimumOBBJylanki(const core::Tensor &points_, bool robust)
void GetPointMaskWithinAABB(const core::Tensor &points, const core::Tensor &min_bound, const core::Tensor &max_bound, core::Tensor &mask)
void GetPointMaskWithinOBB(const core::Tensor &points, const core::Tensor ¢er, const core::Tensor &rotation, const core::Tensor &extent, core::Tensor &mask)
@ MINIMAL_APPROX
Minimal OBB approximation.
@ PCA
Principal Component Analysis.
@ MINIMAL_JYLANKI
Minimal OBB by Jylanki.
constexpr nullopt_t nullopt
Generic file read and write utility for python interface.