use of boofcv.alg.feature.disparity.impl.ImplSelectSparseBasicWta_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));
}
}
}
}
Aggregations