File indexing completed on 2025-03-09 03:55:01
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam 0004 * 0005 * Date : 2019-06-08 0006 * Description : Implementation of KD-Tree for vector space partitioning 0007 * 0008 * SPDX-FileCopyrightText: 2020 by Nghia Duong <minhnghiaduong997 at gmail dot com> 0009 * 0010 * SPDX-License-Identifier: GPL-2.0-or-later 0011 * 0012 * ============================================================ */ 0013 0014 #ifndef DIGIKAM_KD_TREE_H 0015 #define DIGIKAM_KD_TREE_H 0016 0017 // Local includes 0018 0019 #include "kd_node.h" 0020 0021 namespace Digikam 0022 { 0023 0024 class KDTree 0025 { 0026 0027 public: 0028 0029 explicit KDTree(int dim); 0030 ~KDTree(); 0031 0032 /** 0033 * @return Map of N-nearest neighbors, sorted by distance 0034 */ 0035 QMap<double, QVector<int> > getClosestNeighbors(const cv::Mat& position, 0036 float sqRange, 0037 float cosThreshold, 0038 int maxNbNeighbors) const; 0039 0040 /** 0041 * @brief add new node to KD-Tree 0042 * @param position : K-dimension vector 0043 * @param identity : identity of this face vector 0044 * @return 0045 */ 0046 KDNode* add(const cv::Mat& position, const int identity); 0047 0048 private: 0049 0050 // Disable 0051 KDTree(const KDTree&) = delete; 0052 KDTree& operator=(const KDTree&) = delete; 0053 0054 private: 0055 0056 class Private; 0057 Private* d; 0058 }; 0059 0060 } // namespace Digikam 0061 0062 #endif // DIGIKAM_KD_TREE_H