@Override public double score(NccFeature a, NccFeature b) { return -DescriptorDistance.ncc(a, b); }
/** * Computes the best distance to 'observed' from the candidate list. * @param observed Feature being matched * @param candidates Set of candidate matches * @return score from 0 to 1, where lower is closer */ public double distance( NccFeature observed , List<NccFeature> candidates ) { double maximum = -Double.MAX_VALUE; // The feature which has the best fit will maximize the score for( NccFeature f : candidates ) { double score = DescriptorDistance.ncc(observed, f); if( score > maximum ) maximum = score; } return 1-0.5*(maximum + 1); }
private void printDescriptions() { TldTemplateMatching<T> matching = tracker.getTemplateMatching(); FastQueue<TldRegion> detected = tracker.getDetection().getLocalMaximums(); NccFeature t = matching.createDescriptor(); NccFeature f = matching.createDescriptor(); matching.computeNccDescriptor(t, target.x0, target.y0, target.x1, target.y1); System.out.println("Target:"); printDescription(t); for( int i = 0; i < detected.size; i++ ) { TldRegion r = detected.get(i); matching.computeNccDescriptor(f,r.rect.x0,r.rect.y0,r.rect.x1,r.rect.y1); System.out.println("Detected:"); System.out.println(" "+r.rect); printDescription(f); System.out.println(" NCC score = "+ DescriptorDistance.ncc(t,f)); System.out.println(" Confidence = "+ matching.computeConfidence(r.rect)); System.out.println(" Distance = "+ matching.distance(f,matching.getTemplatePositive())); } }