Search in sources :

Example 1 with TupleDesc_F32

use of boofcv.struct.feature.TupleDesc_F32 in project BoofCV by lessthanoptimal.

the class TestSimilarImagesSceneRecognition method simpleAllTogether.

/**
 * Simple scenario which exercises everything all at once
 */
@Test
void simpleAllTogether() {
    var config = new ConfigSimilarImagesSceneRecognition();
    // Needed to do some hacking since the defaults assume there are a bunch of image features
    config.minimumSimilar.setRelative(0.1, 0.0);
    config.recognizeNister2006.minimumDepthFromRoot = 0;
    SimilarImagesSceneRecognition<GrayU8, TupleDesc_F32> alg = FactorySceneReconstruction.createSimilarImages(config, ImageType.SB_U8);
    alg.detector = new HelperDetector();
    for (int i = 0; i < 5; i++) {
        alg.addImage("" + i, new GrayU8(50, 10));
    }
    alg.fixate();
    // For all these other functions just check to see if something got populated
    DogArray_I32 words = new DogArray_I32();
    alg.lookupImageWords("3", words);
    assertTrue(words.size > 0);
    var features = new DogArray<>(Point2D_F64::new);
    alg.lookupPixelFeats("1", features);
    assertTrue(features.size > 0);
    // Look up similar images. All but the query view should be similar
    List<String> similarImages = new ArrayList<>();
    alg.findSimilar("0", (a) -> true, similarImages);
    assertTrue(similarImages.size() > 0);
    var pairs = new DogArray<>(AssociatedIndex::new);
    alg.lookupAssociated(similarImages.get(0), pairs);
    assertTrue(features.size > 0);
}
Also used : TupleDesc_F32(boofcv.struct.feature.TupleDesc_F32) ArrayList(java.util.ArrayList) DogArray_I32(org.ddogleg.struct.DogArray_I32) DogArray(org.ddogleg.struct.DogArray) Point2D_F64(georegression.struct.point.Point2D_F64) GrayU8(boofcv.struct.image.GrayU8) AssociatedIndex(boofcv.struct.feature.AssociatedIndex) Test(org.junit.jupiter.api.Test)

Example 2 with TupleDesc_F32

use of boofcv.struct.feature.TupleDesc_F32 in project BoofCV by lessthanoptimal.

the class TestImplDescribePointPixelRegion_F32 method checkBorder.

public void checkBorder(GrayF32 image, int c_x, int c_y, int w, int h) {
    ImplDescribePointPixelRegion_F32 alg = new ImplDescribePointPixelRegion_F32(w, h);
    TupleDesc_F32 desc = new TupleDesc_F32(alg.getDescriptorLength());
    alg.setImage(image);
    alg.process(c_x, c_y, desc);
    int index = 0;
    int y0 = c_y - h / 2;
    int x0 = c_x - w / 2;
    for (int y = y0; y < y0 + h; y++) {
        for (int x = x0; x < x0 + w; x++, index++) {
            if (image.isInBounds(x, y))
                assertEquals(image.get(x, y), desc.data[index], 1e-4);
            else
                assertEquals(0, desc.data[index], 1e-4);
        }
    }
}
Also used : TupleDesc_F32(boofcv.struct.feature.TupleDesc_F32)

Example 3 with TupleDesc_F32

use of boofcv.struct.feature.TupleDesc_F32 in project BoofCV by lessthanoptimal.

the class TestScoreAssociateSad_F32 method compareToExpected.

@Test
public void compareToExpected() {
    ScoreAssociateSad_F32 scorer = new ScoreAssociateSad_F32();
    TupleDesc_F32 a = new TupleDesc_F32(5);
    TupleDesc_F32 b = new TupleDesc_F32(5);
    a.value = new float[] { 1.1f, 2, 3, 4.5f, 5 };
    b.value = new float[] { -1, 2, 6.1f, 3, 6 };
    assertEquals(7.7, scorer.score(a, b), 1e-2);
}
Also used : TupleDesc_F32(boofcv.struct.feature.TupleDesc_F32) Test(org.junit.Test)

Example 4 with TupleDesc_F32

use of boofcv.struct.feature.TupleDesc_F32 in project BoofCV by lessthanoptimal.

the class TestScoreAssociateEuclideanSq_F32 method compareToExpected.

@Test
public void compareToExpected() {
    ScoreAssociateEuclideanSq_F32 score = new ScoreAssociateEuclideanSq_F32();
    TupleDesc_F32 a = new TupleDesc_F32(5);
    TupleDesc_F32 b = new TupleDesc_F32(5);
    a.value = new float[] { 1, 2, 3, 4, 5 };
    b.value = new float[] { 2, -1, 7, -8, 10 };
    assertEquals(195, score.score(a, b), 1e-4);
}
Also used : TupleDesc_F32(boofcv.struct.feature.TupleDesc_F32) Test(org.junit.Test)

Example 5 with TupleDesc_F32

use of boofcv.struct.feature.TupleDesc_F32 in project BoofCV by lessthanoptimal.

the class TestConvertTupleDesc_F64_F32 method createOutput.

@Test
void createOutput() {
    var alg = new ConvertTupleDesc_F64_F32(5);
    TupleDesc_F32 found = alg.createOutput();
    assertEquals(found.data.length, 5);
}
Also used : TupleDesc_F32(boofcv.struct.feature.TupleDesc_F32) Test(org.junit.jupiter.api.Test)

Aggregations

TupleDesc_F32 (boofcv.struct.feature.TupleDesc_F32)8 Test (org.junit.jupiter.api.Test)3 GrayU8 (boofcv.struct.image.GrayU8)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 Test (org.junit.Test)2 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)1 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)1 ArrayList (java.util.ArrayList)1 DogArray (org.ddogleg.struct.DogArray)1 DogArray_I32 (org.ddogleg.struct.DogArray_I32)1