dist.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5  * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6  *
7  * THE BSD LICENSE
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *************************************************************************/
30 
31 #ifndef OPENCV_FLANN_DIST_H_
32 #define OPENCV_FLANN_DIST_H_
33 
34 #include <cmath>
35 #include <cstdlib>
36 #include <string.h>
37 #ifdef _MSC_VER
38 typedef unsigned __int32 uint32_t;
39 typedef unsigned __int64 uint64_t;
40 #else
41 #include <stdint.h>
42 #endif
43 
44 #include "defines.h"
45 
46 #if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
47 # include <Intrin.h>
48 #endif
49 
50 #ifdef __ARM_NEON__
51 # include "arm_neon.h"
52 #endif
53 
54 namespace cvflann
55 {
56 
57 template<typename T>
58 inline T abs(T x) { return (x<0) ? -x : x; }
59 
60 template<>
61 inline int abs<int>(int x) { return ::abs(x); }
62 
63 template<>
64 inline float abs<float>(float x) { return fabsf(x); }
65 
66 template<>
67 inline double abs<double>(double x) { return fabs(x); }
68 
69 template<typename T>
70 struct Accumulator { typedef T Type; };
71 template<>
72 struct Accumulator<unsigned char> { typedef float Type; };
73 template<>
74 struct Accumulator<unsigned short> { typedef float Type; };
75 template<>
76 struct Accumulator<unsigned int> { typedef float Type; };
77 template<>
78 struct Accumulator<char> { typedef float Type; };
79 template<>
80 struct Accumulator<short> { typedef float Type; };
81 template<>
82 struct Accumulator<int> { typedef float Type; };
83 
84 #undef True
85 #undef False
86 
87 class True
88 {
89 };
90 
91 class False
92 {
93 };
94 
95 
102 template<class T>
103 struct L2_Simple
104 {
107 
108  typedef T ElementType;
110 
111  template <typename Iterator1, typename Iterator2>
112  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
113  {
115  ResultType diff;
116  for(size_t i = 0; i < size; ++i ) {
117  diff = *a++ - *b++;
118  result += diff*diff;
119  }
120  return result;
121  }
122 
123  template <typename U, typename V>
124  inline ResultType accum_dist(const U& a, const V& b, int) const
125  {
126  return (a-b)*(a-b);
127  }
128 };
129 
130 
131 
135 template<class T>
136 struct L2
137 {
140 
141  typedef T ElementType;
143 
153  template <typename Iterator1, typename Iterator2>
154  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
155  {
157  ResultType diff0, diff1, diff2, diff3;
158  Iterator1 last = a + size;
159  Iterator1 lastgroup = last - 3;
160 
161  /* Process 4 items with each loop for efficiency. */
162  while (a < lastgroup) {
163  diff0 = (ResultType)(a[0] - b[0]);
164  diff1 = (ResultType)(a[1] - b[1]);
165  diff2 = (ResultType)(a[2] - b[2]);
166  diff3 = (ResultType)(a[3] - b[3]);
167  result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3;
168  a += 4;
169  b += 4;
170 
171  if ((worst_dist>0)&&(result>worst_dist)) {
172  return result;
173  }
174  }
175  /* Process last 0-3 pixels. Not needed for standard vector lengths. */
176  while (a < last) {
177  diff0 = (ResultType)(*a++ - *b++);
178  result += diff0 * diff0;
179  }
180  return result;
181  }
182 
189  template <typename U, typename V>
190  inline ResultType accum_dist(const U& a, const V& b, int) const
191  {
192  return (a-b)*(a-b);
193  }
194 };
195 
196 
197 /*
198  * Manhattan distance functor, optimized version
199  */
200 template<class T>
201 struct L1
202 {
205 
206  typedef T ElementType;
208 
215  template <typename Iterator1, typename Iterator2>
216  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
217  {
219  ResultType diff0, diff1, diff2, diff3;
220  Iterator1 last = a + size;
221  Iterator1 lastgroup = last - 3;
222 
223  /* Process 4 items with each loop for efficiency. */
224  while (a < lastgroup) {
225  diff0 = (ResultType)abs(a[0] - b[0]);
226  diff1 = (ResultType)abs(a[1] - b[1]);
227  diff2 = (ResultType)abs(a[2] - b[2]);
228  diff3 = (ResultType)abs(a[3] - b[3]);
229  result += diff0 + diff1 + diff2 + diff3;
230  a += 4;
231  b += 4;
232 
233  if ((worst_dist>0)&&(result>worst_dist)) {
234  return result;
235  }
236  }
237  /* Process last 0-3 pixels. Not needed for standard vector lengths. */
238  while (a < last) {
239  diff0 = (ResultType)abs(*a++ - *b++);
240  result += diff0;
241  }
242  return result;
243  }
244 
248  template <typename U, typename V>
249  inline ResultType accum_dist(const U& a, const V& b, int) const
250  {
251  return abs(a-b);
252  }
253 };
254 
255 
256 
257 template<class T>
259 {
262 
263  typedef T ElementType;
265 
266  int order;
267 
268  MinkowskiDistance(int order_) : order(order_) {}
269 
279  template <typename Iterator1, typename Iterator2>
280  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
281  {
283  ResultType diff0, diff1, diff2, diff3;
284  Iterator1 last = a + size;
285  Iterator1 lastgroup = last - 3;
286 
287  /* Process 4 items with each loop for efficiency. */
288  while (a < lastgroup) {
289  diff0 = (ResultType)abs(a[0] - b[0]);
290  diff1 = (ResultType)abs(a[1] - b[1]);
291  diff2 = (ResultType)abs(a[2] - b[2]);
292  diff3 = (ResultType)abs(a[3] - b[3]);
293  result += pow(diff0,order) + pow(diff1,order) + pow(diff2,order) + pow(diff3,order);
294  a += 4;
295  b += 4;
296 
297  if ((worst_dist>0)&&(result>worst_dist)) {
298  return result;
299  }
300  }
301  /* Process last 0-3 pixels. Not needed for standard vector lengths. */
302  while (a < last) {
303  diff0 = (ResultType)abs(*a++ - *b++);
304  result += pow(diff0,order);
305  }
306  return result;
307  }
308 
312  template <typename U, typename V>
313  inline ResultType accum_dist(const U& a, const V& b, int) const
314  {
315  return pow(static_cast<ResultType>(abs(a-b)),order);
316  }
317 };
318 
319 
320 
321 template<class T>
323 {
326 
327  typedef T ElementType;
329 
335  template <typename Iterator1, typename Iterator2>
336  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
337  {
339  ResultType diff0, diff1, diff2, diff3;
340  Iterator1 last = a + size;
341  Iterator1 lastgroup = last - 3;
342 
343  /* Process 4 items with each loop for efficiency. */
344  while (a < lastgroup) {
345  diff0 = abs(a[0] - b[0]);
346  diff1 = abs(a[1] - b[1]);
347  diff2 = abs(a[2] - b[2]);
348  diff3 = abs(a[3] - b[3]);
349  if (diff0>result) {result = diff0; }
350  if (diff1>result) {result = diff1; }
351  if (diff2>result) {result = diff2; }
352  if (diff3>result) {result = diff3; }
353  a += 4;
354  b += 4;
355 
356  if ((worst_dist>0)&&(result>worst_dist)) {
357  return result;
358  }
359  }
360  /* Process last 0-3 pixels. Not needed for standard vector lengths. */
361  while (a < last) {
362  diff0 = abs(*a++ - *b++);
363  result = (diff0>result) ? diff0 : result;
364  }
365  return result;
366  }
367 
368  /* This distance functor is not dimension-wise additive, which
369  * makes it an invalid kd-tree distance, not implementing the accum_dist method */
370 
371 };
372 
374 
380 {
383 
384  typedef unsigned char ElementType;
385  typedef int ResultType;
386 
389  ResultType operator()(const unsigned char* a, const unsigned char* b, int size) const
390  {
391  static const uchar popCountTable[] =
392  {
393  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
394  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
395  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
396  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
397  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
398  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
399  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
400  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
401  };
402  ResultType result = 0;
403  for (int i = 0; i < size; i++) {
404  result += popCountTable[a[i] ^ b[i]];
405  }
406  return result;
407  }
408 };
409 
415 {
418 
419  typedef unsigned char ElementType;
420  typedef int ResultType;
421 
424  ResultType operator()(const unsigned char* a, const unsigned char* b, size_t size) const
425  {
426  static const uchar popCountTable[] =
427  {
428  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
429  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
430  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
431  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
432  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
433  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
434  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
435  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
436  };
437  ResultType result = 0;
438  for (size_t i = 0; i < size; i++) {
439  result += popCountTable[a[i] ^ b[i]];
440  }
441  return result;
442  }
443 };
444 
449 template<class T>
450 struct Hamming
451 {
454 
455 
456  typedef T ElementType;
457  typedef int ResultType;
458 
459  template<typename Iterator1, typename Iterator2>
460  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
461  {
462  ResultType result = 0;
463 #ifdef __ARM_NEON__
464  {
465  uint32x4_t bits = vmovq_n_u32(0);
466  for (size_t i = 0; i < size; i += 16) {
467  uint8x16_t A_vec = vld1q_u8 (a + i);
468  uint8x16_t B_vec = vld1q_u8 (b + i);
469  uint8x16_t AxorB = veorq_u8 (A_vec, B_vec);
470  uint8x16_t bitsSet = vcntq_u8 (AxorB);
471  uint16x8_t bitSet8 = vpaddlq_u8 (bitsSet);
472  uint32x4_t bitSet4 = vpaddlq_u16 (bitSet8);
473  bits = vaddq_u32(bits, bitSet4);
474  }
475  uint64x2_t bitSet2 = vpaddlq_u32 (bits);
476  result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0);
477  result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2);
478  }
479 #elif __GNUC__
480  {
481  //for portability just use unsigned long -- and use the __builtin_popcountll (see docs for __builtin_popcountll)
482  typedef unsigned long long pop_t;
483  const size_t modulo = size % sizeof(pop_t);
484  const pop_t* a2 = reinterpret_cast<const pop_t*> (a);
485  const pop_t* b2 = reinterpret_cast<const pop_t*> (b);
486  const pop_t* a2_end = a2 + (size / sizeof(pop_t));
487 
488  for (; a2 != a2_end; ++a2, ++b2) result += __builtin_popcountll((*a2) ^ (*b2));
489 
490  if (modulo) {
491  //in the case where size is not dividable by sizeof(size_t)
492  //need to mask off the bits at the end
493  pop_t a_final = 0, b_final = 0;
494  memcpy(&a_final, a2, modulo);
495  memcpy(&b_final, b2, modulo);
496  result += __builtin_popcountll(a_final ^ b_final);
497  }
498  }
499 #else // NO NEON and NOT GNUC
500  typedef unsigned long long pop_t;
501  HammingLUT lut;
502  result = lut(reinterpret_cast<const unsigned char*> (a),
503  reinterpret_cast<const unsigned char*> (b), size * sizeof(pop_t));
504 #endif
505  return result;
506  }
507 };
508 
509 template<typename T>
510 struct Hamming2
511 {
514 
515  typedef T ElementType;
516  typedef int ResultType;
517 
520  unsigned int popcnt32(uint32_t n) const
521  {
522  n -= ((n >> 1) & 0x55555555);
523  n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
524  return (((n + (n >> 4))& 0xF0F0F0F)* 0x1010101) >> 24;
525  }
526 
527 #ifdef FLANN_PLATFORM_64_BIT
528  unsigned int popcnt64(uint64_t n) const
529  {
530  n -= ((n >> 1) & 0x5555555555555555);
531  n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333);
532  return (((n + (n >> 4))& 0x0f0f0f0f0f0f0f0f)* 0x0101010101010101) >> 56;
533  }
534 #endif
535 
536  template <typename Iterator1, typename Iterator2>
537  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
538  {
539 #ifdef FLANN_PLATFORM_64_BIT
540  const uint64_t* pa = reinterpret_cast<const uint64_t*>(a);
541  const uint64_t* pb = reinterpret_cast<const uint64_t*>(b);
542  ResultType result = 0;
543  size /= (sizeof(uint64_t)/sizeof(unsigned char));
544  for(size_t i = 0; i < size; ++i ) {
545  result += popcnt64(*pa ^ *pb);
546  ++pa;
547  ++pb;
548  }
549 #else
550  const uint32_t* pa = reinterpret_cast<const uint32_t*>(a);
551  const uint32_t* pb = reinterpret_cast<const uint32_t*>(b);
552  ResultType result = 0;
553  size /= (sizeof(uint32_t)/sizeof(unsigned char));
554  for(size_t i = 0; i < size; ++i ) {
555  result += popcnt32(*pa ^ *pb);
556  ++pa;
557  ++pb;
558  }
559 #endif
560  return result;
561  }
562 };
563 
564 
565 
567 
568 template<class T>
570 {
573 
574  typedef T ElementType;
576 
580  template <typename Iterator1, typename Iterator2>
581  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
582  {
584  ResultType min0, min1, min2, min3;
585  Iterator1 last = a + size;
586  Iterator1 lastgroup = last - 3;
587 
588  /* Process 4 items with each loop for efficiency. */
589  while (a < lastgroup) {
590  min0 = (ResultType)(a[0] < b[0] ? a[0] : b[0]);
591  min1 = (ResultType)(a[1] < b[1] ? a[1] : b[1]);
592  min2 = (ResultType)(a[2] < b[2] ? a[2] : b[2]);
593  min3 = (ResultType)(a[3] < b[3] ? a[3] : b[3]);
594  result += min0 + min1 + min2 + min3;
595  a += 4;
596  b += 4;
597  if ((worst_dist>0)&&(result>worst_dist)) {
598  return result;
599  }
600  }
601  /* Process last 0-3 pixels. Not needed for standard vector lengths. */
602  while (a < last) {
603  min0 = (ResultType)(*a < *b ? *a : *b);
604  result += min0;
605  ++a;
606  ++b;
607  }
608  return result;
609  }
610 
614  template <typename U, typename V>
615  inline ResultType accum_dist(const U& a, const V& b, int) const
616  {
617  return a<b ? a : b;
618  }
619 };
620 
621 
622 
623 template<class T>
625 {
628 
629  typedef T ElementType;
631 
635  template <typename Iterator1, typename Iterator2>
636  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType /*worst_dist*/ = -1) const
637  {
639  ResultType diff0, diff1, diff2, diff3;
640  Iterator1 last = a + size;
641  Iterator1 lastgroup = last - 3;
642 
643  /* Process 4 items with each loop for efficiency. */
644  while (a < lastgroup) {
645  diff0 = sqrt(static_cast<ResultType>(a[0])) - sqrt(static_cast<ResultType>(b[0]));
646  diff1 = sqrt(static_cast<ResultType>(a[1])) - sqrt(static_cast<ResultType>(b[1]));
647  diff2 = sqrt(static_cast<ResultType>(a[2])) - sqrt(static_cast<ResultType>(b[2]));
648  diff3 = sqrt(static_cast<ResultType>(a[3])) - sqrt(static_cast<ResultType>(b[3]));
649  result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3;
650  a += 4;
651  b += 4;
652  }
653  while (a < last) {
654  diff0 = sqrt(static_cast<ResultType>(*a++)) - sqrt(static_cast<ResultType>(*b++));
655  result += diff0 * diff0;
656  }
657  return result;
658  }
659 
663  template <typename U, typename V>
664  inline ResultType accum_dist(const U& a, const V& b, int) const
665  {
666  return sqrt(static_cast<ResultType>(a)) - sqrt(static_cast<ResultType>(b));
667  }
668 };
669 
670 
671 template<class T>
673 {
676 
677  typedef T ElementType;
679 
683  template <typename Iterator1, typename Iterator2>
684  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
685  {
687  ResultType sum, diff;
688  Iterator1 last = a + size;
689 
690  while (a < last) {
691  sum = (ResultType)(*a + *b);
692  if (sum>0) {
693  diff = (ResultType)(*a - *b);
694  result += diff*diff/sum;
695  }
696  ++a;
697  ++b;
698 
699  if ((worst_dist>0)&&(result>worst_dist)) {
700  return result;
701  }
702  }
703  return result;
704  }
705 
709  template <typename U, typename V>
710  inline ResultType accum_dist(const U& a, const V& b, int) const
711  {
713  ResultType sum, diff;
714 
715  sum = (ResultType)(a+b);
716  if (sum>0) {
717  diff = (ResultType)(a-b);
718  result = diff*diff/sum;
719  }
720  return result;
721  }
722 };
723 
724 
725 template<class T>
727 {
730 
731  typedef T ElementType;
733 
737  template <typename Iterator1, typename Iterator2>
738  ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const
739  {
741  Iterator1 last = a + size;
742 
743  while (a < last) {
744  if (* a != 0) {
745  ResultType ratio = (ResultType)(*a / *b);
746  if (ratio>0) {
747  result += *a * log(ratio);
748  }
749  }
750  ++a;
751  ++b;
752 
753  if ((worst_dist>0)&&(result>worst_dist)) {
754  return result;
755  }
756  }
757  return result;
758  }
759 
763  template <typename U, typename V>
764  inline ResultType accum_dist(const U& a, const V& b, int) const
765  {
767  ResultType ratio = (ResultType)(a / b);
768  if (ratio>0) {
769  result = a * log(ratio);
770  }
771  return result;
772  }
773 };
774 
775 
776 
777 /*
778  * This is a "zero iterator". It basically behaves like a zero filled
779  * array to all algorithms that use arrays as iterators (STL style).
780  * It's useful when there's a need to compute the distance between feature
781  * and origin it and allows for better compiler optimisation than using a
782  * zero-filled array.
783  */
784 template <typename T>
786 {
787 
789  {
790  return 0;
791  }
792 
794  {
795  return 0;
796  }
797 
799  {
800  return *this;
801  }
802 
804  {
805  return *this;
806  }
807 
809  {
810  return *this;
811  }
812 
813 };
814 
815 }
816 
817 #endif //OPENCV_FLANN_DIST_H_
unsigned __int32 uint32_t
Definition: dist.h:38
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:336
Definition: dist.h:87
short float uchar uchar uchar uchar uchar ushort int uchar ushort int float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float int int int float int int int float int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP char CV_CUDEV_IMPLEMENT_VEC_BINARY_OP ushort CV_CUDEV_IMPLEMENT_VEC_BINARY_OP short CV_CUDEV_IMPLEMENT_VEC_BINARY_OP int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP uint CV_CUDEV_IMPLEMENT_VEC_BINARY_OP float CV_CUDEV_IMPLEMENT_VEC_BINARY_OP double char
Definition: vec_math.hpp:426
Accumulator< T >::Type ResultType
Definition: dist.h:575
CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst)
computes square root of each matrix element (dst = src**0.5)
T ElementType
Definition: dist.h:141
unsigned int popcnt32(uint32_t n) const
Definition: dist.h:520
float Type
Definition: dist.h:78
Definition: dist.h:379
False is_vector_space_distance
Definition: dist.h:417
CvArr const CvArr * lut
Definition: core_c.h:1439
True is_kdtree_distance
Definition: dist.h:138
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:124
True is_vector_space_distance
Definition: dist.h:627
Definition: dist.h:201
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType=-1) const
Definition: dist.h:537
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:615
int ResultType
Definition: dist.h:385
const CvArr * U
Definition: core_c.h:733
CvPoint2D32f float float b
Definition: legacy.hpp:578
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:710
True is_kdtree_distance
Definition: dist.h:105
ResultType operator()(const unsigned char *a, const unsigned char *b, int size) const
Definition: dist.h:389
Accumulator< T >::Type ResultType
Definition: dist.h:678
CvSize size
Definition: calib3d.hpp:212
float Type
Definition: dist.h:72
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType=-1) const
Definition: dist.h:460
float Type
Definition: dist.h:76
ZeroIterator< T > & operator+=(int)
Definition: dist.h:808
T ElementType
Definition: dist.h:629
True is_kdtree_distance
Definition: dist.h:260
int ResultType
Definition: dist.h:457
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:249
True is_kdtree_distance
Definition: dist.h:626
Accumulator< T >::Type ResultType
Definition: dist.h:109
T operator[](int)
Definition: dist.h:793
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat CvMat * T
Definition: calib3d.hpp:270
Definition: dist.h:726
T ElementType
Definition: dist.h:263
Definition: dist.h:672
False is_vector_space_distance
Definition: dist.h:382
float Type
Definition: dist.h:80
double abs< double >(double x)
Definition: dist.h:67
OutputArray sum
Definition: imgproc.hpp:620
False is_kdtree_distance
Definition: dist.h:416
int ResultType
Definition: dist.h:420
Definition: dist.h:136
const CvArr const CvArr CvArr * result
Definition: core_c.h:805
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:738
Accumulator< T >::Type ResultType
Definition: dist.h:732
unsigned __int64 uint64_t
Definition: dist.h:39
False is_vector_space_distance
Definition: dist.h:453
Accumulator< T >::Type ResultType
Definition: dist.h:328
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType=-1) const
Definition: dist.h:636
False is_kdtree_distance
Definition: dist.h:512
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:764
False is_kdtree_distance
Definition: dist.h:381
T ElementType
Definition: dist.h:515
unsigned char ElementType
Definition: dist.h:384
unsigned char ElementType
Definition: dist.h:419
Definition: dist.h:510
float Type
Definition: dist.h:74
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType=-1) const
Definition: dist.h:112
int order
Definition: dist.h:266
GLenum GLint x
Definition: core_c.h:632
True is_vector_space_distance
Definition: dist.h:729
T ElementType
Definition: dist.h:108
Accumulator< T >::Type ResultType
Definition: dist.h:142
Definition: dist.h:91
GLenum GLsizei n
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:216
Definition: dist.h:70
T ElementType
Definition: dist.h:206
T ElementType
Definition: dist.h:731
ResultType operator()(const unsigned char *a, const unsigned char *b, size_t size) const
Definition: dist.h:424
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:190
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:664
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
Definition: dist.h:414
True is_kdtree_distance
Definition: dist.h:571
True is_vector_space_distance
Definition: dist.h:204
const CvArr const CvArr * V
Definition: core_c.h:733
Definition: dist.h:624
ResultType accum_dist(const U &a, const V &b, int) const
Definition: dist.h:313
float Type
Definition: dist.h:82
True is_vector_space_distance
Definition: dist.h:325
True is_vector_space_distance
Definition: dist.h:261
T ElementType
Definition: dist.h:677
True is_vector_space_distance
Definition: dist.h:572
const ZeroIterator< T > & operator++()
Definition: dist.h:798
CV_EXPORTS_W void log(InputArray src, OutputArray dst)
computes natural logarithm of absolute value of each matrix element: dst = log(abs(src)) ...
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:280
True is_vector_space_distance
Definition: dist.h:675
Accumulator< T >::Type ResultType
Definition: dist.h:264
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
Definition: dist.h:322
True is_kdtree_distance
Definition: dist.h:728
T ElementType
Definition: dist.h:327
int abs< int >(int x)
Definition: dist.h:61
Accumulator< T >::Type ResultType
Definition: dist.h:207
unsigned int popcnt64(uint64_t n) const
Definition: dist.h:528
unsigned char uchar
Definition: types_c.h:170
T Type
Definition: dist.h:70
False is_kdtree_distance
Definition: dist.h:452
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:684
Definition: dist.h:450
True is_kdtree_distance
Definition: dist.h:674
float abs< float >(float x)
Definition: dist.h:64
T ElementType
Definition: dist.h:574
::max::max int
Definition: functional.hpp:324
T abs(T x)
Definition: dist.h:58
CvPoint2D32f float a
Definition: legacy.hpp:578
int x
Definition: highgui_c.h:186
T operator*()
Definition: dist.h:788
short
Definition: vec_math.hpp:153
Definition: dist.h:785
int ResultType
Definition: dist.h:516
True is_vector_space_distance
Definition: dist.h:139
MinkowskiDistance(int order_)
Definition: dist.h:268
Definition: dist.h:258
Definition: dist.h:103
True is_kdtree_distance
Definition: dist.h:203
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:581
True is_vector_space_distance
Definition: dist.h:106
Accumulator< T >::Type ResultType
Definition: dist.h:630
False is_kdtree_distance
Definition: dist.h:324
CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst)
raises the input matrix elements to the specified power (b = a**power)
T ElementType
Definition: dist.h:456
GLsizeiptr size
Definition: core_c.h:939
Definition: dist.h:569
ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist=-1) const
Definition: dist.h:154
False is_vector_space_distance
Definition: dist.h:513