Search in sources :

Example 76 with TupleDesc_F64

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

the class TestScoreAssociateEuclideanSq_F64 method compareToExpected.

@Test
public void compareToExpected() {
    ScoreAssociateEuclideanSq_F64 score = new ScoreAssociateEuclideanSq_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(195, score.score(a, b), 1e-4);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Test(org.junit.Test)

Example 77 with TupleDesc_F64

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

the class GenericAssociateGreedyChecks method ratioTest.

@Test
void ratioTest() {
    // perfect match is a special case
    // [2] is a very good fit and should pass the ratio test, but is not zero
    DogArray<TupleDesc_F64> a = createData(1, 2, 3, 10);
    DogArray<TupleDesc_F64> b = createData(1, 2, 3.01, 4);
    AssociateGreedyBase<TupleDesc_F64> alg = createAlgorithm();
    // ratio test is turned off by default
    associate(alg, a, b);
    DogArray_I32 pairs = alg.getPairs();
    for (int i = 0; i < 4; i++) {
        assertEquals(i, pairs.get(i));
    }
    // set it so that 4 will be rejected
    alg.setRatioTest(0.1);
    associate(alg, a, b);
    pairs = alg.getPairs();
    assertEquals(0, pairs.get(0));
    assertEquals(1, pairs.get(1));
    assertEquals(2, pairs.get(2));
    assertEquals(-1, pairs.get(3));
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 78 with TupleDesc_F64

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

the class TestAssociateGreedyBruteForce2D_MT method createData.

public static DogArray<TupleDesc_F64> createData(int count) {
    Random rand = new Random(234);
    DogArray<TupleDesc_F64> ret = new DogArray<>(count, () -> new TupleDesc_F64(1));
    for (int i = 0; i < count; i++) {
        ret.grow().setTo(rand.nextDouble() * 10);
    }
    return ret;
}
Also used : Random(java.util.Random) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) DogArray(org.ddogleg.struct.DogArray)

Example 79 with TupleDesc_F64

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

the class TestAssociateGreedyDesc_MT method compare.

void compare(boolean backwards, double ratioTest) {
    DogArray<TupleDesc_F64> a = createData(200);
    DogArray<TupleDesc_F64> b = createData(200);
    AssociateGreedyDesc<TupleDesc_F64> sequentialAlg = new AssociateGreedyDesc<>(new ScoreAssociateEuclidean_F64());
    sequentialAlg.backwardsValidation = backwards;
    sequentialAlg.setRatioTest(ratioTest);
    sequentialAlg.setMaxFitError(0.5);
    sequentialAlg.associate(a, b);
    AssociateGreedyDesc_MT<TupleDesc_F64> parallelAlg = new AssociateGreedyDesc_MT<>(new ScoreAssociateEuclidean_F64());
    parallelAlg.backwardsValidation = backwards;
    parallelAlg.setRatioTest(ratioTest);
    parallelAlg.setMaxFitError(0.5);
    parallelAlg.associate(a, b);
    int[] pairs0 = sequentialAlg.getPairs().data;
    int[] pairs1 = parallelAlg.getPairs().data;
    double[] quality0 = sequentialAlg.getFitQuality().data;
    double[] quality1 = parallelAlg.getFitQuality().data;
    assertEquals(pairs0.length, pairs1.length);
    for (int i = 0; i < pairs0.length; i++) {
        assertEquals(pairs0[i], pairs1[i]);
        assertEquals(quality0[i], quality1[i]);
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ScoreAssociateEuclidean_F64(boofcv.abst.feature.associate.ScoreAssociateEuclidean_F64)

Example 80 with TupleDesc_F64

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

the class ExampleAssociateThreeView method main.

public static void main(String[] args) {
    String name = "rock_leaves_";
    GrayU8 gray01 = UtilImageIO.loadImage(UtilIO.pathExample("triple/" + name + "01.jpg"), GrayU8.class);
    GrayU8 gray02 = UtilImageIO.loadImage(UtilIO.pathExample("triple/" + name + "02.jpg"), GrayU8.class);
    GrayU8 gray03 = UtilImageIO.loadImage(UtilIO.pathExample("triple/" + name + "03.jpg"), GrayU8.class);
    // Using SURF features. Robust and fairly fast to compute
    DetectDescribePoint<GrayU8, TupleDesc_F64> detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(0, 4, 1000, 1, 9, 4, 2), null, null, GrayU8.class);
    ExampleAssociateThreeView example = new ExampleAssociateThreeView();
    example.initialize(detDesc);
    // Compute and describe features inside the image
    example.detectFeatures(gray01, 0);
    example.detectFeatures(gray02, 1);
    example.detectFeatures(gray03, 2);
    System.out.println("features01.size = " + example.features01.size);
    System.out.println("features02.size = " + example.features02.size);
    System.out.println("features03.size = " + example.features03.size);
    // Find features for an association ring across all the views. This removes most false positives.
    DogArray<AssociatedTripleIndex> associatedIdx = example.threeViewPairwiseAssociate();
    // Convert the matched indexes into AssociatedTriple which contain the actual pixel coordinates
    var associated = new DogArray<>(AssociatedTriple::new);
    associatedIdx.forEach(p -> associated.grow().setTo(example.locations01.get(p.a), example.locations02.get(p.b), example.locations03.get(p.c)));
    System.out.println("Total Matched Triples = " + associated.size);
    // Show remaining associations from RANSAC
    var triplePanel = new AssociatedTriplePanel();
    triplePanel.setImages(UtilImageIO.loadImageNotNull(UtilIO.pathExample("triple/" + name + "01.jpg")), UtilImageIO.loadImageNotNull(UtilIO.pathExample("triple/" + name + "02.jpg")), UtilImageIO.loadImageNotNull(UtilIO.pathExample("triple/" + name + "03.jpg")));
    triplePanel.setAssociation(associated.toList());
    ShowImages.showWindow(triplePanel, "Associations", true);
}
Also used : AssociatedTriple(boofcv.struct.geo.AssociatedTriple) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) AssociatedTriplePanel(boofcv.gui.feature.AssociatedTriplePanel) AssociatedTripleIndex(boofcv.struct.feature.AssociatedTripleIndex) GrayU8(boofcv.struct.image.GrayU8) DogArray(org.ddogleg.struct.DogArray)

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