Search in sources :

Example 1 with FeatureSceneRecognitionNister2006

use of boofcv.abst.scene.nister2006.FeatureSceneRecognitionNister2006 in project BoofCV by lessthanoptimal.

the class TestRecognitionIO method save_load_FeatureToScene_Nister2006.

/**
 * Very basic test. Mostly just checks to see if things blow up or not
 */
@Test
void save_load_FeatureToScene_Nister2006() {
    File dir = new File(System.getProperty("java.io.tmpdir"), "feature_to_scene");
    try {
        var config = new ConfigFeatureToSceneRecognition();
        config.typeRecognize = ConfigFeatureToSceneRecognition.Type.NISTER_2006;
        ImageType<GrayU8> imageType = ImageType.SB_U8;
        var original = FactorySceneRecognition.createFeatureToScene(config, imageType);
        ((FeatureSceneRecognitionNister2006<TupleDesc_F64>) original.getRecognizer()).setDatabase(createDefaultNister2006());
        RecognitionIO.saveFeatureToScene(original, dir);
        WrapFeatureToSceneRecognition<GrayU8, TupleDesc_F64> found = RecognitionIO.loadFeatureToScene(dir, imageType);
        // Check a some things to make sure it actually loaded
        FeatureSceneRecognitionNister2006<TupleDesc_F64> foundRecognizer = found.getRecognizer();
        assertEquals(20, foundRecognizer.getDatabase().getImagesDB().size);
        assertEquals(5, foundRecognizer.getTree().nodes.size());
    } finally {
        // clean up
        if (dir.exists())
            UtilIO.deleteRecursive(dir);
    }
}
Also used : FeatureSceneRecognitionNister2006(boofcv.abst.scene.nister2006.FeatureSceneRecognitionNister2006) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) GrayU8(boofcv.struct.image.GrayU8) RecognitionNearestNeighborInvertedFile(boofcv.alg.scene.ann.RecognitionNearestNeighborInvertedFile) InvertedFile(boofcv.alg.scene.bow.InvertedFile) File(java.io.File) ConfigFeatureToSceneRecognition(boofcv.abst.scene.ConfigFeatureToSceneRecognition) Test(org.junit.jupiter.api.Test)

Example 2 with FeatureSceneRecognitionNister2006

use of boofcv.abst.scene.nister2006.FeatureSceneRecognitionNister2006 in project BoofCV by lessthanoptimal.

the class TestRecognitionIO method save_load_nister2006.

/**
 * Very basic test. Mostly just checks to see if things blow up or not
 */
@Test
void save_load_nister2006() {
    File dir = new File(System.getProperty("java.io.tmpdir"), "nister2006");
    try {
        var config = new ConfigRecognitionNister2006();
        var original = new FeatureSceneRecognitionNister2006<>(config, () -> new TupleDesc_F64(10));
        original.setDatabase(createDefaultNister2006());
        RecognitionIO.saveNister2006(original, dir);
        var found = new FeatureSceneRecognitionNister2006<>(config, () -> new TupleDesc_F64(10));
        RecognitionIO.loadNister2006(dir, found);
        // Check a some things to make sure it actually loaded
        assertEquals(20, found.getDatabase().getImagesDB().size);
        assertEquals(5, found.getTree().nodes.size());
    } finally {
        // clean up
        if (dir.exists())
            UtilIO.deleteRecursive(dir);
    }
}
Also used : FeatureSceneRecognitionNister2006(boofcv.abst.scene.nister2006.FeatureSceneRecognitionNister2006) TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) ConfigRecognitionNister2006(boofcv.abst.scene.nister2006.ConfigRecognitionNister2006) RecognitionNearestNeighborInvertedFile(boofcv.alg.scene.ann.RecognitionNearestNeighborInvertedFile) InvertedFile(boofcv.alg.scene.bow.InvertedFile) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

FeatureSceneRecognitionNister2006 (boofcv.abst.scene.nister2006.FeatureSceneRecognitionNister2006)2 RecognitionNearestNeighborInvertedFile (boofcv.alg.scene.ann.RecognitionNearestNeighborInvertedFile)2 InvertedFile (boofcv.alg.scene.bow.InvertedFile)2 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)2 File (java.io.File)2 Test (org.junit.jupiter.api.Test)2 ConfigFeatureToSceneRecognition (boofcv.abst.scene.ConfigFeatureToSceneRecognition)1 ConfigRecognitionNister2006 (boofcv.abst.scene.nister2006.ConfigRecognitionNister2006)1 GrayU8 (boofcv.struct.image.GrayU8)1