| 51 | } |
| 52 | |
| 53 | static double GetHatFit( // args same as non CACHE version, see below |
| 54 | int x, // in |
| 55 | int y, // in |
| 56 | const HatFit hatfit) // in |
| 57 | { |
| 58 | const double* descbuf = NULL; // the HAT descriptor |
| 59 | // for max cache hit rate, x and y should divisible by HAT_SEARCH_RESOL |
| 60 | CV_DbgAssert(x % HAT_SEARCH_RESOL == 0); |
| 61 | CV_DbgAssert(y % HAT_SEARCH_RESOL == 0); |
| 62 | if (TRACE_CACHE) |
| 63 | ncalls_g++; |
| 64 | const unsigned key(Key(x, y)); |
| 65 | #pragma omp critical // prevent OpenMP concurrent access to cache_g |
| 66 | { |
| 67 | std::unordered_map<unsigned, VEC>:: const_iterator it(cache_g.find(key)); |
| 68 | if (it != cache_g.end()) // in cache? |
| 69 | { |
| 70 | descbuf = Buf(it->second); // use cached descriptor |
| 71 | if (TRACE_CACHE) |
| 72 | nhits_g++; |
| 73 | } |
| 74 | } |
| 75 | if (descbuf == NULL) // descriptor not in cache? |
| 76 | { |
| 77 | const VEC desc(hat_g.Desc_(x, y)); |
| 78 | #pragma omp critical // prevent OpenMP concurrent access to cache_g |
| 79 | cache_g[key] = desc; // remember descriptor for possible re-use |
| 80 | descbuf = Buf(desc); |
| 81 | } |
| 82 | return hatfit(descbuf); |
| 83 | } |
| 84 | |
| 85 | #else // not CACHE |
| 86 |
no test coverage detected