use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribeImageDense_Convert method basic.
/**
* Checks to see if it converts the input image and that other functions are correctly
* implemented
*/
@Test
public void basic() {
Dummy dummy = new Dummy();
DescribeImageDense<GrayU8, TupleDesc_F64> alg = new DescribeImageDense_Convert(dummy, ImageType.single(GrayU8.class));
GrayU8 foo = new GrayU8(10, 20);
foo.set(5, 2, 10);
alg.process(foo);
assertTrue(dummy.process);
assertEquals(5, alg.createDescription().size());
assertTrue(TupleDesc_F64.class == alg.getDescriptionType());
assertTrue(alg.getImageType().getDataType() == ImageDataType.U8);
assertTrue(null != alg.getDescriptions());
assertTrue(null != alg.getLocations());
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestAssociateNearestNeighbor method various.
/**
* Several tests combined into one
*/
@Test
public void various() {
Dummy<Integer> nn = new Dummy<>();
// src = assoc[i] where src is the index of the source feature and i is the index of the dst feature
nn.assoc = new int[] { 2, 0, 1, -1, 4, -1, -1, 2, 2, 1 };
AssociateNearestNeighbor<TupleDesc_F64> alg = new AssociateNearestNeighbor<>(nn, 10);
FastQueue<TupleDesc_F64> src = new FastQueue<>(10, TupleDesc_F64.class, false);
FastQueue<TupleDesc_F64> dst = new FastQueue<>(10, TupleDesc_F64.class, false);
for (int i = 0; i < 5; i++) {
src.add(new TupleDesc_F64(10));
}
for (int i = 0; i < 10; i++) {
dst.add(new TupleDesc_F64(10));
}
alg.setSource(src);
alg.setDestination(dst);
alg.associate();
FastQueue<AssociatedIndex> matches = alg.getMatches();
assertTrue(nn.pointDimension == 10);
assertEquals(7, matches.size);
for (int i = 0, count = 0; i < nn.assoc.length; i++) {
if (nn.assoc[i] != -1) {
int source = nn.assoc[i];
assertEquals(source, matches.get(count).src);
assertEquals(i, matches.get(count).dst);
count++;
}
}
GrowQueue_I32 unassoc = alg.getUnassociatedSource();
assertEquals(1, unassoc.size);
assertEquals(3, unassoc.get(0));
unassoc = alg.getUnassociatedDestination();
assertEquals(3, unassoc.size);
assertEquals(3, unassoc.get(0));
assertEquals(5, unassoc.get(1));
assertEquals(6, unassoc.get(2));
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestAssociateNearestNeighbor method c.
@Override
protected TupleDesc_F64 c(double value) {
TupleDesc_F64 s = new TupleDesc_F64(1);
s.value[0] = value;
return s;
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestScoreAssociateEuclidean_F64 method compareToExpected.
@Test
public void compareToExpected() {
ScoreAssociateEuclidean_F64 score = new ScoreAssociateEuclidean_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(13.964, score.score(a, b), 1e-2);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class DescribeDenseSiftAlg method process.
/**
* Computes SIFT descriptors across the entire image
*/
public void process() {
int width = widthSubregion * widthGrid;
int radius = width / 2;
int X0 = radius, X1 = savedAngle.width - radius;
int Y0 = radius, Y1 = savedAngle.height - radius;
int numX = (int) ((X1 - X0) / periodColumns);
int numY = (int) ((Y1 - Y0) / periodRows);
descriptors.reset();
sampleLocations.reset();
for (int i = 0; i < numY; i++) {
int y = (Y1 - Y0) * i / (numY - 1) + Y0;
for (int j = 0; j < numX; j++) {
int x = (X1 - X0) * j / (numX - 1) + X0;
TupleDesc_F64 desc = descriptors.grow();
computeDescriptor(x, y, desc);
sampleLocations.grow().set(x, y);
}
}
}
Aggregations