use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestScoreAssociateEuclideanSq_F64 method compareToExpected.
@Test
public void compareToExpected() {
ScoreAssociateEuclideanSq_F64 score = new ScoreAssociateEuclideanSq_F64();
TupleDesc_F64 a = new TupleDesc_F64(5);
TupleDesc_F64 b = new TupleDesc_F64(5);
a.value = new double[] { 1, 2, 3, 4, 5 };
b.value = new double[] { 2, -1, 7, -8, 10 };
assertEquals(195, score.score(a, b), 1e-4);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class GenericAssociateGreedyChecks method ratioTest.
@Test
void ratioTest() {
// perfect match is a special case
// [2] is a very good fit and should pass the ratio test, but is not zero
DogArray<TupleDesc_F64> a = createData(1, 2, 3, 10);
DogArray<TupleDesc_F64> b = createData(1, 2, 3.01, 4);
AssociateGreedyBase<TupleDesc_F64> alg = createAlgorithm();
// ratio test is turned off by default
associate(alg, a, b);
DogArray_I32 pairs = alg.getPairs();
for (int i = 0; i < 4; i++) {
assertEquals(i, pairs.get(i));
}
// set it so that 4 will be rejected
alg.setRatioTest(0.1);
associate(alg, a, b);
pairs = alg.getPairs();
assertEquals(0, pairs.get(0));
assertEquals(1, pairs.get(1));
assertEquals(2, pairs.get(2));
assertEquals(-1, pairs.get(3));
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestAssociateGreedyBruteForce2D_MT method createData.
public static DogArray<TupleDesc_F64> createData(int count) {
Random rand = new Random(234);
DogArray<TupleDesc_F64> ret = new DogArray<>(count, () -> new TupleDesc_F64(1));
for (int i = 0; i < count; i++) {
ret.grow().setTo(rand.nextDouble() * 10);
}
return ret;
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestAssociateGreedyDesc_MT method compare.
void compare(boolean backwards, double ratioTest) {
DogArray<TupleDesc_F64> a = createData(200);
DogArray<TupleDesc_F64> b = createData(200);
AssociateGreedyDesc<TupleDesc_F64> sequentialAlg = new AssociateGreedyDesc<>(new ScoreAssociateEuclidean_F64());
sequentialAlg.backwardsValidation = backwards;
sequentialAlg.setRatioTest(ratioTest);
sequentialAlg.setMaxFitError(0.5);
sequentialAlg.associate(a, b);
AssociateGreedyDesc_MT<TupleDesc_F64> parallelAlg = new AssociateGreedyDesc_MT<>(new ScoreAssociateEuclidean_F64());
parallelAlg.backwardsValidation = backwards;
parallelAlg.setRatioTest(ratioTest);
parallelAlg.setMaxFitError(0.5);
parallelAlg.associate(a, b);
int[] pairs0 = sequentialAlg.getPairs().data;
int[] pairs1 = parallelAlg.getPairs().data;
double[] quality0 = sequentialAlg.getFitQuality().data;
double[] quality1 = parallelAlg.getFitQuality().data;
assertEquals(pairs0.length, pairs1.length);
for (int i = 0; i < pairs0.length; i++) {
assertEquals(pairs0[i], pairs1[i]);
assertEquals(quality0[i], quality1[i]);
}
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class ExampleAssociateThreeView method main.
public static void main(String[] args) {
String name = "rock_leaves_";
GrayU8 gray01 = UtilImageIO.loadImage(UtilIO.pathExample("triple/" + name + "01.jpg"), GrayU8.class);
GrayU8 gray02 = UtilImageIO.loadImage(UtilIO.pathExample("triple/" + name + "02.jpg"), GrayU8.class);
GrayU8 gray03 = UtilImageIO.loadImage(UtilIO.pathExample("triple/" + name + "03.jpg"), GrayU8.class);
// Using SURF features. Robust and fairly fast to compute
DetectDescribePoint<GrayU8, TupleDesc_F64> detDesc = FactoryDetectDescribe.surfStable(new ConfigFastHessian(0, 4, 1000, 1, 9, 4, 2), null, null, GrayU8.class);
ExampleAssociateThreeView example = new ExampleAssociateThreeView();
example.initialize(detDesc);
// Compute and describe features inside the image
example.detectFeatures(gray01, 0);
example.detectFeatures(gray02, 1);
example.detectFeatures(gray03, 2);
System.out.println("features01.size = " + example.features01.size);
System.out.println("features02.size = " + example.features02.size);
System.out.println("features03.size = " + example.features03.size);
// Find features for an association ring across all the views. This removes most false positives.
DogArray<AssociatedTripleIndex> associatedIdx = example.threeViewPairwiseAssociate();
// Convert the matched indexes into AssociatedTriple which contain the actual pixel coordinates
var associated = new DogArray<>(AssociatedTriple::new);
associatedIdx.forEach(p -> associated.grow().setTo(example.locations01.get(p.a), example.locations02.get(p.b), example.locations03.get(p.c)));
System.out.println("Total Matched Triples = " + associated.size);
// Show remaining associations from RANSAC
var triplePanel = new AssociatedTriplePanel();
triplePanel.setImages(UtilImageIO.loadImageNotNull(UtilIO.pathExample("triple/" + name + "01.jpg")), UtilImageIO.loadImageNotNull(UtilIO.pathExample("triple/" + name + "02.jpg")), UtilImageIO.loadImageNotNull(UtilIO.pathExample("triple/" + name + "03.jpg")));
triplePanel.setAssociation(associated.toList());
ShowImages.showWindow(triplePanel, "Associations", true);
}
Aggregations