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