Search in sources :

Example 86 with TupleDesc_F64

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

the class TestGenericDenseDescribeImage method process.

/**
 * Give it a known situation and see if it produces the expected results
 */
@Test
void process() {
    DummyFeature sparse = new DummyFeature();
    GenericDenseDescribeImageDense alg = new GenericDenseDescribeImageDense(sparse, 1.5, 3, 4);
    GrayU8 image = new GrayU8(100, 110);
    alg.process(image);
    List<TupleDesc_F64> descs = alg.getDescriptions();
    List<Point2D_I32> points = alg.getLocations();
    assertEquals(descs.size(), points.size());
    int featureRadius = (int) Math.round(1.5 * 7.0 / 2.0);
    int w = (100 - 2 * featureRadius) / 3;
    int h = (110 - 2 * featureRadius) / 4;
    // -1 since it intentionally skips feature 20
    assertEquals(w * h - 1, points.size());
    int count = 0;
    for (int y = 0; y < h; y++) {
        int pixelY = featureRadius + y * y;
        for (int x = 0; x < w; x++) {
            int pixelX = featureRadius + x * 3;
            Point2D_I32 p = null;
            if (count < 19) {
                p = points.get(count);
            } else if (count > 20) {
                p = points.get(count + 1);
            } else {
                continue;
            }
            assertEquals(pixelX, p.x);
            assertEquals(pixelY, p.y);
            count++;
        }
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Point2D_I32(georegression.struct.point.Point2D_I32) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

Example 87 with TupleDesc_F64

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

the class TestDescribeSift_RadiusAngle method process.

@Test
void process() {
    GrayF32 image = new GrayF32(640, 480);
    GImageMiscOps.fillUniform(image, rand, 0, 200);
    DescribeSift_RadiusAngle<GrayF32> alg = declare();
    alg.setImage(image);
    TupleDesc_F64 desc0 = alg.createDescription();
    TupleDesc_F64 desc1 = alg.createDescription();
    TupleDesc_F64 desc2 = alg.createDescription();
    // same location, but different orientations and scales
    assertTrue(alg.process(100, 120, 0.5, 10, desc0));
    assertTrue(alg.process(100, 50, -1.1, 10, desc1));
    assertTrue(alg.process(100, 50, 0.5, 7, desc2));
    // should be 3 different descriptions
    assertNotEquals(desc0.getDouble(0), desc1.getDouble(0), 1e-6);
    assertNotEquals(desc0.getDouble(0), desc2.getDouble(0), 1e-6);
    assertNotEquals(desc1.getDouble(0), desc2.getDouble(0), 1e-6);
    // see if it blows up along the image border
    assertTrue(alg.process(0, 120, 0.5, 10, desc0));
    assertTrue(alg.process(100, 0, 0.5, 10, desc0));
    assertTrue(alg.process(639, 120, 0.5, 10, desc0));
    assertTrue(alg.process(100, 479, 0.5, 10, desc0));
}
Also used : GrayF32(boofcv.struct.image.GrayF32) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.jupiter.api.Test)

Example 88 with TupleDesc_F64

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

the class TestConvertTupleDescSigned_F64_S8 method convert.

@Test
void convert() {
    var alg = new ConvertTupleDescSigned_F64_S8(5);
    var input = new TupleDesc_F64(5);
    input.data = new double[] { -2.5, 3, 20, -243.45 };
    TupleDesc_S8 found = alg.createOutput();
    alg.convert(input, found);
    TupleDesc_S8 expected = alg.createOutput();
    ConvertDescriptors.signed(input, expected);
    for (int i = 0; i < 5; i++) {
        assertEquals(expected.data[i], found.data[i]);
    }
}
Also used : TupleDesc_S8(boofcv.struct.feature.TupleDesc_S8) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.jupiter.api.Test)

Example 89 with TupleDesc_F64

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

the class TestAssociateDescriptionSets2D method c.

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

Example 90 with TupleDesc_F64

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

the class TestScoreAssociateCorrelation method compareToExpected.

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

Aggregations

TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)127 Test (org.junit.jupiter.api.Test)74 GrayF32 (boofcv.struct.image.GrayF32)27 DogArray_I32 (org.ddogleg.struct.DogArray_I32)15 Test (org.junit.Test)14 GrayU8 (boofcv.struct.image.GrayU8)13 ArrayList (java.util.ArrayList)12 DogArray (org.ddogleg.struct.DogArray)10 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)7 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)7 ConfigAssociateGreedy (boofcv.factory.feature.associate.ConfigAssociateGreedy)7 TupleDesc_S8 (boofcv.struct.feature.TupleDesc_S8)7 File (java.io.File)7 AssociatedTripleIndex (boofcv.struct.feature.AssociatedTripleIndex)6 Point2D_F64 (georegression.struct.point.Point2D_F64)6 Point2D_I32 (georegression.struct.point.Point2D_I32)6 Planar (boofcv.struct.image.Planar)5 RecognitionNearestNeighborInvertedFile (boofcv.alg.scene.ann.RecognitionNearestNeighborInvertedFile)4 InvertedFile (boofcv.alg.scene.bow.InvertedFile)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)4