Open3D (C++ API)  0.13.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Protected Attributes
open3d::t::geometry::PointCloud Class Reference

A pointcloud contains a set of 3D points. More...

#include <PointCloud.h>

Inheritance diagram for open3d::t::geometry::PointCloud:
open3d::t::geometry::Geometry

Public Member Functions

 PointCloud (const core::Device &device=core::Device("CPU:0"))
 Construct an empty pointcloud. More...
 
 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 TensorMapGetPointAttr () const
 Getter for point_attr_ TensorMap. Used in Pybind. More...
 
core::TensorGetPointAttr (const std::string &key)
 
core::TensorGetPoints ()
 Get the value of the "points" attribute. Convenience function. More...
 
core::TensorGetPointColors ()
 Get the value of the "colors" attribute. Convenience function. More...
 
core::TensorGetPointNormals ()
 Get the value of the "normals" attribute. Convenience function. More...
 
const core::TensorGetPointAttr (const std::string &key) const
 
const core::TensorGetPoints () const
 Get the value of the "points" attribute. Convenience function. More...
 
const core::TensorGetPointColors () const
 Get the value of the "colors" attribute. Convenience function. More...
 
const core::TensorGetPointNormals () const
 Get the value of the "normals" attribute. Convenience function. More...
 
void SetPointAttr (const std::string &key, const core::Tensor &value)
 
void SetPoints (const core::Tensor &value)
 Set the value of the "points" 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 HasPoints () 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 CPU () const
 
PointCloud CUDA (int device_id=0) const
 
PointCloudClear () override
 Clear all data in the pointcloud. More...
 
bool IsEmpty () const override
 Returns !HasPoints(). 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
 
PointCloudTransform (const core::Tensor &transformation)
 Transforms the points and normals (if exist) of the PointCloud. Extracts R, t from Transformation T (4x4) = [[ R(3x3) t(3x1) ], [ O(1x3) s(1x1) ]] (s = 1 for Transformation wihtout scaling) PS. It Assumes s = 1 and O = [0,0,0] and applies the transformation as P = R(P) + t. More...
 
PointCloudTranslate (const core::Tensor &translation, bool relative=true)
 Translates the points of the PointCloud. More...
 
PointCloudScale (double scale, const core::Tensor &center)
 Scales the points of the PointCloud. More...
 
PointCloudRotate (const core::Tensor &R, const core::Tensor &center)
 Rotates the points and normals (if exists). More...
 
PointCloud VoxelDownSample (double voxel_size, const core::HashmapBackend &backend=core::HashmapBackend::Default) const
 Downsamples a point cloud with a specified voxel size. More...
 
core::Device GetDevice () const
 Returns the device attribute of this PointCloud. More...
 
open3d::geometry::PointCloud ToLegacyPointCloud () 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::Dtype::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::Dtype::Float32, core::Device("CPU:0")), float depth_scale=1000.0f, float depth_max=3.0f)
 Project a point cloud to an RGBD image. More...
 
- Public Member Functions inherited from open3d::t::geometry::Geometry
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)
 

Static Public Member Functions

static PointCloud CreateFromDepthImage (const Image &depth, const core::Tensor &intrinsics, const core::Tensor &extrinsics=core::Tensor::Eye(4, core::Dtype::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 pointcloud 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::Dtype::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 pointcloud from an RGB-D image and a camera model. More...
 
static PointCloud FromLegacyPointCloud (const open3d::geometry::PointCloud &pcd_legacy, core::Dtype dtype=core::Dtype::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

- Public Types inherited from open3d::t::geometry::Geometry
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...
 
- Protected Member Functions inherited from open3d::t::geometry::Geometry
 Geometry (GeometryType type, int dimension)
 Parameterized Constructor. More...
 

Detailed Description

A pointcloud contains a set of 3D points.

The PointCloud class stores the attribute data in key-value pairs for flexibility, where the key is a string representing the attribute name and value is a Tensor containing the attribute data. In most cases, the length of an attribute should be equal to the length of the "points", the pointcloud class provides helper functions to check and facilitates this consistency.

Although the attributes are all stored in a key-value pair dictionary, the attributes have different levels:

Note that the level 0 and level 1 convenience functions can also be achieved via the generalized helper functions:

Constructor & Destructor Documentation

◆ PointCloud() [1/3]

open3d::t::geometry::PointCloud::PointCloud ( const core::Device device = core::Device("CPU:0"))

Construct an empty pointcloud.

◆ PointCloud() [2/3]

open3d::t::geometry::PointCloud::PointCloud ( const core::Tensor points)

Construct a pointcloud from points.

Parameters
pointsA tensor with element shape (3,).
  • The resulting pointcloud will have the same dtype and device as the tensor.
  • If the tensor is created in-place from a pre-allocated buffer, the tensor has a fixed size and thus the resulting pointcloud will have a fixed size and calling to functions like SynchronizedPushBack will raise an exception.

◆ PointCloud() [3/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.

Parameters
map_keys_to_tensorsA map of string to Tensor containing points and their attributes. point_dict must contain at least the "points" key.

◆ ~PointCloud()

virtual open3d::t::geometry::PointCloud::~PointCloud ( )
inlineoverridevirtual

Member Function Documentation

◆ Append()

PointCloud open3d::t::geometry::PointCloud::Append ( const PointCloud other) const

Append a pointcloud and returns the resulting pointcloud.

The pointcloud being appended, must have all the attributes present in the pointcloud it is being appended to, with same dtype, device and same shape other than the first dimension / length.

◆ Clear()

PointCloud& open3d::t::geometry::PointCloud::Clear ( )
inlineoverridevirtual

Clear all data in the pointcloud.

Implements open3d::t::geometry::Geometry.

◆ Clone()

PointCloud open3d::t::geometry::PointCloud::Clone ( ) const

Returns copy of the point cloud on the same device.

◆ CPU()

PointCloud open3d::t::geometry::PointCloud::CPU ( ) const
inline

Transfer the point cloud to CPU.

If the point cloud is already on CPU, no copy will be performed.

◆ CreateFromDepthImage()

PointCloud open3d::t::geometry::PointCloud::CreateFromDepthImage ( const Image depth,
const core::Tensor intrinsics,
const core::Tensor extrinsics = core::Tensor::Eye(                    4, core::Dtype::Float32core::Device("CPU:0")),
float  depth_scale = 1000.0f,
float  depth_max = 3.0f,
int  stride = 1,
bool  with_normals = false 
)
static

Factory function to create a pointcloud from a depth image and a camera model.

Given depth value d at (u, v) image coordinate, the corresponding 3d point is:

  • z = d / depth_scale
  • x = (u - cx) * z / fx
  • y = (v - cy) * z / fy
Parameters
depthThe input depth image should be a uint16_t or float image.
intrinsicsIntrinsic parameters of the camera.
extrinsicsExtrinsic parameters of the camera.
depth_scaleThe depth is scaled by 1 / depth_scale.
depth_maxTruncated at depth_max distance.
strideSampling 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_normalsAlso 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.
Returns
Created pointcloud with the 'points' property set. Thus is empty if the conversion fails.

◆ CreateFromRGBDImage()

PointCloud open3d::t::geometry::PointCloud::CreateFromRGBDImage ( const RGBDImage rgbd_image,
const core::Tensor intrinsics,
const core::Tensor extrinsics = core::Tensor::Eye(                    4, core::Dtype::Float32core::Device("CPU:0")),
float  depth_scale = 1000.0f,
float  depth_max = 3.0f,
int  stride = 1,
bool  with_normals = false 
)
static

Factory function to create a pointcloud from an RGB-D image and a camera model.

Given depth value d at (u, v) image coordinate, the corresponding 3d point is:

  • z = d / depth_scale
  • x = (u - cx) * z / fx
  • y = (v - cy) * z / fy
Parameters
rgbd_imageThe input RGBD image should have a uint16_t or float depth image and RGB image with any DType and the same size.
intrinsicsIntrinsic parameters of the camera.
extrinsicsExtrinsic parameters of the camera.
depth_scaleThe depth is scaled by 1 / depth_scale.
depth_maxTruncated at depth_max distance.
strideSampling 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_normalsAlso 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.
Returns
Created pointcloud with the 'points' and 'colors' properties set. This is empty if the conversion fails.

◆ CUDA()

PointCloud open3d::t::geometry::PointCloud::CUDA ( int  device_id = 0) const
inline

Transfer the point cloud to a CUDA device.

If the point cloud is already on the specified CUDA device, no copy will be performed.

◆ FromLegacyPointCloud()

PointCloud open3d::t::geometry::PointCloud::FromLegacyPointCloud ( const open3d::geometry::PointCloud pcd_legacy,
core::Dtype  dtype = core::Dtype::Float32,
const core::Device device = core::Device("CPU:0") 
)
static

Create a PointCloud from a legacy Open3D PointCloud.

◆ GetCenter()

core::Tensor open3d::t::geometry::PointCloud::GetCenter ( ) const

Returns the center for point coordinates.

◆ GetDevice()

core::Device open3d::t::geometry::PointCloud::GetDevice ( ) const
inline

Returns the device attribute of this PointCloud.

◆ GetMaxBound()

core::Tensor open3d::t::geometry::PointCloud::GetMaxBound ( ) const

Returns the max bound for point coordinates.

◆ GetMinBound()

core::Tensor open3d::t::geometry::PointCloud::GetMinBound ( ) const

Returns the min bound for point coordinates.

◆ GetPointAttr() [1/3]

const TensorMap& open3d::t::geometry::PointCloud::GetPointAttr ( ) const
inline

Getter for point_attr_ TensorMap. Used in Pybind.

◆ GetPointAttr() [2/3]

core::Tensor& open3d::t::geometry::PointCloud::GetPointAttr ( const std::string &  key)
inline

Get attributes. Throws exception if the attribute does not exist.

Parameters
keyAttribute name.

◆ GetPointAttr() [3/3]

const core::Tensor& open3d::t::geometry::PointCloud::GetPointAttr ( const std::string &  key) const
inline

Get attributes. Throws exception if the attribute does not exist.

Parameters
keyAttribute name.

◆ GetPointColors() [1/2]

core::Tensor& open3d::t::geometry::PointCloud::GetPointColors ( )
inline

Get the value of the "colors" attribute. Convenience function.

◆ GetPointColors() [2/2]

const core::Tensor& open3d::t::geometry::PointCloud::GetPointColors ( ) const
inline

Get the value of the "colors" attribute. Convenience function.

◆ GetPointNormals() [1/2]

core::Tensor& open3d::t::geometry::PointCloud::GetPointNormals ( )
inline

Get the value of the "normals" attribute. Convenience function.

◆ GetPointNormals() [2/2]

const core::Tensor& open3d::t::geometry::PointCloud::GetPointNormals ( ) const
inline

Get the value of the "normals" attribute. Convenience function.

◆ GetPoints() [1/2]

core::Tensor& open3d::t::geometry::PointCloud::GetPoints ( )
inline

Get the value of the "points" attribute. Convenience function.

◆ GetPoints() [2/2]

const core::Tensor& open3d::t::geometry::PointCloud::GetPoints ( ) const
inline

Get the value of the "points" attribute. Convenience function.

◆ HasPointAttr()

bool open3d::t::geometry::PointCloud::HasPointAttr ( const std::string &  key) const
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

◆ HasPointColors()

bool open3d::t::geometry::PointCloud::HasPointColors ( ) const
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.

◆ HasPointNormals()

bool open3d::t::geometry::PointCloud::HasPointNormals ( ) const
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.

◆ HasPoints()

bool open3d::t::geometry::PointCloud::HasPoints ( ) const
inline

Check if the "points" attribute's value has length > 0. This is a convenience function.

◆ IsEmpty()

bool open3d::t::geometry::PointCloud::IsEmpty ( ) const
inlineoverridevirtual

Returns !HasPoints().

Implements open3d::t::geometry::Geometry.

◆ operator+()

PointCloud open3d::t::geometry::PointCloud::operator+ ( const PointCloud other) const
inline

operator+ for t::PointCloud appends the compatible attributes to the pointcloud.

◆ ProjectToDepthImage()

geometry::Image open3d::t::geometry::PointCloud::ProjectToDepthImage ( int  width,
int  height,
const core::Tensor intrinsics,
const core::Tensor extrinsics = core::Tensor::Eye(                    4, core::Dtype::Float32core::Device("CPU:0")),
float  depth_scale = 1000.0f,
float  depth_max = 3.0f 
)

Project a point cloud to a depth image.

◆ ProjectToRGBDImage()

geometry::RGBDImage open3d::t::geometry::PointCloud::ProjectToRGBDImage ( int  width,
int  height,
const core::Tensor intrinsics,
const core::Tensor extrinsics = core::Tensor::Eye(                    4, core::Dtype::Float32core::Device("CPU:0")),
float  depth_scale = 1000.0f,
float  depth_max = 3.0f 
)

Project a point cloud to an RGBD image.

◆ RemovePointAttr()

void open3d::t::geometry::PointCloud::RemovePointAttr ( const std::string &  key)
inline

Removes point attribute by key value. Primary attribute "points" cannot be removed. Throws warning if attribute key does not exists.

Parameters
keyAttribute name.

◆ Rotate()

PointCloud & open3d::t::geometry::PointCloud::Rotate ( const core::Tensor R,
const core::Tensor center 
)

Rotates the points and normals (if exists).

Parameters
RRotation [Tensor of dim {3,3}]. Should be on the same device as the PointCloud
centerCenter [Tensor of dim {3}] about which the PointCloud is to be scaled. Should be on the same device as the PointCloud
Returns
Rotated pointcloud

◆ Scale()

PointCloud & open3d::t::geometry::PointCloud::Scale ( double  scale,
const core::Tensor center 
)

Scales the points of the PointCloud.

Parameters
scaleScale [double] of dimension
centerCenter [Tensor of dim {3}] about which the PointCloud is to be scaled. Should be on the same device as the PointCloud
Returns
Scaled pointcloud

◆ SetPointAttr()

void open3d::t::geometry::PointCloud::SetPointAttr ( const std::string &  key,
const core::Tensor value 
)
inline

Set attributes. If the attribute key already exists, its value will be overwritten, otherwise, the new key will be created.

Parameters
keyAttribute name.
valueA tensor.

◆ SetPointColors()

void open3d::t::geometry::PointCloud::SetPointColors ( const core::Tensor value)
inline

Set the value of the "colors" attribute. Convenience function.

◆ SetPointNormals()

void open3d::t::geometry::PointCloud::SetPointNormals ( const core::Tensor value)
inline

Set the value of the "normals" attribute. Convenience function.

◆ SetPoints()

void open3d::t::geometry::PointCloud::SetPoints ( const core::Tensor value)
inline

Set the value of the "points" attribute. Convenience function.

◆ To()

PointCloud open3d::t::geometry::PointCloud::To ( const core::Device device,
bool  copy = false 
) const

Transfer the point cloud to a specified device.

Parameters
deviceThe targeted device to convert to.
copyIf 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.

◆ ToLegacyPointCloud()

open3d::geometry::PointCloud open3d::t::geometry::PointCloud::ToLegacyPointCloud ( ) const

Convert to a legacy Open3D PointCloud.

◆ ToString()

std::string open3d::t::geometry::PointCloud::ToString ( ) const

Text description.

◆ Transform()

PointCloud & open3d::t::geometry::PointCloud::Transform ( const core::Tensor transformation)

Transforms the points and normals (if exist) of the PointCloud. Extracts R, t from Transformation T (4x4) = [[ R(3x3) t(3x1) ], [ O(1x3) s(1x1) ]] (s = 1 for Transformation wihtout scaling) PS. It Assumes s = 1 and O = [0,0,0] and applies the transformation as P = R(P) + t.

Parameters
transformationTransformation [Tensor of dim {4,4}]. Should be on the same device as the PointCloud
Returns
Transformed pointcloud

◆ Translate()

PointCloud & open3d::t::geometry::PointCloud::Translate ( const core::Tensor translation,
bool  relative = true 
)

Translates the points of the PointCloud.

Parameters
translationtranslation tensor of dimension {3} Should be on the same device as the PointCloud
relativeif true (default): translates relative to Center
Returns
Translated pointcloud

◆ VoxelDownSample()

PointCloud open3d::t::geometry::PointCloud::VoxelDownSample ( double  voxel_size,
const core::HashmapBackend backend = core::HashmapBackend::Default 
) const

Downsamples a point cloud with a specified voxel size.

Parameters
voxel_sizeVoxel size. A positive number.

Field Documentation

◆ device_

core::Device open3d::t::geometry::PointCloud::device_ = core::Device("CPU:0")
protected

◆ point_attr_

TensorMap open3d::t::geometry::PointCloud::point_attr_
protected

The documentation for this class was generated from the following files: