31 #ifndef OPENCV_FLANN_GROUND_TRUTH_H_
32 #define OPENCV_FLANN_GROUND_TRUTH_H_
41 template <
typename Distance>
43 int skip = 0, Distance distance = Distance())
45 typedef typename Distance::ResultType DistanceType;
48 std::vector<int> match(n);
49 std::vector<DistanceType> dists(n);
51 dists[0] = distance(dataset[0], query, dataset.
cols);
55 for (
size_t i=1; i<dataset.
rows; ++i) {
56 DistanceType tmp = distance(dataset[i], query, dataset.
cols);
62 else if (tmp < dists[dcnt-1]) {
64 match[dcnt-1] = (
int)i;
69 while (j>=1 && dists[j]<dists[j-1]) {
76 for (
int i=0; i<nn; ++i) {
77 matches[i] = match[i+skip];
82 template <
typename Distance>
84 int skip=0, Distance
d = Distance())
86 for (
size_t i=0; i<testset.
rows; ++i) {
87 find_nearest<Distance>(dataset, testset[i], matches[i], (
int)matches.
cols, skip,
d);
94 #endif //OPENCV_FLANN_GROUND_TRUTH_H_
void compute_ground_truth(const Matrix< typename Distance::ElementType > &dataset, const Matrix< typename Distance::ElementType > &testset, Matrix< int > &matches, int skip=0, Distance d=Distance())
Definition: ground_truth.h:83
void find_nearest(const Matrix< typename Distance::ElementType > &dataset, typename Distance::ElementType *query, int *matches, int nn, int skip=0, Distance distance=Distance())
Definition: ground_truth.h:42
size_t cols
Definition: matrix.h:52
int d
Definition: legacy.hpp:3064
size_t rows
Definition: matrix.h:51
::max::max int
Definition: functional.hpp:324
CV_EXPORTS void swap(Mat &a, Mat &b)
swaps two matrices