14 using namespace DBoW2;
25 BowVector::const_iterator v1_it, v2_it;
26 const BowVector::const_iterator v1_end = v1.end();
27 const BowVector::const_iterator v2_end = v2.end();
34 while(v1_it != v1_end && v2_it != v2_end)
39 if(v1_it->first == v2_it->first)
41 score += fabs(vi - wi) - fabs(vi) - fabs(wi);
47 else if(v1_it->first < v2_it->first)
50 v1_it = v1.lower_bound(v2_it->first);
56 v2_it = v2.lower_bound(v1_it->first);
75 BowVector::const_iterator v1_it, v2_it;
76 const BowVector::const_iterator v1_end = v1.end();
77 const BowVector::const_iterator v2_end = v2.end();
84 while(v1_it != v1_end && v2_it != v2_end)
89 if(v1_it->first == v2_it->first)
97 else if(v1_it->first < v2_it->first)
100 v1_it = v1.lower_bound(v2_it->first);
106 v2_it = v2.lower_bound(v1_it->first);
117 score = 1.0 - sqrt(1.0 - score);
128 BowVector::const_iterator v1_it, v2_it;
129 const BowVector::const_iterator v1_end = v1.end();
130 const BowVector::const_iterator v2_end = v2.end();
139 while(v1_it != v1_end && v2_it != v2_end)
144 if(v1_it->first == v2_it->first)
148 if(vi + wi != 0.0) score += vi * wi / (vi + wi);
154 else if(v1_it->first < v2_it->first)
157 v1_it = v1.lower_bound(v2_it->first);
162 v2_it = v2.lower_bound(v1_it->first);
177 BowVector::const_iterator v1_it, v2_it;
178 const BowVector::const_iterator v1_end = v1.end();
179 const BowVector::const_iterator v2_end = v2.end();
188 while(v1_it != v1_end && v2_it != v2_end)
193 if(v1_it->first == v2_it->first)
195 if(vi != 0 && wi != 0) score += vi * log(vi/wi);
201 else if(v1_it->first < v2_it->first)
204 score += vi * (log(vi) - LOG_EPS);
210 v2_it = v2.lower_bound(v1_it->first);
216 for(; v1_it != v1_end; ++v1_it)
217 if(v1_it->second != 0)
218 score += v1_it->second * (log(v1_it->second) - LOG_EPS);
226 double BhattacharyyaScoring::score(
const BowVector &v1,
229 BowVector::const_iterator v1_it, v2_it;
230 const BowVector::const_iterator v1_end = v1.end();
231 const BowVector::const_iterator v2_end = v2.end();
238 while(v1_it != v1_end && v2_it != v2_end)
243 if(v1_it->first == v2_it->first)
245 score += sqrt(vi * wi);
251 else if(v1_it->first < v2_it->first)
254 v1_it = v1.lower_bound(v2_it->first);
260 v2_it = v2.lower_bound(v1_it->first);
271 double DotProductScoring::score(
const BowVector &v1,
274 BowVector::const_iterator v1_it, v2_it;
275 const BowVector::const_iterator v1_end = v1.end();
276 const BowVector::const_iterator v2_end = v2.end();
283 while(v1_it != v1_end && v2_it != v2_end)
288 if(v1_it->first == v2_it->first)
296 else if(v1_it->first < v2_it->first)
299 v1_it = v1.lower_bound(v2_it->first);
305 v2_it = v2.lower_bound(v1_it->first);
Vector of words to represent images.
double WordValue
Value of a word.
static const double LOG_EPS
Log of epsilon.