# Clustering and search

- FASTCV\_API int fcvClusterEuclideanf32(const float \*\_\_restrict points, int numPoints, int dim, int pointStride, const size\_t \*\_\_restrict indices, int numIndices, int numClusters, float \*\_\_restrict clusterCenters, int clusterCenterStride, float \*\_\_restrict newClusterCenters, size\_t \*\_\_restrict clusterMemberCounts, size\_t \*\_\_restrict clusterBindings, float \*sumOfClusterDistances)

    - General function for computing cluster centers and cluster bindings for a set of points of dimension dim.

Remark

This is general clusterer. There are no assumptions on points other than they belong to a vector space

- Parameters:

    - - **points** – Array of all points. Array size must be greater than numPoints \* dim.
- **numPoints** – Number of points in points array.
- **dim** – dimension, e.g. 36
- **pointStride** – Byte distance between adjacent points in array
- **indices** – Array of point indices in points array. Processing will only occur on points whose indices are in this array. Each index in array must be smaller numPoints.
- **numIndices** – Length of indices array. numIndieces must be &lt;= numPoints.
- **numClusters** – Number of cluster centers
- **clusterCenters** – current cluster centers; elements are distant by clusterCenterStride
- **clusterCenterStride** – byte distance between adjacent cluster centers in array
- **newClusterCenters** – array for new cluster centers; should be numClusterCenters long
- **clusterMemberCounts** – Element counts for each cluster; should be numClusterCenters long
- **clusterBindings** – Output indices of the clusters to which each vector belongs to, array must be numIndices long.
- **sumOfClusterDistances** – Array for sum of distances of cluster elements to cluster centers; Must be numClusters long

- Returns:

    - 0 if successfully clustered, otherwise error code

- FASTCV\_API int fcvClusterEuclideanNormedf32(const float \*\_\_restrict points, int numPoints, int dim, int pointStride, const size\_t \*\_\_restrict indices, int numIndices, int numClusters, float \*\_\_restrict clusterCenters, int clusterCenterStride, float \*\_\_restrict newClusterCenters, size\_t \*\_\_restrict clusterMemberCounts, size\_t \*\_\_restrict clusterBindings, float \*sumOfClusterDistances)

    - Function for computing cluster centers and cluster bindings for a set of normalized points of dimension dim. Cluster centers are also normalized (see remark below)

Remark

this function assumes that points are normalized (e.g. NFT4 descriptors). Cluster centers are also normalized. Normalized points are on a surface of unit sphere which is not a vector space but curved manifold of dimension (dim-1) embeded in Euclidean vector space of dimension dim

- Parameters:

    - - **points** – Array of all points. Array size must be greater than numPoints \* dim.
- **numPoints** – Number of points in points array.
- **dim** – dimension, e.g. 36
- **pointStride** – Byte distance between adjacent points in array
- **indices** – Array of point indices in points array. Processing will only occur on points whose indices are in this array. Each index in array must be smaller numPoints.
- **numIndices** – Length of indices array. numIndieces must be &lt;= numPoints.
- **numClusters** – Number of cluster centers
- **clusterCenters** – current cluster centers; elements are distant by clusterCenterStride
- **clusterCenterStride** – byte distance between adjacent cluster centers in array
- **newClusterCenters** – array for new cluster centers; should be numClusterCenters long
- **clusterMemberCounts** – Element counts for each cluster; should be numClusterCenters long
- **clusterBindings** – Output indices of the clusters to which each vector belongs to, a rray must be numIndices long.
- **sumOfClusterDistances** – Array for sum of distances of cluster elements to cluster centers; Must be numClusters long

- Returns:

    - 0 if successfully clustered, otherwise error code

- FASTCV\_API int fcvClusterEuclideanNormed36f32(const float \*\_\_restrict points, int numPoints, int pointStride, const size\_t \*\_\_restrict indices, int numIndices, int numClusters, float \*\_\_restrict clusterCenters, int clusterCenterStride, float \*\_\_restrict newClusterCenters, size\_t \*\_\_restrict clusterMemberCounts, size\_t \*\_\_restrict clusterBindings, float \*sumOfClusterDistances)

    - Function for computing cluster centers and cluster bindings for a set of normalized points of dimension 36. Cluster centers are also normalized (see remark below)

Remark

this function assumes that points are normalized (e.g. NFT4 descriptors). Cluster centers are also normalized. Normalized points are on a surphace of unit sphere which is not a vector space but curved manifold of dimension (dim-1) embeded in Euclidean vector space of dimension dim

- Parameters:

    - - **points** – Array of all points. Array size must be greater than numPoints \* 36.
- **numPoints** – Number of points in points array.
- **pointStride** – Byte distance between adjacent points in array
- **indices** – Array of point indices in points array. Processing will only occur on points whose indices are in this array. Each index in array must be smaller numPoints.
- **numIndices** – Length of indices array. numIndieces must be &lt;= numPoints.
- **numClusters** – Number of cluster centers
- **clusterCenters** – current cluster centers; elements are distant by clusterCenterStride
- **clusterCenterStride** – byte distance between adjacent cluster centers in array
- **newClusterCenters** – array for new cluster centers; should be numClusterCenters long
- **clusterMemberCounts** – Element counts for each cluster; should be numClusterCenters long
- **clusterBindings** – Output indices of the clusters to which each vector belongs to, a rray must be numIndices long.
- **sumOfClusterDistances** – Array for sum of distances of cluster elements to cluster centers; Must be numClusters long

- Returns:

    - 0 if successfully clustered, otherwise error code

- FASTCV\_API int fcvClusterEuclideanu8(const uint8\_t \*\_\_restrict points, int32\_t numPoints, int32\_t dim, int32\_t pointStride, int32\_t numPointsUsed, int32\_t numClusters, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict clusterCenters, int32\_t clusterCenterStride, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*\_\_restrict newClusterCenters, uint32\_t \*\_\_restrict clusterMemberCounts, uint32\_t \*\_\_restrict clusterBindings, [float32\_t](https://docs.qualcomm.com/doc/80-79511-2/topic/typedef_a00021_1a4611b605e45ab401f02cab15c5e38715.html#_CPPv49float32_t) \*sumOfClusterDistances)

    - General function for computing cluster centers and cluster bindings for a set of points of dimension dim.

Remark

This is general clusterer. There are no assumptions on points other than they belong to a vector space

- Parameters:

    - - **points** – Array of all points. Array size must be greater than numPoints \* pointStride.
- **numPoints** – Number of points in points array.
- **dim** – dimension, e.g. 36
- **pointStride** – Byte distance between adjacent points in array
- **numPointsUsed** – Total number of points used for clustering, {0,1,…(numPointsUsed-1)}
- **numClusters** – Number of clusters
- **clusterCenters** – current cluster centers; elements are distant by clusterCenterStride
- **clusterCenterStride** – byte distance between adjacent cluster centers in array
- **newClusterCenters** – array for new cluster centers; should be numClusterCenters long
- **clusterMemberCounts** – Element counts for each cluster; should be numClusterCenters long
- **clusterBindings** – Output indices of the clusters to which each vector belongs to, array must be numPointsUsed long.
- **sumOfClusterDistances** – the sum of distances between each cluster center to its belonging points. The size should be numClusterCenters\*sizeof(float\_32)

- Returns:

    - 0 if successfully clustered, otherwise error code

Last Published: Aug 30, 2024

[Previous Topic
3D reconstruction](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/3d_reconstruction.md) [Next Topic
Color conversion](https://docs.qualcomm.com/bundle/publicresource/80-79511-2/topics/color_conversion.md)