Search in sources :

Example 1 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestTldTemplateMatching method createDescriptor.

@Test
public void createDescriptor() {
    TldTemplateMatching alg = new TldTemplateMatching(interpolate);
    assertTrue(alg.createDescriptor() != null);
    alg.unused.push(new NccFeature(5));
    assertTrue(alg.createDescriptor() != null);
    assertEquals(0, alg.unused.size());
}
Also used : NccFeature(boofcv.struct.feature.NccFeature) Test(org.junit.Test)

Example 2 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestTldTemplateMatching method distance.

@Test
public void distance() {
    TldTemplateMatching alg = new TldTemplateMatching(interpolate);
    alg.setImage(input);
    NccFeature a = alg.createDescriptor();
    NccFeature b = alg.createDescriptor();
    NccFeature c = alg.createDescriptor();
    alg.computeNccDescriptor(a, 2, 3, 17, 18);
    alg.computeNccDescriptor(b, 2, 3, 17, 18);
    alg.computeNccDescriptor(c, 20, 32, 40, 60);
    List<NccFeature> list = new ArrayList<>();
    list.add(b);
    list.add(c);
    // same one should produce a distance of zero since the closest is identical
    assertEquals(0, alg.distance(a, list), 1e-8);
    assertEquals(0, alg.distance(c, list), 1e-8);
    // any random one should be between 0 and 1
    NccFeature d = alg.createDescriptor();
    alg.computeNccDescriptor(d, 14, 30, 20, 50);
    double found = alg.distance(d, list);
    assertTrue(found >= 0 && found <= 1);
}
Also used : ArrayList(java.util.ArrayList) NccFeature(boofcv.struct.feature.NccFeature) Test(org.junit.Test)

Example 3 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestTldTemplateMatching method computeNccDescriptor.

@Test
public void computeNccDescriptor() {
    TldTemplateMatching alg = new TldTemplateMatching(interpolate);
    alg.setImage(input);
    NccFeature found = alg.createDescriptor();
    alg.computeNccDescriptor(found, 2, 3, 17, 18);
    NccFeature expected = alg.createDescriptor();
    DescribePointPixelRegionNCC descriptor = FactoryDescribePointAlgs.pixelRegionNCC(15, 15, GrayU8.class);
    descriptor.setImage(input);
    descriptor.process(7 + 2, 7 + 3, expected);
    assertEquals(expected.mean, found.mean, 1e-8);
}
Also used : DescribePointPixelRegionNCC(boofcv.alg.feature.describe.DescribePointPixelRegionNCC) NccFeature(boofcv.struct.feature.NccFeature) Test(org.junit.Test)

Example 4 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class VisualizeTldDetectionApp method printDescriptions.

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()));
    }
}
Also used : NccFeature(boofcv.struct.feature.NccFeature) TldRegion(boofcv.alg.tracker.tld.TldRegion)

Example 5 with NccFeature

use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.

the class TestImplDescribePointPixelRegionNCC_F32 method checkBorder.

public void checkBorder(GrayF32 image, int c_x, int c_y, int w, int h) {
    ImplDescribePointPixelRegionNCC_F32 alg = new ImplDescribePointPixelRegionNCC_F32(w, h);
    NccFeature desc = new NccFeature(alg.getDescriptorLength());
    alg.setImage(image);
    assertFalse(alg.isInBounds(c_x, c_y));
}
Also used : NccFeature(boofcv.struct.feature.NccFeature)

Aggregations

NccFeature (boofcv.struct.feature.NccFeature)13 Test (org.junit.Test)5 DescribePointPixelRegionNCC (boofcv.alg.feature.describe.DescribePointPixelRegionNCC)1 TldRegion (boofcv.alg.tracker.tld.TldRegion)1 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1