digiKam Developer Documentation
Professional Photo Management with the Power of Open Source
Loading...
Searching...
No Matches
Digikam::KDTreeBase Class Referenceabstract
+ Inheritance diagram for Digikam::KDTreeBase:

Public Member Functions

 KDTreeBase (int dim, int kdtreeThreshold=KDTREE_MAP_THRESHOLD)
 Constructor of the class implementing the KD-Tree for vector space partitioning.
 
virtual KDNodeBaseadd (const cv::Mat &position, const int identity)
 add new node to KD-Tree
 
virtual KDNodeBasecreateNode (const cv::Mat &nodePos, const int identity, int splitAxis, int dimension)=0
 create an ew node
 
virtual QMap< double, QVector< int > > getClosestNeighbors (const cv::Mat &position, float sqRange, int maxNbNeighbors) const
 

Constructor & Destructor Documentation

◆ KDTreeBase()

Digikam::KDTreeBase::KDTreeBase ( int  dim,
int  kdtreeThreshold = KDTREE_MAP_THRESHOLD 
)
explicit
Parameters
dimThe dimmension of the tree.
kdtreeThresholdThe KD-Tree threshold. Above this value, we start using the KD-Tree instead of the vector. If the vector grows to default KDTREE_MAP_THRESHOLD items, start using the KDTree.
Note
Due to sparse data density in the tree, we initially use a vector of nodes to compare the target to the samples once we have achieved a suitabe data density we delete the vector (but not the nodes) and begin using the tree.

Using this to compare brute force vs kdtree performance due to sparse data in k-dimensions (128 dimensions for face features).

Member Function Documentation

◆ add()

KDNodeBase * Digikam::KDTreeBase::add ( const cv::Mat &  position,
const int  identity 
)
virtual
Parameters
positionK-dimension vector
identityidentity of this face vector
Returns
the KD-Tree node base instance

◆ createNode()

virtual KDNodeBase * Digikam::KDTreeBase::createNode ( const cv::Mat &  nodePos,
const int  identity,
int  splitAxis,
int  dimension 
)
pure virtual
Parameters
nodePosextracted face vectors
identityidentity of this face vector
splitAxiscurrent axis/dimension of the vector
dimensionnumber of dimensions (usually 128)
Returns
the KD-Tree node base instance

◆ getClosestNeighbors()

QMap< double, QVector< int > > Digikam::KDTreeBase::getClosestNeighbors ( const cv::Mat &  position,
float  sqRange,
int  maxNbNeighbors 
) const
virtual
Returns
Map of N-nearest neighbors, sorted by distance