use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribeDenseSiftAlg method computeDescriptor.
/**
* Compute to the general descriptor algorithm. They should produce the same results
*/
@Test
public void computeDescriptor() {
GrayF32 derivX = new GrayF32(100, 102);
GrayF32 derivY = new GrayF32(100, 102);
GImageMiscOps.fillUniform(derivX, rand, 0, 200);
GImageMiscOps.fillUniform(derivY, rand, 0, 200);
DescribeDenseSiftAlg<GrayF32> alg = new DescribeDenseSiftAlg<>(4, 4, 8, 0.5, 0.2, 10, 10, GrayF32.class);
DescribePointSift<GrayF32> algTest = new DescribePointSift<>(4, 4, 8, 1, 0.5, 0.2, GrayF32.class);
alg.setImageGradient(derivX, derivY);
algTest.setImageGradient(derivX, derivY);
List<Point2D_I32> samplePoints = new ArrayList<>();
samplePoints.add(new Point2D_I32(30, 35));
samplePoints.add(new Point2D_I32(45, 10));
samplePoints.add(new Point2D_I32(60, 12));
samplePoints.add(new Point2D_I32(50, 50));
TupleDesc_F64 found = new TupleDesc_F64(128);
TupleDesc_F64 expected = new TupleDesc_F64(128);
for (Point2D_I32 p : samplePoints) {
alg.computeDescriptor(p.x, p.y, found);
algTest.process(p.x, p.y, 1, 0, expected);
for (int i = 0; i < 128; i++) {
assertEquals(expected.value[i], found.value[i], 1e-8);
}
}
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribePointSift method process.
/**
* Tests to see if it blows up and not much more. Random image. Compute descriptor along border and image
* center.
*/
@Test
public void process() {
GrayF32 derivX = new GrayF32(200, 200);
GrayF32 derivY = new GrayF32(200, 200);
GImageMiscOps.fillUniform(derivX, rand, -100, 100);
GImageMiscOps.fillUniform(derivY, rand, -100, 100);
DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
alg.setImageGradient(derivX, derivY);
List<Point2D_I32> testPoints = new ArrayList<>();
testPoints.add(new Point2D_I32(100, 0));
testPoints.add(new Point2D_I32(100, 199));
testPoints.add(new Point2D_I32(0, 100));
testPoints.add(new Point2D_I32(199, 100));
testPoints.add(new Point2D_I32(100, 100));
TupleDesc_F64 desc = new TupleDesc_F64(alg.getDescriptorLength());
for (Point2D_I32 where : testPoints) {
alg.process(where.x, where.y, 2, 0.5, desc);
}
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestConvertDescriptors method real_F64.
/**
* General test with a known output
*/
@Test
public void real_F64() {
TupleDesc_F64 input = new TupleDesc_F64(4);
input.value = new double[] { 1, -2, 3, -4 };
TupleDesc_S8 output = new TupleDesc_S8(4);
ConvertDescriptors.real(input, output);
assertEquals((int) (1 * 127.0 / 4.0), output.value[0]);
assertEquals((int) (-2 * 127.0 / 4.0), output.value[1]);
assertEquals((int) (3 * 127.0 / 4.0), output.value[2]);
assertEquals((int) (-4 * 127.0 / 4.0), output.value[3]);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestConvertDescriptors method convertNcc_F64.
@Test
public void convertNcc_F64() {
TupleDesc_F64 desc = new TupleDesc_F64(100);
for (int i = 0; i < desc.size(); i++) {
desc.value[i] = rand.nextDouble() * 2 - 1;
}
NccFeature found = new NccFeature(100);
ConvertDescriptors.convertNcc(desc, found);
for (int i = 0; i < desc.size(); i++) {
assertEquals(desc.value[i], found.value[i] + found.mean, 1e-8);
}
// crude test. just makes sure signa has been set really.
assertTrue(found.sigma > 0);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestConvertDescriptors method positive_F64_zeros.
/**
* Test pathological case where the input is all zeros
*/
@Test
public void positive_F64_zeros() {
TupleDesc_F64 input = new TupleDesc_F64(4);
TupleDesc_U8 output = new TupleDesc_U8(4);
ConvertDescriptors.positive(input, output);
for (int i = 0; i < 4; i++) assertEquals(0, output.value[0]);
}
Aggregations