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);
}
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();
}
Aggregations