Search in sources :

Example 1 with DetectDescribePoint

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

the class ExampleImageStitching method describeImage.

/**
 * Detects features inside the two images and computes descriptions at those points.
 */
private static <T extends ImageGray<T>, FD extends TupleDesc> void describeImage(T image, DetectDescribePoint<T, FD> detDesc, List<Point2D_F64> points, FastQueue<FD> listDescs) {
    detDesc.detect(image);
    listDescs.reset();
    for (int i = 0; i < detDesc.getNumberOfFeatures(); i++) {
        points.add(detDesc.getLocation(i).copy());
        listDescs.grow().setTo(detDesc.getDescription(i));
    }
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint)

Example 2 with DetectDescribePoint

use of boofcv.abst.feature.detdesc.DetectDescribePoint 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<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
    AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 2, true);
    // 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) BrightFeature(boofcv.struct.feature.BrightFeature) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) ConfigRansac(boofcv.factory.geo.ConfigRansac) Homography2D_F64(georegression.struct.homography.Homography2D_F64)

Example 3 with DetectDescribePoint

use of boofcv.abst.feature.detdesc.DetectDescribePoint in project narchy by automenta.

the class ExampleStereoTwoViewsOneCamera method computeMatches.

/**
 * Use the associate point feature example to create a list of {@link AssociatedPair} for use in computing the
 * fundamental matrix.
 */
public void computeMatches(GrayF32 left, GrayF32 right) {
    DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 0, 1, 9, 4, 4), null, null, GrayF32.class);
    // DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
    ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
    AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 0.9, true);
    ExampleAssociatePoints<GrayF32, BrightFeature> findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
    findMatches.associate(left, right);
    FastQueue<AssociatedIndex> matchIndexes = associate.getMatches();
    matchedFeatures.clear();
    for (int i = 0; i < matchIndexes.size; i++) {
        AssociatedIndex a = matchIndexes.get(i);
        matchedFeatures.add(new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst)));
    }
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedPair(boofcv.struct.geo.AssociatedPair) BrightFeature(boofcv.struct.feature.BrightFeature) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 4 with DetectDescribePoint

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

the class ExampleFundamentalMatrix 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 detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null, null, GrayF32.class);
    // DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
    ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class, true);
    AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer, 1, true);
    ExampleAssociatePoints<GrayF32, BrightFeature> findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
    findMatches.associate(left, right);
    List<AssociatedPair> matches = new ArrayList<>();
    FastQueue<AssociatedIndex> matchIndexes = associate.getMatches();
    for (int i = 0; i < matchIndexes.size; i++) {
        AssociatedIndex a = matchIndexes.get(i);
        AssociatedPair p = new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst));
        matches.add(p);
    }
    return matches;
}
Also used : DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) AssociatedPair(boofcv.struct.geo.AssociatedPair) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) ArrayList(java.util.ArrayList) DetectDescribePoint(boofcv.abst.feature.detdesc.DetectDescribePoint) BrightFeature(boofcv.struct.feature.BrightFeature) GrayF32(boofcv.struct.image.GrayF32) ExampleAssociatePoints(boofcv.examples.features.ExampleAssociatePoints) AssociatedIndex(boofcv.struct.feature.AssociatedIndex)

Example 5 with DetectDescribePoint

use of boofcv.abst.feature.detdesc.DetectDescribePoint 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(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) ConfigFastHessian(boofcv.abst.feature.detect.interest.ConfigFastHessian) AssociateDescription(boofcv.abst.feature.associate.AssociateDescription) ScoreAssociation(boofcv.abst.feature.associate.ScoreAssociation) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

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