Skip to content

Commit f3d4660

Browse files
committed
Added documentation for nearest neighbour
1 parent 9f46f19 commit f3d4660

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

docs/details/vision.dox

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ equal to the number of features contained in the query array.
4848

4949
=======================================================================
5050

51+
\defgroup cv_func_nearest_neighbour nearestNeighbour
52+
\ingroup featmatcher_mat
53+
54+
\brief Nearest Neighbour
55+
56+
Calculates nearest distances between two 2-dimensional arrays containing
57+
features based on the type of distance computation chosen. Currently, \ref
58+
AF_SAD (sum of absolute differences), \ref AF_SSD (sum of squared differences)
59+
and \ref AF_SHD (hamming distance) are supported.
60+
One of the arrays containing the training data and the other the
61+
query data. One of the dimensions of the both arrays must be equal among them,
62+
identifying the length of each feature. The other dimension indicates the
63+
total number of features in each of the training and query arrays. Two
64+
1-dimensional arrays are created as results, one containg the smallest N
65+
distances of the query array and another containing the indices of these
66+
distances in the training array. The resulting 1-dimensional arrays have length
67+
equal to the number of features contained in the query array.
68+
69+
=======================================================================
70+
5171
\defgroup cv_func_match_template matchTemplate
5272
\ingroup match_mat
5373

include/af/vision.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,39 @@ AFAPI void orb(features& feat, array& desc, const array& image, const float fast
8484
\param[in] n_dist is the number of smallest distances to return (currently, only 1
8585
is supported)
8686
87+
\note Note: This is a special case of the \ref nearestNeighbour function with AF_SHD
88+
as dist_type
89+
8790
\ingroup cv_func_hamming_matcher
8891
*/
8992
AFAPI void hammingMatcher(array& idx, array& dist,
9093
const array& query, const array& train,
9194
const dim_t dist_dim=0, const unsigned n_dist=1);
9295

96+
/**
97+
C++ Interface wrapper for Nearest Neighbour
98+
99+
\param[out] idx is an array of MxN size, where M is equal to the number of query
100+
features and N is equal to n_dist. The value at position IxJ indicates
101+
the index of the Jth smallest distance to the Ith query value in the
102+
train data array.
103+
the index of the Ith smallest distance of the Mth query.
104+
\param[out] dist is an array of MxN size, where M is equal to the number of query
105+
features and N is equal to n_dist. The value at position IxJ indicates
106+
the distance of the Jth smallest distance to the Ith query value in the
107+
train data array based on the dist_type chosen.
108+
\param[in] query is the array containing the data to be queried
109+
\param[in] train is the array containing the data used as training data
110+
\param[in] dist_dim indicates the dimension to analyze for distance (the dimension
111+
indicated here must be of equal length for both query and train arrays)
112+
\param[in] n_dist is the number of smallest distances to return (currently, only 1
113+
is supported)
114+
\param[in] dist_type is the distance computation type. Currently \ref AF_SAD (sum
115+
of absolute differences), \ref AF_SSD (sum of squared differences), and
116+
\ref AF_SHD (hamming distances) are supported.
117+
118+
\ingroup cv_func_nearest_neighbour
119+
*/
93120
AFAPI void nearestNeighbour(array& idx, array& dist,
94121
const array& query, const array& train,
95122
const dim_t dist_dim=0, const unsigned n_dist=1,
@@ -195,6 +222,30 @@ extern "C" {
195222
const af_array query, const af_array train,
196223
const dim_t dist_dim, const unsigned n_dist);
197224

225+
/**
226+
C Interface wrapper for Nearest Neighbour
227+
228+
\param[out] idx is an array of MxN size, where M is equal to the number of query
229+
features and N is equal to n_dist. The value at position IxJ indicates
230+
the index of the Jth smallest distance to the Ith query value in the
231+
train data array.
232+
the index of the Ith smallest distance of the Mth query.
233+
\param[out] dist is an array of MxN size, where M is equal to the number of query
234+
features and N is equal to n_dist. The value at position IxJ indicates
235+
the distance of the Jth smallest distance to the Ith query value in the
236+
train data array based on the dist_type chosen.
237+
\param[in] query is the array containing the data to be queried
238+
\param[in] train is the array containing the data used as training data
239+
\param[in] dist_dim indicates the dimension to analyze for distance (the dimension
240+
indicated here must be of equal length for both query and train arrays)
241+
\param[in] n_dist is the number of smallest distances to return (currently, only 1
242+
is supported)
243+
\param[in] dist_type is the distance computation type. Currently \ref AF_SAD (sum
244+
of absolute differences), \ref AF_SSD (sum of squared differences), and
245+
\ref AF_SHD (hamming distances) are supported.
246+
247+
\ingroup cv_func_nearest_neighbour
248+
*/
198249
AFAPI af_err af_nearest_neighbour(af_array* idx, af_array* dist,
199250
const af_array query, const af_array train,
200251
const dim_t dist_dim, const unsigned n_dist,

0 commit comments

Comments
 (0)