Search in sources :

Example 1 with ImplDisparitySparseScoreSadRect_F32

use of boofcv.alg.feature.disparity.impl.ImplDisparitySparseScoreSadRect_F32 in project BoofCV by lessthanoptimal.

the class TestWrapDisparitySparseSadRect method compareToDense.

/**
 * Compare to the equivalent dense algorithm
 */
@Test
public void compareToDense() {
    // more stressful if not 0
    int minDisparity = 3;
    int maxDisparity = 12;
    GrayF32 left = new GrayF32(w, h);
    GrayF32 right = new GrayF32(w, h);
    StereoDisparity<GrayF32, GrayU8> validator = FactoryStereoDisparity.regionWta(DisparityAlgorithms.RECT, minDisparity, maxDisparity, r, r, -1, -1, -1, GrayF32.class);
    StereoDisparitySparse<GrayF32> alg = new WrapDisparitySparseSadRect<>(new ImplDisparitySparseScoreSadRect_F32(minDisparity, maxDisparity, r, r), new ImplSelectSparseBasicWta_F32());
    validator.process(left, right);
    GrayU8 expected = validator.getDisparity();
    alg.setImages(left, right);
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            if (alg.process(x, y)) {
                double found = alg.getDisparity();
                assertEquals(minDisparity + expected.get(x, y), (int) found);
            } else {
                assertTrue(expected.get(x, y) > (maxDisparity - minDisparity));
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImplSelectSparseBasicWta_F32(boofcv.alg.feature.disparity.impl.ImplSelectSparseBasicWta_F32) GrayU8(boofcv.struct.image.GrayU8) ImplDisparitySparseScoreSadRect_F32(boofcv.alg.feature.disparity.impl.ImplDisparitySparseScoreSadRect_F32) Test(org.junit.Test)

Aggregations

ImplDisparitySparseScoreSadRect_F32 (boofcv.alg.feature.disparity.impl.ImplDisparitySparseScoreSadRect_F32)1 ImplSelectSparseBasicWta_F32 (boofcv.alg.feature.disparity.impl.ImplSelectSparseBasicWta_F32)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayU8 (boofcv.struct.image.GrayU8)1 Test (org.junit.Test)1