Open3D (C++ API)
0.14.1
|
A point cloud contains a list of 3D points. More...
#include <PointCloud.h>
Public Member Functions | |
PointCloud (const core::Device &device=core::Device("CPU:0")) | |
PointCloud (const core::Tensor &points) | |
PointCloud (const std::unordered_map< std::string, core::Tensor > &map_keys_to_tensors) | |
virtual | ~PointCloud () override |
std::string | ToString () const |
Text description. More... | |
const TensorMap & | GetPointAttr () const |
Getter for point_attr_ TensorMap. Used in Pybind. More... | |
core::Tensor & | GetPointAttr (const std::string &key) |
core::Tensor & | GetPointPositions () |
Get the value of the "positions" attribute. Convenience function. More... | |
core::Tensor & | GetPointColors () |
Get the value of the "colors" attribute. Convenience function. More... | |
core::Tensor & | GetPointNormals () |
Get the value of the "normals" attribute. Convenience function. More... | |
const core::Tensor & | GetPointAttr (const std::string &key) const |
const core::Tensor & | GetPointPositions () const |
Get the value of the "positions" attribute. Convenience function. More... | |
const core::Tensor & | GetPointColors () const |
Get the value of the "colors" attribute. Convenience function. More... | |
const core::Tensor & | GetPointNormals () const |
Get the value of the "normals" attribute. Convenience function. More... | |
void | SetPointAttr (const std::string &key, const core::Tensor &value) |
void | SetPointPositions (const core::Tensor &value) |
Set the value of the "positions" attribute. Convenience function. More... | |
void | SetPointColors (const core::Tensor &value) |
Set the value of the "colors" attribute. Convenience function. More... | |
void | SetPointNormals (const core::Tensor &value) |
Set the value of the "normals" attribute. Convenience function. More... | |
bool | HasPointAttr (const std::string &key) const |
void | RemovePointAttr (const std::string &key) |
bool | HasPointPositions () const |
bool | HasPointColors () const |
bool | HasPointNormals () const |
PointCloud | To (const core::Device &device, bool copy=false) const |
PointCloud | Clone () const |
Returns copy of the point cloud on the same device. More... | |
PointCloud & | Clear () override |
Clear all data in the point cloud. More... | |
bool | IsEmpty () const override |
Returns !HasPointPositions(). More... | |
core::Tensor | GetMinBound () const |
Returns the min bound for point coordinates. More... | |
core::Tensor | GetMaxBound () const |
Returns the max bound for point coordinates. More... | |
core::Tensor | GetCenter () const |
Returns the center for point coordinates. More... | |
PointCloud | Append (const PointCloud &other) const |
PointCloud | operator+ (const PointCloud &other) const |
PointCloud & | Transform (const core::Tensor &transformation) |
Transforms the PointPositions and PointNormals (if exist) of the PointCloud. More... | |
PointCloud & | Translate (const core::Tensor &translation, bool relative=true) |
Translates the PointPositions of the PointCloud. More... | |
PointCloud & | Scale (double scale, const core::Tensor ¢er) |
Scales the PointPositions of the PointCloud. More... | |
PointCloud & | Rotate (const core::Tensor &R, const core::Tensor ¢er) |
Rotates the PointPositions and PointNormals (if exists). More... | |
PointCloud | VoxelDownSample (double voxel_size, const core::HashBackendType &backend=core::HashBackendType::Default) const |
Downsamples a point cloud with a specified voxel size. More... | |
core::Device | GetDevice () const |
Returns the device attribute of this PointCloud. More... | |
void | EstimateNormals (const int max_nn=30, const utility::optional< double > radius=utility::nullopt) |
Function to estimate point normals. If the point cloud normals exist, the estimated normals are oriented with respect to the same. It uses KNN search if only max_nn parameter is provided, and HybridSearch if radius parameter is also provided. More... | |
void | EstimateColorGradients (const int max_nn=30, const utility::optional< double > radius=utility::nullopt) |
Function to compute point color gradients. If radius is provided, then HybridSearch is used, otherwise KNN-Search is used. Reference: Park, Q.-Y. Zhou, and V. Koltun, Colored Point Cloud Registration Revisited, ICCV, 2017. More... | |
open3d::geometry::PointCloud | ToLegacy () const |
Convert to a legacy Open3D PointCloud. More... | |
geometry::Image | ProjectToDepthImage (int width, int height, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f) |
Project a point cloud to a depth image. More... | |
geometry::RGBDImage | ProjectToRGBDImage (int width, int height, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f) |
Project a point cloud to an RGBD image. More... | |
![]() | |
virtual | ~Geometry () |
GeometryType | GetGeometryType () const |
Returns one of registered geometry types. More... | |
int | Dimension () const |
Returns whether the geometry is 2D or 3D. More... | |
std::string | GetName () const |
void | SetName (const std::string &name) |
![]() | |
DrawableGeometry () | |
~DrawableGeometry () | |
bool | HasMaterial () const |
Check if a material has been applied to this Geometry with SetMaterial. More... | |
visualization::rendering::Material & | GetMaterial () |
Get material associated with this Geometry. More... | |
const visualization::rendering::Material & | GetMaterial () const |
Get const reference to material associated with this Geometry. More... | |
void | SetMaterial (const visualization::rendering::Material &material) |
Set the material properties associate with this Geometry. More... | |
Static Public Member Functions | |
static PointCloud | CreateFromDepthImage (const Image &depth, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f, int stride=1, bool with_normals=false) |
Factory function to create a point cloud from a depth image and a camera model. More... | |
static PointCloud | CreateFromRGBDImage (const RGBDImage &rgbd_image, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f, int stride=1, bool with_normals=false) |
Factory function to create a point cloud from an RGB-D image and a camera model. More... | |
static PointCloud | FromLegacy (const open3d::geometry::PointCloud &pcd_legacy, core::Dtype dtype=core::Float32, const core::Device &device=core::Device("CPU:0")) |
Create a PointCloud from a legacy Open3D PointCloud. More... | |
Protected Attributes | |
core::Device | device_ = core::Device("CPU:0") |
TensorMap | point_attr_ |
Additional Inherited Members | |
![]() | |
enum | GeometryType { GeometryType::Unspecified = 0, GeometryType::PointCloud = 1, GeometryType::VoxelGrid = 2, GeometryType::Octree = 3, GeometryType::LineSet = 4, GeometryType::MeshBase = 5, GeometryType::TriangleMesh = 6, GeometryType::HalfEdgeTriangleMesh = 7, GeometryType::Image = 8, GeometryType::RGBDImage = 9, GeometryType::TetraMesh = 10, GeometryType::OrientedBoundingBox = 11, GeometryType::AxisAlignedBoundingBox = 12 } |
Specifies possible geometry types. More... | |
![]() | |
Geometry (GeometryType type, int dimension) | |
Parameterized Constructor. More... | |
A point cloud contains a list of 3D points.
The point cloud class stores the attribute data in key-value maps, where the key is a string representing the attribute name and the value is a Tensor containing the attribute data. In most cases, the length of an attribute should be equal to the length of the point cloud's "positions".
PointCloud::GetPointAttr(), PointCloud::SetPointAttr(), PointCloud::HasPointAttr() also work for default attribute "position" and common attributes "normals" and "colors", e.g.,
open3d::t::geometry::PointCloud::PointCloud | ( | const core::Device & | device = core::Device("CPU:0") | ) |
Construct an empty point cloud on the provided device.
device | The device on which to initialize the point cloud (default: 'CPU:0'). |
open3d::t::geometry::PointCloud::PointCloud | ( | const core::Tensor & | points | ) |
Construct a point cloud from points.
The input tensor will be directly used as the underlying storage of the point cloud (no memory copy).
points | A tensor with element shape {3}. |
open3d::t::geometry::PointCloud::PointCloud | ( | const std::unordered_map< std::string, core::Tensor > & | map_keys_to_tensors | ) |
Construct from points and other attributes of the points.
map_keys_to_tensors | A map of string to Tensor containing points and their attributes. point_dict must contain at least the "positions" key. |
|
inlineoverridevirtual |
PointCloud open3d::t::geometry::PointCloud::Append | ( | const PointCloud & | other | ) | const |
Append a point cloud and returns the resulting point cloud.
The point cloud being appended, must have all the attributes present in the point cloud it is being appended to, with same dtype, device and same shape other than the first dimension / length.
|
inlineoverridevirtual |
Clear all data in the point cloud.
Implements open3d::t::geometry::Geometry.
PointCloud open3d::t::geometry::PointCloud::Clone | ( | ) | const |
Returns copy of the point cloud on the same device.
|
static |
Factory function to create a point cloud from a depth image and a camera model.
Given depth value d at (u, v) image coordinate, the corresponding 3d point is:
depth | The input depth image should be a uint16_t or float image. |
intrinsics | Intrinsic parameters of the camera. |
extrinsics | Extrinsic parameters of the camera. |
depth_scale | The depth is scaled by 1 / depth_scale . |
depth_max | Truncated at depth_max distance. |
stride | Sampling factor to support coarse point cloud extraction. Unless with_normals=true , there is no low pass filtering, so aliasing is possible for stride>1 . |
with_normals | Also compute normals for the point cloud. If True, the point cloud will only contain points with valid normals. If normals are requested, the depth map is first filtered to ensure smooth normals. |
|
static |
Factory function to create a point cloud from an RGB-D image and a camera model.
Given depth value d at (u, v) image coordinate, the corresponding 3d point is:
rgbd_image | The input RGBD image should have a uint16_t or float depth image and RGB image with any DType and the same size. |
intrinsics | Intrinsic parameters of the camera. |
extrinsics | Extrinsic parameters of the camera. |
depth_scale | The depth is scaled by 1 / depth_scale . |
depth_max | Truncated at depth_max distance. |
stride | Sampling factor to support coarse point cloud extraction. Unless with_normals=true , there is no low pass filtering, so aliasing is possible for stride>1 . |
with_normals | Also compute normals for the point cloud. If True, the point cloud will only contain points with valid normals. If normals are requested, the depth map is first filtered to ensure smooth normals. |
void open3d::t::geometry::PointCloud::EstimateColorGradients | ( | const int | max_nn = 30 , |
const utility::optional< double > | radius = utility::nullopt |
||
) |
Function to compute point color gradients. If radius is provided, then HybridSearch is used, otherwise KNN-Search is used. Reference: Park, Q.-Y. Zhou, and V. Koltun, Colored Point Cloud Registration Revisited, ICCV, 2017.
max_nn | NeighbourSearch max neighbours parameter [Default = 30]. |
radius | [optional] NeighbourSearch radius parameter to use HybridSearch. [Recommended ~1.4x voxel size]. |
void open3d::t::geometry::PointCloud::EstimateNormals | ( | const int | max_nn = 30 , |
const utility::optional< double > | radius = utility::nullopt |
||
) |
Function to estimate point normals. If the point cloud normals exist, the estimated normals are oriented with respect to the same. It uses KNN search if only max_nn parameter is provided, and HybridSearch if radius parameter is also provided.
max_nn | NeighbourSearch max neighbours parameter [Default = 30]. |
radius | [optional] NeighbourSearch radius parameter to use HybridSearch. [Recommended ~1.4x voxel size]. |
|
static |
Create a PointCloud from a legacy Open3D PointCloud.
core::Tensor open3d::t::geometry::PointCloud::GetCenter | ( | ) | const |
Returns the center for point coordinates.
|
inline |
Returns the device attribute of this PointCloud.
core::Tensor open3d::t::geometry::PointCloud::GetMaxBound | ( | ) | const |
Returns the max bound for point coordinates.
core::Tensor open3d::t::geometry::PointCloud::GetMinBound | ( | ) | const |
Returns the min bound for point coordinates.
|
inline |
Getter for point_attr_ TensorMap. Used in Pybind.
|
inline |
Get attributes. Throws exception if the attribute does not exist.
key | Attribute name. |
|
inline |
Get attributes. Throws exception if the attribute does not exist.
key | Attribute name. |
|
inline |
Get the value of the "colors" attribute. Convenience function.
|
inline |
Get the value of the "colors" attribute. Convenience function.
|
inline |
Get the value of the "normals" attribute. Convenience function.
|
inline |
Get the value of the "normals" attribute. Convenience function.
|
inline |
Get the value of the "positions" attribute. Convenience function.
|
inline |
Get the value of the "positions" attribute. Convenience function.
|
inline |
Returns true if all of the followings are true: 1) attribute key exist 2) attribute's length as points' length 3) attribute's length > 0
|
inline |
Returns true if all of the followings are true: 1) attribute "colors" exist 2) attribute "colors"'s length as points' length 3) attribute "colors"'s length > 0 This is a convenience function.
|
inline |
Returns true if all of the followings are true: 1) attribute "normals" exist 2) attribute "normals"'s length as points' length 3) attribute "normals"'s length > 0 This is a convenience function.
|
inline |
Check if the "positions" attribute's value has length > 0. This is a convenience function.
|
inlineoverridevirtual |
Returns !HasPointPositions().
Implements open3d::t::geometry::Geometry.
|
inline |
operator+ for t::PointCloud appends the compatible attributes to the point cloud.
geometry::Image open3d::t::geometry::PointCloud::ProjectToDepthImage | ( | int | width, |
int | height, | ||
const core::Tensor & | intrinsics, | ||
const core::Tensor & | extrinsics = core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")) , |
||
float | depth_scale = 1000.0f , |
||
float | depth_max = 3.0f |
||
) |
Project a point cloud to a depth image.
geometry::RGBDImage open3d::t::geometry::PointCloud::ProjectToRGBDImage | ( | int | width, |
int | height, | ||
const core::Tensor & | intrinsics, | ||
const core::Tensor & | extrinsics = core::Tensor::Eye(4, core::Float32, core::Device("CPU:0")) , |
||
float | depth_scale = 1000.0f , |
||
float | depth_max = 3.0f |
||
) |
Project a point cloud to an RGBD image.
|
inline |
Removes point attribute by key value. Primary attribute "positions" cannot be removed. Throws warning if attribute key does not exists.
key | Attribute name. |
PointCloud & open3d::t::geometry::PointCloud::Rotate | ( | const core::Tensor & | R, |
const core::Tensor & | center | ||
) |
Rotates the PointPositions and PointNormals (if exists).
R | Rotation [Tensor of dim {3,3}]. Should be on the same device as the PointCloud |
center | Center [Tensor of dim {3}] about which the PointCloud is to be scaled. Should be on the same device as the PointCloud |
PointCloud & open3d::t::geometry::PointCloud::Scale | ( | double | scale, |
const core::Tensor & | center | ||
) |
Scales the PointPositions of the PointCloud.
scale | Scale [double] of dimension |
center | Center [Tensor of dim {3}] about which the PointCloud is to be scaled. Should be on the same device as the PointCloud |
|
inline |
Set attributes. If the attribute key already exists, its value will be overwritten, otherwise, the new key will be created.
key | Attribute name. |
value | A tensor. |
|
inline |
Set the value of the "colors" attribute. Convenience function.
|
inline |
Set the value of the "normals" attribute. Convenience function.
|
inline |
Set the value of the "positions" attribute. Convenience function.
PointCloud open3d::t::geometry::PointCloud::To | ( | const core::Device & | device, |
bool | copy = false |
||
) | const |
Transfer the point cloud to a specified device.
device | The targeted device to convert to. |
copy | If true, a new point cloud is always created; if false, the copy is avoided when the original point cloud is already on the targeted device. |
open3d::geometry::PointCloud open3d::t::geometry::PointCloud::ToLegacy | ( | ) | const |
Convert to a legacy Open3D PointCloud.
std::string open3d::t::geometry::PointCloud::ToString | ( | ) | const |
Text description.
PointCloud & open3d::t::geometry::PointCloud::Transform | ( | const core::Tensor & | transformation | ) |
Transforms the PointPositions and PointNormals (if exist) of the PointCloud.
Transformation matrix is a 4x4 matrix. T (4x4) = [[ R(3x3) t(3x1) ], [ O(1x3) s(1x1) ]] (s = 1 for Transformation without scaling)
It applies the following general transform to each positions
and normals
. |x'| | R(0,0) R(0,1) R(0,2) t(0)| |x| |y'| = | R(1,0) R(1,1) R(1,2) t(1)| @ |y| |z'| | R(2,0) R(2,1) R(2,2) t(2)| |z| |w'| | O(0,0) O(0,1) O(0,2) s | |1|
[x, y, z] = [x', y', z'] / w'
transformation | Transformation [Tensor of dim {4,4}]. |
PointCloud & open3d::t::geometry::PointCloud::Translate | ( | const core::Tensor & | translation, |
bool | relative = true |
||
) |
Translates the PointPositions of the PointCloud.
translation | translation tensor of dimension {3} Should be on the same device as the PointCloud |
relative | if true (default): translates relative to Center |
PointCloud open3d::t::geometry::PointCloud::VoxelDownSample | ( | double | voxel_size, |
const core::HashBackendType & | backend = core::HashBackendType::Default |
||
) | const |
Downsamples a point cloud with a specified voxel size.
voxel_size | Voxel size. A positive number. |
|
protected |
|
protected |