Search in sources :

Example 6 with TupleDesc_F64

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

the class TestDescribeImageDense_Convert method basic.

/**
 * Checks to see if it converts the input image and that other functions are correctly
 * implemented
 */
@Test
public void basic() {
    Dummy dummy = new Dummy();
    DescribeImageDense<GrayU8, TupleDesc_F64> alg = new DescribeImageDense_Convert(dummy, ImageType.single(GrayU8.class));
    GrayU8 foo = new GrayU8(10, 20);
    foo.set(5, 2, 10);
    alg.process(foo);
    assertTrue(dummy.process);
    assertEquals(5, alg.createDescription().size());
    assertTrue(TupleDesc_F64.class == alg.getDescriptionType());
    assertTrue(alg.getImageType().getDataType() == ImageDataType.U8);
    assertTrue(null != alg.getDescriptions());
    assertTrue(null != alg.getLocations());
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 7 with TupleDesc_F64

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

the class TestAssociateNearestNeighbor method various.

/**
 * Several tests combined into one
 */
@Test
public void various() {
    Dummy<Integer> nn = new Dummy<>();
    // src = assoc[i] where src is the index of the source feature and i is the index of the dst feature
    nn.assoc = new int[] { 2, 0, 1, -1, 4, -1, -1, 2, 2, 1 };
    AssociateNearestNeighbor<TupleDesc_F64> alg = new AssociateNearestNeighbor<>(nn, 10);
    FastQueue<TupleDesc_F64> src = new FastQueue<>(10, TupleDesc_F64.class, false);
    FastQueue<TupleDesc_F64> dst = new FastQueue<>(10, TupleDesc_F64.class, false);
    for (int i = 0; i < 5; i++) {
        src.add(new TupleDesc_F64(10));
    }
    for (int i = 0; i < 10; i++) {
        dst.add(new TupleDesc_F64(10));
    }
    alg.setSource(src);
    alg.setDestination(dst);
    alg.associate();
    FastQueue<AssociatedIndex> matches = alg.getMatches();
    assertTrue(nn.pointDimension == 10);
    assertEquals(7, matches.size);
    for (int i = 0, count = 0; i < nn.assoc.length; i++) {
        if (nn.assoc[i] != -1) {
            int source = nn.assoc[i];
            assertEquals(source, matches.get(count).src);
            assertEquals(i, matches.get(count).dst);
            count++;
        }
    }
    GrowQueue_I32 unassoc = alg.getUnassociatedSource();
    assertEquals(1, unassoc.size);
    assertEquals(3, unassoc.get(0));
    unassoc = alg.getUnassociatedDestination();
    assertEquals(3, unassoc.size);
    assertEquals(3, unassoc.get(0));
    assertEquals(5, unassoc.get(1));
    assertEquals(6, unassoc.get(2));
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) FastQueue(org.ddogleg.struct.FastQueue) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 8 with TupleDesc_F64

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

the class TestAssociateNearestNeighbor method c.

@Override
protected TupleDesc_F64 c(double value) {
    TupleDesc_F64 s = new TupleDesc_F64(1);
    s.value[0] = value;
    return s;
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64)

Example 9 with TupleDesc_F64

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

the class TestScoreAssociateEuclidean_F64 method compareToExpected.

@Test
public void compareToExpected() {
    ScoreAssociateEuclidean_F64 score = new ScoreAssociateEuclidean_F64();
    TupleDesc_F64 a = new TupleDesc_F64(5);
    TupleDesc_F64 b = new TupleDesc_F64(5);
    a.value = new double[] { 1, 2, 3, 4, 5 };
    b.value = new double[] { 2, -1, 7, -8, 10 };
    assertEquals(13.964, score.score(a, b), 1e-2);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Example 10 with TupleDesc_F64

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

the class DescribeDenseSiftAlg method process.

/**
 * Computes SIFT descriptors across the entire image
 */
public void process() {
    int width = widthSubregion * widthGrid;
    int radius = width / 2;
    int X0 = radius, X1 = savedAngle.width - radius;
    int Y0 = radius, Y1 = savedAngle.height - radius;
    int numX = (int) ((X1 - X0) / periodColumns);
    int numY = (int) ((Y1 - Y0) / periodRows);
    descriptors.reset();
    sampleLocations.reset();
    for (int i = 0; i < numY; i++) {
        int y = (Y1 - Y0) * i / (numY - 1) + Y0;
        for (int j = 0; j < numX; j++) {
            int x = (X1 - X0) * j / (numX - 1) + X0;
            TupleDesc_F64 desc = descriptors.grow();
            computeDescriptor(x, y, desc);
            sampleLocations.grow().set(x, y);
        }
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64)

Aggregations

TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)66 Test (org.junit.Test)47 GrayF32 (boofcv.struct.image.GrayF32)17 GrayU8 (boofcv.struct.image.GrayU8)8 Point2D_I32 (georegression.struct.point.Point2D_I32)6 TupleDesc_S8 (boofcv.struct.feature.TupleDesc_S8)5 ArrayList (java.util.ArrayList)5 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4 BufferedImage (java.awt.image.BufferedImage)4 File (java.io.File)4 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)3 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)3 TupleDesc_U8 (boofcv.struct.feature.TupleDesc_U8)3 Planar (boofcv.struct.image.Planar)3 Point3D_F64 (georegression.struct.point.Point3D_F64)3 HistogramScene (boofcv.alg.scene.HistogramScene)2 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)2 ImageGray (boofcv.struct.image.ImageGray)2 IOException (java.io.IOException)2 FastQueue (org.ddogleg.struct.FastQueue)2