Direct Graphical Models  v.1.7.0
DirectGraphicalModels::CKDTree Class Reference

Class implementing k-D Tree data structure. More...

#include <KDTree.h>

Public Member Functions

 CKDTree (void)
 Default constructor. More...
 
 CKDTree (Mat &keys, Mat &values)
 Constructor. More...
 
 CKDTree (const CKDTree &)=delete
 
 ~CKDTree (void)
 
bool operator= (const CKDTree)=delete
 
void reset (void)
 Resets the tree. More...
 
void save (const std::string &fileName) const
 Saves the tree into a file. More...
 
void load (const std::string &fileName)
 Loads a tree from the file. More...
 
void build (Mat &keys, Mat &values)
 Builds a k-d tree on keys with corresponding values. More...
 
std::shared_ptr< const CKDNodefindNearestNeighbor (const Mat &key) const
 Finds the nearest neighbor to the key. More...
 
std::vector< std::shared_ptr< const CKDNode > > findNearestNeighbors (const Mat &key, size_t maxNeighbors) const
 Finds up to maxNeighbors nearest neighbors to the key. More...
 
std::shared_ptr< const CKDNodegetRoot (void) const
 Returns pointer to the root of the tree. More...
 

Private Member Functions

std::shared_ptr< CKDNodeloadTree (FILE *pFile, int k)
 
std::shared_ptr< CKDNodebuildTree (Mat &data, pair_mat_t &boundingBox)
 
std::shared_ptr< const CKDNodefindNearestNode (const Mat &key) const
 

Private Attributes

std::shared_ptr< CKDNodem_root
 

Detailed Description

Class implementing k-D Tree data structure.

This class implementats a non-uniform k-D Tree data structure.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 17 of file KDTree.h.

Constructor & Destructor Documentation

◆ CKDTree() [1/3]

DirectGraphicalModels::CKDTree::CKDTree ( void  )
inline

Default constructor.

Definition at line 23 of file KDTree.h.

◆ CKDTree() [2/3]

DirectGraphicalModels::CKDTree::CKDTree ( Mat &  keys,
Mat &  values 
)
inline

Constructor.

Parameters
keysThe tree keys: k-d points: Mat(size: nKeys x k; type: CV_8UC1)
valuesThe values for every key: Mat(size: nKeys x 1; type: CV_8UC1)

Definition at line 29 of file KDTree.h.

Here is the call graph for this function:

◆ CKDTree() [3/3]

DirectGraphicalModels::CKDTree::CKDTree ( const CKDTree )
delete

◆ ~CKDTree()

DirectGraphicalModels::CKDTree::~CKDTree ( void  )
inline

Definition at line 31 of file KDTree.h.

Member Function Documentation

◆ build()

void DirectGraphicalModels::CKDTree::build ( Mat &  keys,
Mat &  values 
)

Builds a k-d tree on keys with corresponding values.

Parameters
keysThe tree keys: k-d points: Mat(size: nKeys x k; type: CV_8UC1)

The keys matrix is modified by this function

valuesThe values for every key: Mat(size: nKeys x 1; type: CV_8UC1)

Definition at line 90 of file KDTree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ buildTree()

std::shared_ptr< CKDNode > DirectGraphicalModels::CKDTree::buildTree ( Mat &  data,
pair_mat_t &  boundingBox 
)
private

Definition at line 179 of file KDTree.cpp.

Here is the caller graph for this function:

◆ findNearestNeighbor()

std::shared_ptr<const CKDNode> DirectGraphicalModels::CKDTree::findNearestNeighbor ( const Mat &  key) const
inline

Finds the nearest neighbor to the key.

Parameters
keyThe search key: k-d point: Mat(size: 1 x k; type: CV_8UC1)
Returns
The Node (tree leaf) with the key, which is the most close to the argument key

Definition at line 61 of file KDTree.h.

Here is the call graph for this function:

◆ findNearestNeighbors()

std::vector< std::shared_ptr< const CKDNode > > DirectGraphicalModels::CKDTree::findNearestNeighbors ( const Mat &  key,
size_t  maxNeighbors 
) const

Finds up to maxNeighbors nearest neighbors to the key.

Parameters
keyThe search key: k-d point: Mat(size: 1 x k; type: CV_8UC1)
maxNeighborsmaximum number of neighbor nodes to find
Returns
The array of Nodes (tree leaves) with the keys, which are the most close to the argument key

Definition at line 117 of file KDTree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findNearestNode()

std::shared_ptr< const CKDNode > DirectGraphicalModels::CKDTree::findNearestNode ( const Mat &  key) const
private

Definition at line 225 of file KDTree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoot()

std::shared_ptr<const CKDNode> DirectGraphicalModels::CKDTree::getRoot ( void  ) const
inline

Returns pointer to the root of the tree.

Returns
The pointer to the root of the tree

Definition at line 73 of file KDTree.h.

◆ load()

void DirectGraphicalModels::CKDTree::load ( const std::string &  fileName)

Loads a tree from the file.

Parameters
fileNameThe output file name

Definition at line 80 of file KDTree.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadTree()

std::shared_ptr< CKDNode > DirectGraphicalModels::CKDTree::loadTree ( FILE *  pFile,
int  k 
)
private

Definition at line 146 of file KDTree.cpp.

Here is the caller graph for this function:

◆ operator=()

bool DirectGraphicalModels::CKDTree::operator= ( const CKDTree  )
delete

◆ reset()

void DirectGraphicalModels::CKDTree::reset ( void  )
inline

Resets the tree.

Definition at line 38 of file KDTree.h.

Here is the caller graph for this function:

◆ save()

void DirectGraphicalModels::CKDTree::save ( const std::string &  fileName) const

Saves the tree into a file.

Parameters
fileNameThe output file name

Definition at line 65 of file KDTree.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ m_root

std::shared_ptr<CKDNode> DirectGraphicalModels::CKDTree::m_root
private

Definition at line 83 of file KDTree.h.


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