/** * This searches through the keypoints in klist for the closest match to key. */ protected T findMatch(T query, List<T> features) { double distsq = Double.MAX_VALUE; T minkey = null; // find closest match for (final T target : features) { final double dsq = target.getFeatureVector().asDoubleFV() .compare(query.getFeatureVector().asDoubleFV(), DoubleFVComparison.SUM_SQUARE); if (dsq < distsq) { distsq = dsq; minkey = target; } } return minkey; }
/** * This searches through the keypoints in klist for the closest match to * key. */ protected T findMatch(T query, List<T> features) { double distsq = Double.MAX_VALUE; T minkey = null; // find closest match for (final T target : features) { final double dsq = target.getFeatureVector().asDoubleFV() .compare(query.getFeatureVector().asDoubleFV(), DoubleFVComparison.EUCLIDEAN); if (dsq < distsq) { distsq = dsq; minkey = target; } } return minkey; }
/** * This searches through the keypoints in klist for the two closest matches to * key. If the closest is less than <code>threshold</code> times distance to * second closest, then return the closest match. Otherwise, return NULL. */ protected T checkForMatch(T query, List<T> features) { double distsq1 = Double.MAX_VALUE, distsq2 = Double.MAX_VALUE; T minkey = null; // find two closest matches for (final T target : features) { final double dsq = target.getFeatureVector().asDoubleFV() .compare(query.getFeatureVector().asDoubleFV(), DoubleFVComparison.SUM_SQUARE); if (dsq < distsq1) { distsq2 = distsq1; distsq1 = dsq; minkey = target; } else if (dsq < distsq2) { distsq2 = dsq; } } // check the distance against the threshold if (10 * 10 * distsq1 < thresh * thresh * distsq2) { return minkey; } else return null; }
/** * This searches through the keypoints in klist for the two closest matches * to key. If the closest is less than <code>threshold</code> times distance * to second closest, then return the closest match. Otherwise, return NULL. */ protected T checkForMatch(T query, List<T> features) { double distsq1 = Double.MAX_VALUE, distsq2 = Double.MAX_VALUE; T minkey = null; // find two closest matches for (final T target : features) { final double dsq = target.getFeatureVector().asDoubleFV() .compare(query.getFeatureVector().asDoubleFV(), DoubleFVComparison.EUCLIDEAN); if (dsq < distsq1) { distsq2 = distsq1; distsq1 = dsq; minkey = target; } else if (dsq < distsq2) { distsq2 = dsq; } } // check the distance against the threshold if (10 * 10 * distsq1 < thresh * thresh * distsq2) { return minkey; } else return null; }
for (final String person : features.keySet()) { for (final DoubleFV fv : features.get(person)) { final double distance = fv.compare(testFeature, DoubleFVComparison.EUCLIDEAN);
final DoubleFV fj = features[j]; matrix.set(i, j, fi.compare(fj, DoubleFVComparison.COSINE_SIM));
final DoubleFV fj = features[j]; matrix.set(i, j, fi.compare(fj, DoubleFVComparison.COSINE_SIM));