Search in sources :

Example 6 with ConfigAssociateGreedy

use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.

the class ExampleAssociatePoints method main.

public static void main(String[] args) {
    Class imageType = GrayF32.class;
    // Class imageType = GrayU8.class;
    // select which algorithms to use
    DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 300, 1, 9, 4, 4), null, null, imageType);
    // sift(new ConfigCompleteSift(0,5,600));
    ScoreAssociation scorer = FactoryAssociation.defaultScore(detDesc.getDescriptionType());
    AssociateDescription associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true), scorer);
    // load and match images
    ExampleAssociatePoints app = new ExampleAssociatePoints(detDesc, associate, imageType);
    BufferedImage imageA = UtilImageIO.loadImageNotNull(UtilIO.pathExample("stitch/kayak_01.jpg"));
    BufferedImage imageB = UtilImageIO.loadImageNotNull(UtilIO.pathExample("stitch/kayak_03.jpg"));
    app.associate(imageA, imageB);
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) GrayF32(boofcv.struct.image.GrayF32) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) AssociateDescription(boofcv.abst.feature.associate.AssociateDescription) ScoreAssociation(boofcv.abst.feature.associate.ScoreAssociation) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 7 with ConfigAssociateGreedy

use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.

the class ExampleComputeFundamentalMatrix method computeMatches.

/**
 * Use the associate point feature example to create a list of {@link AssociatedPair} for use in computing the
 * fundamental matrix.
 */
public static List<AssociatedPair> computeMatches(BufferedImage left, BufferedImage right) {
    DetectDescribePoint<GrayF32, TupleDesc_F64> detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(0, 2, 400, 1, 9, 4, 4), null, null, GrayF32.class);
    // DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
    ScoreAssociation<TupleDesc_F64> scorer = FactoryAssociation.scoreEuclidean(TupleDesc_F64.class, true);
    AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, 0.1), scorer);
    var findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
    findMatches.associate(left, right);
    List<AssociatedPair> matches = new ArrayList<>();
    FastAccess<AssociatedIndex> matchIndexes = associate.getMatches();
    for (int i = 0; i < matchIndexes.size; i++) {
        AssociatedIndex a = matchIndexes.get(i);
        var p = new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst));
        matches.add(p);
    }
    return matches;
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) ArrayList(java.util.ArrayList) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) GrayF32(boofcv.struct.image.GrayF32) ExampleAssociatePoints(boofcv.examples.features.ExampleAssociatePoints) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 8 with ConfigAssociateGreedy

use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.

the class TestAssociateThreeByPairs method failOnBtoC.

/**
 * A->B is good. B->C is bad.
 */
@Test
void failOnBtoC() {
    DogArray<TupleDesc_F64> featuresA = UtilFeature.createArrayF64(1);
    DogArray<TupleDesc_F64> featuresB = UtilFeature.createArrayF64(1);
    DogArray<TupleDesc_F64> featuresC = UtilFeature.createArrayF64(1);
    DogArray_I32 featuresSetA = new DogArray_I32();
    DogArray_I32 featuresSetB = new DogArray_I32();
    DogArray_I32 featuresSetC = new DogArray_I32();
    featuresB.grow().setTo(234234234);
    featuresC.grow().setTo(2344234);
    featuresC.grow().setTo(99234234);
    for (int i = 0; i < 10; i++) {
        featuresA.grow().setTo(i);
        featuresB.grow().setTo(i + 0.1);
        featuresC.grow().setTo(i + 0.22);
    }
    // there is only one set
    featuresSetA.resize(featuresA.size);
    featuresSetA.fill(0);
    featuresSetB.resize(featuresB.size);
    featuresSetB.fill(0);
    featuresSetC.resize(featuresC.size);
    featuresSetC.fill(0);
    double maxError = 0.1 * 0.1 + 0.00000001;
    ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
    AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, maxError), score);
    AssociateThreeByPairs<TupleDesc_F64> alg = new AssociateThreeByPairs<>(associate);
    alg.initialize(1);
    alg.setFeaturesA(featuresA, featuresSetA);
    alg.setFeaturesB(featuresB, featuresSetB);
    alg.setFeaturesC(featuresC, featuresSetC);
    alg.associate();
    DogArray<AssociatedTripleIndex> matches = alg.getMatches();
    assertEquals(0, matches.size);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) AssociatedTripleIndex(boofcv.struct.feature.AssociatedTripleIndex) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 9 with ConfigAssociateGreedy

use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.

the class TestAssociateThreeByPairs method failOnCtoA.

/**
 * A->B is good. B->C is good. C->A exceeds error margin
 */
@Test
void failOnCtoA() {
    DogArray<TupleDesc_F64> featuresA = UtilFeature.createArrayF64(1);
    DogArray<TupleDesc_F64> featuresB = UtilFeature.createArrayF64(1);
    DogArray<TupleDesc_F64> featuresC = UtilFeature.createArrayF64(1);
    DogArray_I32 featuresSetA = new DogArray_I32();
    DogArray_I32 featuresSetB = new DogArray_I32();
    DogArray_I32 featuresSetC = new DogArray_I32();
    featuresB.grow().setTo(234234234);
    featuresC.grow().setTo(2344234);
    featuresC.grow().setTo(99234234);
    for (int i = 0; i < 10; i++) {
        featuresA.grow().setTo(i);
        featuresB.grow().setTo(i + 0.1);
        featuresC.grow().setTo(i + 0.2);
    }
    // there is only one set
    featuresSetA.resize(featuresA.size);
    featuresSetA.fill(0);
    featuresSetB.resize(featuresB.size);
    featuresSetB.fill(0);
    featuresSetC.resize(featuresC.size);
    featuresSetC.fill(0);
    double maxError = 0.1 * 0.1 + 0.00000001;
    ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
    AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, maxError), score);
    AssociateThreeByPairs<TupleDesc_F64> alg = new AssociateThreeByPairs<>(associate);
    alg.initialize(1);
    alg.setFeaturesA(featuresA, featuresSetA);
    alg.setFeaturesB(featuresB, featuresSetB);
    alg.setFeaturesC(featuresC, featuresSetC);
    alg.associate();
    DogArray<AssociatedTripleIndex> matches = alg.getMatches();
    assertEquals(0, matches.size);
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) AssociatedTripleIndex(boofcv.struct.feature.AssociatedTripleIndex) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Example 10 with ConfigAssociateGreedy

use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.

the class TestAssociateThreeByPairs method perfect.

@Test
void perfect() {
    DogArray<TupleDesc_F64> featuresA = UtilFeature.createArrayF64(1);
    DogArray<TupleDesc_F64> featuresB = UtilFeature.createArrayF64(1);
    DogArray<TupleDesc_F64> featuresC = UtilFeature.createArrayF64(1);
    DogArray_I32 featuresSetA = new DogArray_I32();
    DogArray_I32 featuresSetB = new DogArray_I32();
    DogArray_I32 featuresSetC = new DogArray_I32();
    featuresB.grow().setTo(234234234);
    featuresC.grow().setTo(2344234);
    featuresC.grow().setTo(99234234);
    for (int i = 0; i < 10; i++) {
        featuresA.grow().setTo(i);
        featuresB.grow().setTo(i);
        featuresC.grow().setTo(i);
    }
    // there is only one set
    featuresSetA.resize(featuresA.size);
    featuresSetA.fill(0);
    featuresSetB.resize(featuresB.size);
    featuresSetB.fill(0);
    featuresSetC.resize(featuresC.size);
    featuresSetC.fill(0);
    ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
    AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, 1e-8), score);
    AssociateThreeByPairs<TupleDesc_F64> alg = new AssociateThreeByPairs<>(associate);
    alg.initialize(1);
    alg.setFeaturesA(featuresA, featuresSetA);
    alg.setFeaturesB(featuresB, featuresSetB);
    alg.setFeaturesC(featuresC, featuresSetC);
    alg.associate();
    DogArray<AssociatedTripleIndex> matches = alg.getMatches();
    assertEquals(10, matches.size);
    for (int i = 0; i < 10; i++) {
        AssociatedTripleIndex a = matches.get(i);
        assertEquals(i, a.a);
        assertEquals(i + 1, a.b);
        assertEquals(i + 2, a.c);
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) AssociatedTripleIndex(boofcv.struct.feature.AssociatedTripleIndex) DogArray_I32(org.ddogleg.struct.DogArray_I32) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigAssociateGreedy (boofcv.factory.feature.associate.ConfigAssociateGreedy)10 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)7 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)4 AssociatedTripleIndex (boofcv.struct.feature.AssociatedTripleIndex)4 GrayF32 (boofcv.struct.image.GrayF32)4 DogArray_I32 (org.ddogleg.struct.DogArray_I32)4 Test (org.junit.jupiter.api.Test)4 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)3 AssociateDescription (boofcv.abst.feature.associate.AssociateDescription)2 ScoreAssociation (boofcv.abst.feature.associate.ScoreAssociation)2 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)2 AssociatedPair (boofcv.struct.geo.AssociatedPair)2 BufferedImage (java.awt.image.BufferedImage)2 ArrayList (java.util.ArrayList)2 AssociateThreeByPairs (boofcv.alg.feature.associate.AssociateThreeByPairs)1 ExampleAssociatePoints (boofcv.examples.features.ExampleAssociatePoints)1 ConfigRansac (boofcv.factory.geo.ConfigRansac)1 AssociationPanel (boofcv.gui.feature.AssociationPanel)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1