![]() |
Perception Tool Kit (PTK) API Guide
|
A PTK_PointCloud is used store a collection of 3D points. It is independent of source of the points and does not store sensor-specific metadata. It does, however, provide access to the tag metadata field on each point which allows for up to 32 application- or algorithm-specific tags to be created. Points within a point cloud are identified uniquely by integers, which are used for reading points and their tags. The identifying integers are assigned sequentially as points are added to a point cloud.
![]() |
Data Structures | |
struct | PTK_PointCloudConfig |
Definition of vector meta data. More... | |
Functions | |
uint32_t | PTK_PointCloud_getSize (const PTK_PointCloudConfig *cfg) |
Compute how much memory is required to store a complete PTK_PointCloud struct matching the given configuration. More... | |
PTK_PointCloud * | PTK_PointCloud_init (uint8_t *memPtr, const PTK_PointCloudConfig *cfg) |
Initialize an externally allocated piece of memory to be a valid PTK_PointCloud. More... | |
void | PTK_PointCloud_clear (PTK_PointCloud *pc) |
Clear a PTK_PointCloud by setting used point count to zero.. More... | |
uint32_t | PTK_PointCloud_hasSpace (const PTK_PointCloud *pc, uint32_t points) |
Check if the given point cloud has enough space to accomodate the addition of points additional PTK_Points. More... | |
uint32_t | PTK_PointCloud_add (PTK_PointCloud *pc, const PTK_Point *xyzw) |
Add a copy of the given point to the point cloud, if there is room. More... | |
uint32_t | PTK_PointCloud_addv (PTK_PointCloud *pc, const PTK_Point *xyzw, uint32_t numPoints) |
Add a copy of each of the points in the array pv to the given point cloud, if there is enough space. If not, no points are copied. The IDs of the copied points are sequential after the first one, so only the first ID is returned. More... | |
uint32_t | PTK_PointCloud_getPointCount (const PTK_PointCloud *pc) |
This returns the total number of points that have been added since PTK_PointCloud_clear() was last called. More... | |
uint32_t | PTK_PointCloud_getPoint (const PTK_PointCloud *pc, uint32_t id, PTK_Point *dst) |
This copies a PTK_Point out of the point cloud into another (user-supplied) memory location. More... | |
static PTK_Point * | PTK_PointCloud_refPoint (PTK_PointCloud *pc, uint32_t id) |
This gets a direct pointer to a specific PTK_Point within the point cloud. More... | |
const PTK_Point * | PTK_PointCloud_crefPoint (const PTK_PointCloud *pc, uint32_t id) |
This gets an immutable pointer to a specific PTK_Point within the point cloud. More... | |
void | PTK_PointCloud_tag (PTK_PointCloud *pc, uint32_t id, uint32_t tag) |
This sets tag bits for the point with the given identifier. More... | |
void | PTK_PointCloud_untag (PTK_PointCloud *pc, uint32_t id, uint32_t tag) |
This removes tag bits for the point at the given identifier. More... | |
uint32_t | PTK_PointCloud_isTagged (const PTK_PointCloud *pc, uint32_t id, uint32_t tag) |
This checks if all of the bits set in tag are also set in the tag for the specified PTK_Point. Note that the point in question may have additional tag bits set, but it may not be missing any. More... | |
uint32_t | PTK_PointCloud_readTag (const PTK_PointCloud *pc, uint32_t id) |
This reads the tag for a given point identifier in the given point cloud. More... | |
static void | PTK_PointCloud_copyMetaData (PTK_PointCloud *dst, const PTK_PointCloud *src) |
Copy metadata from src to dst. More... | |
uint32_t | PTK_PointCloud_copy (PTK_PointCloud *dst, const PTK_PointCloud *src) |
Copy points from src to dst, appending points so long as space remains in the dst cloud. More... | |
void | PTK_PointCloud_transform (PTK_PointCloud *dst, PTK_PointCloud *src, const PTK_RigidTransform *M) |
Each point in src is transformed by M and then written to the same location in dst. The tag bits are also propagated to dst, and the total number of points present in dst is updated accordingly. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first or to have src= dst. The return value indicates the number of successfully transformed and copied points, which may be important if transforming and appending onto a non-empty cloud for detecting space limitations. More... | |
void | PTK_PointCloud_scale (PTK_PointCloud *dst, PTK_PointCloud *src, float scale) |
Each point in src is scaled by scale and then written with the same id in dst. The tag bits are also propagated to dst. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first, or to have src = dst. The return value indicates how many points were scaled and appended to dst, which may be important if appending to a non-empty point cloud for detectin space limitations. More... | |
void | PTK_PointCloud_getMinMax (const PTK_PointCloud *pc, const PTK_Point *basis, float *minVal, float *maxVal, uint32_t *minId, uint32_t *maxId) |
Find PTK_Points with the minimum and maximum PTK Vector dot4 value computed with the given basis. If you are using tag bits rather than a fourth coordinate, be sure to set basis.meta.w to 0. More... | |
uint32_t | PTK_PointCloud_ransacPlane (const PTK_PointCloud *pc, const uint32_t *__restrict ids, uint32_t N, float tol, uint32_t iters, float *nd, uint32_t *__restrict foundInliers) |
uint32_t PTK_PointCloud_getSize | ( | const PTK_PointCloudConfig * | cfg | ) |
Compute how much memory is required to store a complete PTK_PointCloud struct matching the given configuration.
[in] | cfg | Configuration structure defining the point cloud. |
PTK_PointCloud* PTK_PointCloud_init | ( | uint8_t * | memPtr, |
const PTK_PointCloudConfig * | cfg | ||
) |
Initialize an externally allocated piece of memory to be a valid PTK_PointCloud.
[out] | memPtr | Externally allocated memory of at least PTK_PointCloud_getSize() bytes. |
[in] | cfg | Configuration structure to initialize from. |
void PTK_PointCloud_clear | ( | PTK_PointCloud * | pc | ) |
Clear a PTK_PointCloud by setting used point count to zero..
[out] | pc | Point cloud to modify. |
uint32_t PTK_PointCloud_hasSpace | ( | const PTK_PointCloud * | pc, |
uint32_t | points | ||
) |
Check if the given point cloud has enough space to accomodate the addition of points additional PTK_Points.
[out] | pc | The point cloud to check. |
[in] | points | The number of points to check for. |
uint32_t PTK_PointCloud_add | ( | PTK_PointCloud * | pc, |
const PTK_Point * | xyzw | ||
) |
Add a copy of the given point to the point cloud, if there is room.
[in] | pc | Add to this point cloud. |
[in] | xyzw | Point to add. |
uint32_t PTK_PointCloud_addv | ( | PTK_PointCloud * | pc, |
const PTK_Point * | xyzw, | ||
uint32_t | numPoints | ||
) |
Add a copy of each of the points in the array pv to the given point cloud, if there is enough space. If not, no points are copied. The IDs of the copied points are sequential after the first one, so only the first ID is returned.
[out] | pc | Add points to this point cloud. |
[in] | xyzw | Pointer to several points in a contiguous block of memory. |
[in] | numPoints | The number of points to add. |
uint32_t PTK_PointCloud_getPointCount | ( | const PTK_PointCloud * | pc | ) |
This returns the total number of points that have been added since PTK_PointCloud_clear() was last called.
[in] | pc | Read from this point cloud. |
uint32_t PTK_PointCloud_getPoint | ( | const PTK_PointCloud * | pc, |
uint32_t | id, | ||
PTK_Point * | dst | ||
) |
This copies a PTK_Point out of the point cloud into another (user-supplied) memory location.
[out] | pc | Read from this point cloud. |
[in] | id | Read point with the given identifier. |
[out] | dst | Copy the point here. |
|
inlinestatic |
This gets a direct pointer to a specific PTK_Point within the point cloud.
[in] | pc | Get point from this cloud. |
[in] | id | Read point with the given identifier. |
const PTK_Point* PTK_PointCloud_crefPoint | ( | const PTK_PointCloud * | pc, |
uint32_t | id | ||
) |
This gets an immutable pointer to a specific PTK_Point within the point cloud.
[in] | pc | Get point from this cloud. |
[in] | id | Read point with the given identifier. |
void PTK_PointCloud_tag | ( | PTK_PointCloud * | pc, |
uint32_t | id, | ||
uint32_t | tag | ||
) |
This sets tag bits for the point with the given identifier.
[in,out] | pc | Modify a point in this cloud. |
[in] | id | Tag the point with this identifier. |
[in] | tag | Apply these tag bits. |
void PTK_PointCloud_untag | ( | PTK_PointCloud * | pc, |
uint32_t | id, | ||
uint32_t | tag | ||
) |
This removes tag bits for the point at the given identifier.
[in] | pc | Modify a point in this cloud. |
[in] | id | Untag the point with this identifier. |
[in] | tag | Remove these tag bits |
uint32_t PTK_PointCloud_isTagged | ( | const PTK_PointCloud * | pc, |
uint32_t | id, | ||
uint32_t | tag | ||
) |
This checks if all of the bits set in tag are also set in the tag for the specified PTK_Point. Note that the point in question may have additional tag bits set, but it may not be missing any.
[out] | pc | Check tag bits for a point in this cloud. |
[in] | id | Check the point with this identifier. |
[in] | tag | Check for these tag bits. |
uint32_t PTK_PointCloud_readTag | ( | const PTK_PointCloud * | pc, |
uint32_t | id | ||
) |
This reads the tag for a given point identifier in the given point cloud.
[in] | pc | Read tag bits for a point in this cloud. |
[in] | id | Read tag bits for a point with this identifier. |
|
inlinestatic |
Copy metadata from src to dst.
[out] | dst | Copy metadata to this cloud. |
[in] | src | Copy metadata from this cloud. |
uint32_t PTK_PointCloud_copy | ( | PTK_PointCloud * | dst, |
const PTK_PointCloud * | src | ||
) |
Copy points from src to dst, appending points so long as space remains in the dst cloud.
[out] | dst | Copy points to this cloud. |
[in] | src | Copy points from this cloud. |
void PTK_PointCloud_transform | ( | PTK_PointCloud * | dst, |
PTK_PointCloud * | src, | ||
const PTK_RigidTransform * | M | ||
) |
Each point in src is transformed by M and then written to the same location in dst. The tag bits are also propagated to dst, and the total number of points present in dst is updated accordingly. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first or to have src= dst. The return value indicates the number of successfully transformed and copied points, which may be important if transforming and appending onto a non-empty cloud for detecting space limitations.
[out] | dst | Transformed points to be written here. |
[out] | src | Source cloud to be transformed. |
[in] | M | Rigid transformation to apply. |
void PTK_PointCloud_scale | ( | PTK_PointCloud * | dst, |
PTK_PointCloud * | src, | ||
float | scale | ||
) |
Each point in src is scaled by scale and then written with the same id in dst. The tag bits are also propagated to dst. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first, or to have src = dst. The return value indicates how many points were scaled and appended to dst, which may be important if appending to a non-empty point cloud for detectin space limitations.
[out] | dst | Scaled points written here. |
[out] | src | Cloud to be scaled. |
[in] | scale | Scale factor. |
void PTK_PointCloud_getMinMax | ( | const PTK_PointCloud * | pc, |
const PTK_Point * | basis, | ||
float * | minVal, | ||
float * | maxVal, | ||
uint32_t * | minId, | ||
uint32_t * | maxId | ||
) |
Find PTK_Points with the minimum and maximum PTK Vector dot4 value computed with the given basis. If you are using tag bits rather than a fourth coordinate, be sure to set basis.meta.w to 0.
[in] | pc | Cloud to operate on. |
[in] | basis | Basis vector for inner product metric. |
[out] | minVal | Minimum value written here. |
[out] | maxVal | Maximum value written here. |
[out] | minId | Minimum id written here. |
[out] | maxId | Maximum id written here. |
uint32_t PTK_PointCloud_ransacPlane | ( | const PTK_PointCloud * | pc, |
const uint32_t *__restrict | ids, | ||
uint32_t | N, | ||
float | tol, | ||
uint32_t | iters, | ||
float * | nd, | ||
uint32_t *__restrict | foundInliers | ||
) |
[in] | pc | |
[in] | ids | |
[in] | N | |
[in] | tol | |
[in] | iters | |
[out] | nd | |
[out] | foundInliers |