use of boofcv.factory.feature.associate.ConfigAssociateGreedy 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(new ConfigAssociateGreedy(true), scorer);
// load and match images
ExampleAssociatePoints 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);
}
use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.
the class ExampleComputeFundamentalMatrix 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<GrayF32, TupleDesc_F64> detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(0, 2, 400, 1, 9, 4, 4), null, null, GrayF32.class);
// DetectDescribePoint detDesc = FactoryDetectDescribe.sift(null,new ConfigSiftDetector(2,0,200,5),null,null);
ScoreAssociation<TupleDesc_F64> scorer = FactoryAssociation.scoreEuclidean(TupleDesc_F64.class, true);
AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, 0.1), scorer);
var findMatches = new ExampleAssociatePoints<>(detDesc, associate, GrayF32.class);
findMatches.associate(left, right);
List<AssociatedPair> matches = new ArrayList<>();
FastAccess<AssociatedIndex> matchIndexes = associate.getMatches();
for (int i = 0; i < matchIndexes.size; i++) {
AssociatedIndex a = matchIndexes.get(i);
var p = new AssociatedPair(findMatches.pointsA.get(a.src), findMatches.pointsB.get(a.dst));
matches.add(p);
}
return matches;
}
use of boofcv.factory.feature.associate.ConfigAssociateGreedy in project BoofCV by lessthanoptimal.
the class TestAssociateThreeByPairs method failOnBtoC.
/**
* A->B is good. B->C is bad.
*/
@Test
void failOnBtoC() {
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.1);
featuresC.grow().setTo(i + 0.22);
}
// 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 TestAssociateThreeByPairs method failOnCtoA.
/**
* A->B is good. B->C is good. C->A exceeds error margin
*/
@Test
void failOnCtoA() {
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.1);
featuresC.grow().setTo(i + 0.2);
}
// 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 TestAssociateThreeByPairs method perfect.
@Test
void perfect() {
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);
featuresC.grow().setTo(i);
}
// 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);
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
AssociateDescription<TupleDesc_F64> associate = FactoryAssociation.greedy(new ConfigAssociateGreedy(true, 1e-8), 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(10, matches.size);
for (int i = 0; i < 10; i++) {
AssociatedTripleIndex a = matches.get(i);
assertEquals(i, a.a);
assertEquals(i + 1, a.b);
assertEquals(i + 2, a.c);
}
}
Aggregations