Search in sources :

Example 6 with DetectDescribePoint

use of boofcv.abst.feature.detdesc.DetectDescribePoint 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(scorer, Double.MAX_VALUE, true);
    // load and match images
    ExampleAssociatePoints app = new ExampleAssociatePoints(detDesc, associate, imageType);
    BufferedImage imageA = UtilImageIO.loadImage(UtilIO.pathExample("stitch/kayak_01.jpg"));
    BufferedImage imageB = UtilImageIO.loadImage(UtilIO.pathExample("stitch/kayak_03.jpg"));
    app.associate(imageA, imageB);
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) GrayF32(boofcv.struct.image.GrayF32) AssociateDescription(boofcv.abst.feature.associate.AssociateDescription) ScoreAssociation(boofcv.abst.feature.associate.ScoreAssociation) BufferedImage(java.awt.image.BufferedImage)

Example 7 with DetectDescribePoint

use of boofcv.abst.feature.detdesc.DetectDescribePoint in project BoofCV by lessthanoptimal.

the class ExampleImageStitching method computeTransform.

/**
 * Using abstracted code, find a transform which minimizes the difference between corresponding features
 * in both images.  This code is completely model independent and is the core algorithms.
 */
public static <T extends ImageGray<T>, FD extends TupleDesc> Homography2D_F64 computeTransform(T imageA, T imageB, DetectDescribePoint<T, FD> detDesc, AssociateDescription<FD> associate, ModelMatcher<Homography2D_F64, AssociatedPair> modelMatcher) {
    // get the length of the description
    List<Point2D_F64> pointsA = new ArrayList<>();
    FastQueue<FD> descA = UtilFeature.createQueue(detDesc, 100);
    List<Point2D_F64> pointsB = new ArrayList<>();
    FastQueue<FD> descB = UtilFeature.createQueue(detDesc, 100);
    // extract feature locations and descriptions from each image
    describeImage(imageA, detDesc, pointsA, descA);
    describeImage(imageB, detDesc, pointsB, descB);
    // Associate features between the two images
    associate.setSource(descA);
    associate.setDestination(descB);
    associate.associate();
    // create a list of AssociatedPairs that tell the model matcher how a feature moved
    FastQueue<AssociatedIndex> matches = associate.getMatches();
    List<AssociatedPair> pairs = new ArrayList<>();
    for (int i = 0; i < matches.size(); i++) {
        AssociatedIndex match = matches.get(i);
        Point2D_F64 a = pointsA.get(match.src);
        Point2D_F64 b = pointsB.get(match.dst);
        pairs.add(new AssociatedPair(a, b, false));
    }
    // find the best fit model to describe the change between these images
    if (!modelMatcher.process(pairs))
        throw new RuntimeException("Model Matcher failed!");
    // return the found image transform
    return modelMatcher.getModelParameters().copy();
}
Also used : AssociatedPair(boofcv.struct.geo.AssociatedPair) Point2D_F64(georegression.struct.point.Point2D_F64) ArrayList(java.util.ArrayList) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Aggregations

DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)7 ConfigFastHessian (boofcv.abst.feature.detect.interest.ConfigFastHessian)4 AssociatedPair (boofcv.struct.geo.AssociatedPair)4 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)3 BrightFeature (boofcv.struct.feature.BrightFeature)3 GrayF32 (boofcv.struct.image.GrayF32)3 AssociateDescription (boofcv.abst.feature.associate.AssociateDescription)2 ScoreAssociation (boofcv.abst.feature.associate.ScoreAssociation)2 BufferedImage (java.awt.image.BufferedImage)2 ArrayList (java.util.ArrayList)2 ExampleAssociatePoints (boofcv.examples.features.ExampleAssociatePoints)1 ConfigRansac (boofcv.factory.geo.ConfigRansac)1 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)1 Homography2D_F64 (georegression.struct.homography.Homography2D_F64)1 Point2D_F64 (georegression.struct.point.Point2D_F64)1