Search in sources :

Example 1 with ConfigAssociateGreedy

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

the class TestAssociateThreeByPairs method failOnAtoB.

/**
 * A->B is bad.
 */
@Test
void failOnAtoB() {
    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.12);
        featuresC.grow().setTo(i + 0.3);
    }
    // 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 2 with ConfigAssociateGreedy

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

the class CompareConvertedDescriptionsApp method visualize.

public static <TD extends TupleDesc<TD>> void visualize(String title, BufferedImage image1, BufferedImage image2, InterestPointDetector<GrayF32> detector, DescribePointRadiusAngle<GrayF32, TD> describe, ScoreAssociation<TD> scorer) {
    AssociateDescription<TD> assoc = FactoryAssociation.greedy(new ConfigAssociateGreedy(false), scorer);
    List<Point2D_F64> locationSrc = new ArrayList<>();
    List<Point2D_F64> locationDst = new ArrayList<>();
    GrayF32 input1 = ConvertBufferedImage.convertFrom(image1, (GrayF32) null);
    GrayF32 input2 = ConvertBufferedImage.convertFrom(image2, (GrayF32) null);
    FastAccess<TD> listSrc = describeImage(input1, detector, describe, locationSrc);
    FastAccess<TD> listDst = describeImage(input2, detector, describe, locationDst);
    assoc.setSource(listSrc);
    assoc.setDestination(listDst);
    assoc.associate();
    FastAccess<AssociatedIndex> matches = assoc.getMatches();
    AssociationPanel panel = new AssociationPanel(20);
    panel.setImages(image1, image2);
    panel.setAssociation(locationSrc, locationDst, matches);
    ShowImages.showWindow(panel, title);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Point2D_F64(georegression.struct.point.Point2D_F64) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) ArrayList(java.util.ArrayList) AssociationPanel(boofcv.gui.feature.AssociationPanel) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 3 with ConfigAssociateGreedy

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

the class ExampleImageStitching method stitch.

/**
 * Given two input images create and display an image where the two have been overlayed on top of each other.
 */
public static <T extends ImageGray<T>> void stitch(BufferedImage imageA, BufferedImage imageB, Class<T> imageType) {
    T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType);
    T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType);
    // Detect using the standard SURF feature descriptor and describer
    DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null, null, imageType);
    ScoreAssociation<TupleDesc_F64> scorer = FactoryAssociation.scoreEuclidean(TupleDesc_F64.class, true);
    AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, 2), scorer);
    // fit the images using a homography. This works well for rotations and distant objects.
    ModelMatcher<Homography2D_F64, AssociatedPair> modelMatcher = FactoryMultiViewRobust.homographyRansac(null, new ConfigRansac(60, 3));
    Homography2D_F64 H = computeTransform(inputA, inputB, detDesc, associate, modelMatcher);
    renderStitching(imageA, imageB, H);
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) 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) ConfigRansac(boofcv.factory.geo.ConfigRansac) Homography2D_F64(georegression.struct.homography.Homography2D_F64)

Example 4 with ConfigAssociateGreedy

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

the class ExampleAssociateThreeView method threeViewPairwiseAssociate.

/**
 * BoofCV comes with a class which does all the three view matching for you. Which association and scoring
 * function are used is all configurable.
 */
public DogArray<AssociatedTripleIndex> threeViewPairwiseAssociate() {
    ScoreAssociation<TupleDesc_F64> scorer = FactoryAssociation.scoreEuclidean(TupleDesc_F64.class, true);
    AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, 0.1), scorer);
    var associateThree = new AssociateThreeByPairs<>(associate);
    associateThree.initialize(detDesc.getNumberOfSets());
    associateThree.setFeaturesA(features01, featureSet01);
    associateThree.setFeaturesB(features02, featureSet02);
    associateThree.setFeaturesC(features03, featureSet03);
    associateThree.associate();
    return associateThree.getMatches();
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) AssociateThreeByPairs(boofcv.alg.feature.associate.AssociateThreeByPairs) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy)

Example 5 with ConfigAssociateGreedy

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

the class ExampleDetectDescribe method main.

public static void main(String[] args) {
    Class imageType = GrayF32.class;
    DetectDescribePoint detDesc = createFromPremade(imageType);
    // DetectDescribePoint detDesc = createFromComponents(imageType);
    // Might as well have this example do something useful, like associate two images
    ScoreAssociation scorer = FactoryAssociation.defaultScore(detDesc.getDescriptionType());
    AssociateDescription associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true), scorer);
    // load and match images
    var 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) ConfigAssociateGreedy(boofcv.factory.feature.associate.ConfigAssociateGreedy) AssociateDescription(boofcv.abst.feature.associate.AssociateDescription) ScoreAssociation(boofcv.abst.feature.associate.ScoreAssociation) BufferedImage(java.awt.image.BufferedImage)

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