digiKam
kd_node.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam
4  *
5  * Date : 2019-06-08
6  * Description : Node of KD-Tree for vector space partitioning
7  *
8  * Copyright (C) 2020 by Nghia Duong <minhnghiaduong997 at gmail dot com>
9  *
10  * This program is free software; you can redistribute it
11  * and/or modify it under the terms of the GNU General
12  * Public License as published by the Free Software Foundation;
13  * either version 2, or (at your option)
14  * any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #ifndef DIGIKAM_KD_NODE_H
24 #define DIGIKAM_KD_NODE_H
25 
26 // C++ includes
27 
28 #include <vector>
29 
30 // Qt includes
31 
32 #include <QVector>
33 #include <QMap>
34 
35 // Local include
36 
37 #include "digikam_opencv.h"
38 
39 namespace Digikam
40 {
41 
42 class KDNode
43 {
44 public:
45 
46  explicit KDNode(const cv::Mat& nodePos,
47  const int identity,
48  int splitAxis,
49  int dimension);
50  ~KDNode();
51 
52 public:
53 
54  static float sqrDistance(const float* const pos1, const float* const pos2, int dimension);
55  static float cosDistance(const float* const pos1, const float* const pos2, int dimension);
56 
57 public:
58 
62  KDNode* insert(const cv::Mat& nodePos, const int identity);
63 
67  cv::Mat getPosition() const;
68 
72  double getClosestNeighbors(QMap<double, QVector<int> >& neighborList,
73  const cv::Mat& position,
74  float sqRange,
75  float cosThreshold,
76  int maxNbNeighbors) const;
80  int getIdentity();
81 
85  void setNodeId(int id);
86 
87 private:
88 
89  void updateRange(const cv::Mat&);
90 
91  KDNode* findParent(const cv::Mat& nodePos);
92 
93 private:
94 
95  // Disable
96  KDNode(const KDNode&) = delete;
97  KDNode& operator=(const KDNode&) = delete;
98 
99 private:
100 
101  class Private;
102  Private* d;
103 };
104 
105 } // namespace Digikam
106 
107 #endif // DIGIKAM_KD_NODE_H
Definition: kd_node.h:43
cv::Mat getPosition() const
Definition: kd_node.cpp:160
static float sqrDistance(const float *const pos1, const float *const pos2, int dimension)
Definition: kd_node.cpp:43
static float cosDistance(const float *const pos1, const float *const pos2, int dimension)
Definition: kd_node.cpp:55
double getClosestNeighbors(QMap< double, QVector< int > > &neighborList, const cv::Mat &position, float sqRange, float cosThreshold, int maxNbNeighbors) const
Definition: kd_node.cpp:175
~KDNode()
Definition: kd_node.cpp:124
void setNodeId(int id)
Definition: kd_node.cpp:170
int getIdentity()
Definition: kd_node.cpp:165
KDNode * insert(const cv::Mat &nodePos, const int identity)
Definition: kd_node.cpp:129
KDNode(const cv::Mat &nodePos, const int identity, int splitAxis, int dimension)
Definition: kd_node.cpp:112
Definition: datefolderview.cpp:43
Definition: scan.h:26