![]() |
Zivid C++ API 2.16.0+46cdaba6-1
|
Point cloud with x, y, z, RGB color and SNR laid out as a linear list of only valid points. More...
#include <Zivid/UnorganizedPointCloud.h>
Public Member Functions | |
ZIVID_CORE_EXPORT | UnorganizedPointCloud () |
Create an empty point cloud. | |
ZIVID_CORE_EXPORT size_t | size () const |
Get the size of the point cloud (total number of points) | |
ZIVID_CORE_EXPORT UnorganizedPointCloud | extended (const UnorganizedPointCloud &other) const |
Create a new point cloud containing the combined data of this point cloud and another. | |
ZIVID_CORE_EXPORT UnorganizedPointCloud & | extend (const UnorganizedPointCloud &other) |
Extend this point cloud in-place by adding the points from another point cloud. | |
ZIVID_CORE_EXPORT UnorganizedPointCloud | voxelDownsampled (float voxelSize, int minPointsPerVoxel) const |
Create a new point cloud that is a voxel downsampling of this point cloud. | |
ZIVID_CORE_EXPORT UnorganizedPointCloud & | transform (const Zivid::Matrix4x4 &matrix) |
Transform the point cloud in-place by the given 4x4 transformation matrix. | |
ZIVID_CORE_EXPORT UnorganizedPointCloud | transformed (const Zivid::Matrix4x4 &matrix) const |
Transform the point cloud by the given 4x4 transformation matrix. | |
ZIVID_CORE_EXPORT UnorganizedPointCloud & | center () |
Translate the point cloud in-place so that its centroid lands at the origin (0,0,0) | |
ZIVID_CORE_EXPORT std::optional< PointXYZ > | centroid () const |
Get the centroid of the point cloud, i.e. average of all XYZ point positions. | |
ZIVID_CORE_EXPORT Array1D< PointXYZ > | copyPointsXYZ () const |
Get the XYZ data of every point. | |
ZIVID_CORE_EXPORT Array1D< ColorRGBA > | copyColorsRGBA () const |
Get the color data of every point on 8-bit RGBA format. | |
ZIVID_CORE_EXPORT Array1D< ColorBGRA > | copyColorsBGRA () const |
Get the color data of every point on 8-bit BGRA format. | |
ZIVID_CORE_EXPORT Array1D< ColorRGBA_SRGB > | copyColorsRGBA_SRGB () const |
Get the color data of every point on 8-bit RGBA format in the sRGB color space. | |
ZIVID_CORE_EXPORT Array1D< ColorBGRA_SRGB > | copyColorsBGRA_SRGB () const |
Get the color data of every point on 8-bit BGRA format in the sRGB color space. | |
ZIVID_CORE_EXPORT Array1D< SNR > | copySNRs () const |
Get the SNR data of every point. | |
template<typename DataFormat > | |
Array1D< DataFormat > | copyData () const |
Array1D with point cloud data using specified DataFormat. | |
template<typename DataFormat > | |
void | copyData (DataFormat *destination) const |
Copy data in the specified DataFormat to a destination buffer. | |
ZIVID_CORE_EXPORT UnorganizedPointCloud | clone () const |
Returns a clone of the point cloud. The clone will include a copy of all of the point cloud data on the compute device memory. This means that the returned point cloud will not be affected by subsequent modifications (such as transform) on the original point cloud. | |
ZIVID_CORE_EXPORT std::string | toString () const |
Get string representation of the point cloud. | |
Point cloud with x, y, z, RGB color and SNR laid out as a linear list of only valid points.
An instance of this class is a handle to a point cloud stored on the compute device memory. This class provides several methods to copy point cloud data from the compute device memory to host (CPU) system memory (RAM).
This point cloud contains only valid points, meaning that the XYZ values are never NaN.
ZIVID_CORE_EXPORT Zivid::UnorganizedPointCloud::UnorganizedPointCloud | ( | ) |
Create an empty point cloud.
This constructor creates a point cloud with size zero, i.e. no points. An empty point cloud can be useful for combining points from several other points clouds.
ZIVID_CORE_EXPORT UnorganizedPointCloud & Zivid::UnorganizedPointCloud::center | ( | ) |
Translate the point cloud in-place so that its centroid lands at the origin (0,0,0)
If the point cloud has zero points, this method throws an exception.
ZIVID_CORE_EXPORT std::optional< PointXYZ > Zivid::UnorganizedPointCloud::centroid | ( | ) | const |
Get the centroid of the point cloud, i.e. average of all XYZ point positions.
If the point cloud has zero points, this method returns an empty std::optional.
ZIVID_CORE_EXPORT UnorganizedPointCloud Zivid::UnorganizedPointCloud::clone | ( | ) | const |
Returns a clone of the point cloud. The clone will include a copy of all of the point cloud data on the compute device memory. This means that the returned point cloud will not be affected by subsequent modifications (such as transform) on the original point cloud.
This function incurs a performance cost due to the copying of the compute device memory. When performance is important we recommend to avoid using this method, and instead modify the existing point cloud.
ZIVID_CORE_EXPORT Array1D< ColorBGRA > Zivid::UnorganizedPointCloud::copyColorsBGRA | ( | ) | const |
Get the color data of every point on 8-bit BGRA format.
This method copies the BGRA values from compute device memory to host (CPU) system memory (RAM) and returns them as an Array1D of ColorBGRA.
The length of the returned array will match the size method.
If you already have a buffer, you can copy data directly from compute device memory to your destination buffer using copyData with template parameter ColorBGRA.
ZIVID_CORE_EXPORT Array1D< ColorBGRA_SRGB > Zivid::UnorganizedPointCloud::copyColorsBGRA_SRGB | ( | ) | const |
Get the color data of every point on 8-bit BGRA format in the sRGB color space.
This method copies the sRGB values from compute device memory to host (CPU) system memory (RAM) and returns them as an Array1D of ColorBGRA_SRGB.
The sRGB color space is suitable for showing an image on a display for human viewing. It is easier to see details in darker areas of an image in sRGB than in linear RGB, as more of the dynamic range is dedicated to darker colors. This color space is assumed by default by most monitors and should be used when displaying an image.
ZIVID_CORE_EXPORT Array1D< ColorRGBA > Zivid::UnorganizedPointCloud::copyColorsRGBA | ( | ) | const |
Get the color data of every point on 8-bit RGBA format.
This method copies the RGBA values from compute device memory to host (CPU) system memory (RAM) and returns them as an Array1D of ColorRGBA.
The length of the returned array will match the size method.
If you already have a buffer, you can copy data directly from compute device memory to your destination buffer using copyData with template parameter ColorRGBA.
ZIVID_CORE_EXPORT Array1D< ColorRGBA_SRGB > Zivid::UnorganizedPointCloud::copyColorsRGBA_SRGB | ( | ) | const |
Get the color data of every point on 8-bit RGBA format in the sRGB color space.
This method copies the sRGB values from compute device memory to host (CPU) system memory (RAM) and returns them as an Array1D of ColorRGBA_SRGB.
The sRGB color space is suitable for showing an image on a display for human viewing. It is easier to see details in darker areas of an image in sRGB than in linear RGB, as more of the dynamic range is dedicated to darker colors. This color space is assumed by default by most monitors and should be used when displaying an image.
|
inline |
Array1D with point cloud data using specified DataFormat.
The template parameter DataFormat specifies which point cloud data fields are included in the array. This is a convenience function that can be used for generic template programming. Calling this method with template parameter PointXYZ, for example, is equivalent to calling the copyPointsXYZ member function.
If you already have a buffer, you can copy data directly from compute device memory to your destination buffer using copyData(DataFormat *destination)
. For more information about the available DataFormat types, see copyData(DataFormat *destination)
.
|
inline |
Copy data in the specified DataFormat to a destination buffer.
Transfers point cloud data from the compute device to a provided output buffer on the host (CPU) system memory (RAM). The template parameter DataFormat defines the layout of the data and which data fields are included.
This method is the most efficient way to copy point cloud data from the compute device if you need to store it to your own buffer. The destination buffer must be large enough to hold UnorganizedPointCloud::size() * sizeof(DataFormat)
bytes of data. Providing a buffer which is too small results in undefined behavior.
Available data formats:
x
, y
, z
) packed together. Size per element is 12 bytes. r
, g
, b
and a
. a
is always 255. Size per element 4 bytes. b
, g
, r
and a
. a
is always 255. Size per element 4 bytes. r
, g
, b
and a
. a
is always 255. Size per element 4 bytes. b
, g
, r
and a
. a
is always 255. Size per element 4 bytes. value
. Size per element is 4 bytes. ZIVID_CORE_EXPORT Array1D< PointXYZ > Zivid::UnorganizedPointCloud::copyPointsXYZ | ( | ) | const |
Get the XYZ data of every point.
This method copies the 3D point coordinates from compute device memory to host (CPU) system memory (RAM) and returns them as an Array1D of PointXYZ.
The length of the returned array will match the size method.
If you already have a buffer, you can copy data directly from compute device memory to your destination buffer using copyData with template parameter PointXYZ.
ZIVID_CORE_EXPORT Array1D< SNR > Zivid::UnorganizedPointCloud::copySNRs | ( | ) | const |
Get the SNR data of every point.
This method copies the signal-to-noise ratios from compute device memory to host (CPU) system memory (RAM) and returns them as an Array1D of SNR.
The length of the returned array will match the size method.
If you already have a buffer, you can copy data directly from compute device memory to your destination buffer using copyData with template parameter SNR.
ZIVID_CORE_EXPORT UnorganizedPointCloud & Zivid::UnorganizedPointCloud::extend | ( | const UnorganizedPointCloud & | other | ) |
Extend this point cloud in-place by adding the points from another point cloud.
other | The other point cloud to copy data from |
ZIVID_CORE_EXPORT UnorganizedPointCloud Zivid::UnorganizedPointCloud::extended | ( | const UnorganizedPointCloud & | other | ) | const |
Create a new point cloud containing the combined data of this point cloud and another.
other | The other point cloud to copy data from |
ZIVID_CORE_EXPORT size_t Zivid::UnorganizedPointCloud::size | ( | ) | const |
Get the size of the point cloud (total number of points)
ZIVID_CORE_EXPORT std::string Zivid::UnorganizedPointCloud::toString | ( | ) | const |
Get string representation of the point cloud.
ZIVID_CORE_EXPORT UnorganizedPointCloud & Zivid::UnorganizedPointCloud::transform | ( | const Zivid::Matrix4x4 & | matrix | ) |
Transform the point cloud in-place by the given 4x4 transformation matrix.
The transform matrix must be affine. In other words, the last row of the matrix must be [0, 0, 0, 1]
.
matrix | An affine 4x4 matrix |
ZIVID_CORE_EXPORT UnorganizedPointCloud Zivid::UnorganizedPointCloud::transformed | ( | const Zivid::Matrix4x4 & | matrix | ) | const |
Transform the point cloud by the given 4x4 transformation matrix.
This method is identical to transform, except the transformed point cloud is returned as a new UnorganizedPointCloud instance. The current point cloud is not modified.
matrix | An affine 4x4 matrix |
ZIVID_CORE_EXPORT UnorganizedPointCloud Zivid::UnorganizedPointCloud::voxelDownsampled | ( | float | voxelSize, |
int | minPointsPerVoxel ) const |
Create a new point cloud that is a voxel downsampling of this point cloud.
Voxel downsampling subdivides 3D space into a grid of cubic voxels with a given size. If a given voxel contains a number of points at or above the given limit, all those source points are replaced with a single point with the following properties:
Using minPointsPerVoxel > 1
is particularly useful for removing noise and artifacts from unorganized point clouds that are a combination of structured point clouds captured from different angles. This is because a given artifact is most likely only present in one of the captures, and minPointsPerVoxel
can be used to only fill voxels that both captures "agree" on.
voxelSize | The size of the voxel cubes (must be greater than 0.0) |
minPointsPerVoxel | The minimum number of points required to fill a voxel (must be 1 or greater) |