Search in sources :

Example 31 with TupleDesc_F64

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

the class TestDescribeDenseSiftAlg method computeDescriptor.

/**
 * Compute to the general descriptor algorithm.  They should produce the same results
 */
@Test
public void computeDescriptor() {
    GrayF32 derivX = new GrayF32(100, 102);
    GrayF32 derivY = new GrayF32(100, 102);
    GImageMiscOps.fillUniform(derivX, rand, 0, 200);
    GImageMiscOps.fillUniform(derivY, rand, 0, 200);
    DescribeDenseSiftAlg<GrayF32> alg = new DescribeDenseSiftAlg<>(4, 4, 8, 0.5, 0.2, 10, 10, GrayF32.class);
    DescribePointSift<GrayF32> algTest = new DescribePointSift<>(4, 4, 8, 1, 0.5, 0.2, GrayF32.class);
    alg.setImageGradient(derivX, derivY);
    algTest.setImageGradient(derivX, derivY);
    List<Point2D_I32> samplePoints = new ArrayList<>();
    samplePoints.add(new Point2D_I32(30, 35));
    samplePoints.add(new Point2D_I32(45, 10));
    samplePoints.add(new Point2D_I32(60, 12));
    samplePoints.add(new Point2D_I32(50, 50));
    TupleDesc_F64 found = new TupleDesc_F64(128);
    TupleDesc_F64 expected = new TupleDesc_F64(128);
    for (Point2D_I32 p : samplePoints) {
        alg.computeDescriptor(p.x, p.y, found);
        algTest.process(p.x, p.y, 1, 0, expected);
        for (int i = 0; i < 128; i++) {
            assertEquals(expected.value[i], found.value[i], 1e-8);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DescribePointSift(boofcv.alg.feature.describe.DescribePointSift) ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 32 with TupleDesc_F64

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

the class TestDescribePointSift method process.

/**
 * Tests to see if it blows up and not much more.  Random image.  Compute descriptor along border and image
 * center.
 */
@Test
public void process() {
    GrayF32 derivX = new GrayF32(200, 200);
    GrayF32 derivY = new GrayF32(200, 200);
    GImageMiscOps.fillUniform(derivX, rand, -100, 100);
    GImageMiscOps.fillUniform(derivY, rand, -100, 100);
    DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
    alg.setImageGradient(derivX, derivY);
    List<Point2D_I32> testPoints = new ArrayList<>();
    testPoints.add(new Point2D_I32(100, 0));
    testPoints.add(new Point2D_I32(100, 199));
    testPoints.add(new Point2D_I32(0, 100));
    testPoints.add(new Point2D_I32(199, 100));
    testPoints.add(new Point2D_I32(100, 100));
    TupleDesc_F64 desc = new TupleDesc_F64(alg.getDescriptorLength());
    for (Point2D_I32 where : testPoints) {
        alg.process(where.x, where.y, 2, 0.5, desc);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) Test(org.junit.Test)

Example 33 with TupleDesc_F64

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

the class TestConvertDescriptors method real_F64.

/**
 * General test with a known output
 */
@Test
public void real_F64() {
    TupleDesc_F64 input = new TupleDesc_F64(4);
    input.value = new double[] { 1, -2, 3, -4 };
    TupleDesc_S8 output = new TupleDesc_S8(4);
    ConvertDescriptors.real(input, output);
    assertEquals((int) (1 * 127.0 / 4.0), output.value[0]);
    assertEquals((int) (-2 * 127.0 / 4.0), output.value[1]);
    assertEquals((int) (3 * 127.0 / 4.0), output.value[2]);
    assertEquals((int) (-4 * 127.0 / 4.0), output.value[3]);
}
Also used : TupleDesc_S8(boofcv.struct.feature.TupleDesc_S8) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Example 34 with TupleDesc_F64

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

the class TestConvertDescriptors method convertNcc_F64.

@Test
public void convertNcc_F64() {
    TupleDesc_F64 desc = new TupleDesc_F64(100);
    for (int i = 0; i < desc.size(); i++) {
        desc.value[i] = rand.nextDouble() * 2 - 1;
    }
    NccFeature found = new NccFeature(100);
    ConvertDescriptors.convertNcc(desc, found);
    for (int i = 0; i < desc.size(); i++) {
        assertEquals(desc.value[i], found.value[i] + found.mean, 1e-8);
    }
    // crude test.  just makes sure signa has been set really.
    assertTrue(found.sigma > 0);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) NccFeature(boofcv.struct.feature.NccFeature) Test(org.junit.Test)

Example 35 with TupleDesc_F64

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

the class TestConvertDescriptors method positive_F64_zeros.

/**
 * Test pathological case where the input is all zeros
 */
@Test
public void positive_F64_zeros() {
    TupleDesc_F64 input = new TupleDesc_F64(4);
    TupleDesc_U8 output = new TupleDesc_U8(4);
    ConvertDescriptors.positive(input, output);
    for (int i = 0; i < 4; i++) assertEquals(0, output.value[0]);
}
Also used : TupleDesc_U8(boofcv.struct.feature.TupleDesc_U8) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

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